Infront Data Manager Connect Client (.NET)
Public Member Functions | Protected Member Functions | Properties | List of all members
Gevasys.DataCore.Client.PushClient Class Referenceabstract

More...

Inherits Gevasys.DataCore.Client.IPushClient.

Inherited by Examples.SamplePushClient, and Gevasys.DataCore.Tools.Cache.PriceCache.

Public Member Functions

long GetCountUpdates ()
 
String GetName ()
 
void Start ()
 
void AddNewData (List< UpdateMessage > newUpdates)
 
void Run ()
 For internal use only. More...
 
void Stop ()
 
abstract void ProcessUpdates (List< UpdateMessage > updates)
 
abstract void Update (DataCore.Core.IConsumer source, ConsumerStateChangedEventArgs arg)
 Abstract method that must be implemented in derived classes to recive status notifications for the underlying consumers. More...
 
- Public Member Functions inherited from Gevasys.DataCore.Client.IPushClient
void Update (IConsumer source, ConsumerStateChangedEventArgs arg)
 Method for processing incoming status notifications for a Consumer. More...
 

Protected Member Functions

 PushClient (String name)
 

Properties

string Name [get]
 Name of the push client. The name is also used as the name of the push client thread to make identifying your thread during debugging easier. More...
 

Detailed Description

Represents the abstract base class for all push clients. Derive from this class to create a push client that receives data.

Any push client can be attached to one StreamingPartitioner or to one or more ConsumerStore .

The processing of updates is done in two stages.

1. All incoming updates from the attached StreamingPartioner or ConsumerStore are stored in an internal

List to physically separate the updates for a specific push client from the owning StreamingPartitioner or ConsumerStore.

2. All in stage 1 stored updates are moved to a second ArrayDeque and then a call to processUpdates with this updates is made.

This stage is executed in a separate Thread so that your processing code for updates will never block incoming updates from any

StreamingPartitioner or ConsumerStore and so any update is strictly separated from the IO layer.

Attention!

Because user specific code for processing updates in or after the processUpdates method does not block the IO layer and the buffer

for the IO layer is not limited in size(but limited by the available system memory), you can run into a situation where your application

terminates with an OutOfMemoryError exception, and/or any update that is processed by user specific code

is effectively delayed. To avoid this situation ensure that your code is fast enough to process all incoming updates.

Any instances of this class are thread safe.

using System;
using System.Collections.Generic;
using Gevasys.DataCore.Client.Logging;
using Gevasys.DataCore.Core.Protocol.Binary.Decoding;
namespace Test
{
public class SamplePushClient : PushClient
{
public SamplePushClient(String name)
: base(name)
{
}
public override void ProcessUpdates(List<UpdateMessage>updates)
{
foreach (UpdateMessage update in updates)
{
String instrument = update.GetInstrument();
BaseField field = null;
Console.WriteLine(update.toMachineReadableOutput());
if (update.TryGetField(26, out field))
{
Console.Write(" 26: " + ((DateTimeField)field).Value);
}
if (update.TryGetField(28, out field))
{
Console.Write(" 28: " + ((DoubleField)field).Value);
}
if (update.TryGetField(30, out field))
{
Console.Write(" 29: " + ((DoubleField)field).Value);
}
if (update.TryGetField(80, out field))
{
Console.Write(" 80: " + ((DoubleField)field).Value);
}
foreach (BaseField fieldUpdate in update.FieldDict.Values)
{
short fieldId = fieldUpdate.FieldId;
switch (fieldUpdate.DataTypeValue)
{
case BaseBinaryMessage.DataType.Float:
float value = ((FloatField)fieldUpdate).Value;
break;
case BaseBinaryMessage.DataType.Short:
short shortValue = ((ShortField)fieldUpdate).Value;
break;
case BaseBinaryMessage.DataType.String:
string stringValue = ((StringField)fieldUpdate).Value;
break;
case BaseBinaryMessage.DataType.Int32:
int intValue = ((IntField)fieldUpdate).Value;
break;
case BaseBinaryMessage.DataType.Long:
long longValue = ((LongField)fieldUpdate).Value;
break;
case BaseBinaryMessage.DataType.Double:
double doubleValue = ((DoubleField)fieldUpdate).Value;
break;
case BaseBinaryMessage.DataType.DateTime:
DateTime dateValue = ((DateTimeField)fieldUpdate).Value;
break;
default:
break;
}
}
}
}
public override void Update(IConsumer source, ConsumerStateChangedEventArgs arg)
{
if (source.GetConsumerType() == ConsumerType.ConsumerPartitioner)
{
// Attached partitioner is offline. No incoming updates.
if (!arg.IsOnline)
{
Logger.Log.Warn("Partitioner " + source.GetName() + " is offline");
}
// Attached partitioner is online.
else
{
Logger.Log.Info("Partitioner is " + source.GetName() + " online");
}
}
else if (source.GetConsumerType() == ConsumerType.ConsumerStore)
{
// Attached consumer store is offline. No incoming updates.
if (!arg.IsOnline)
{
Logger.Log.Warn("Consumer store " + source.GetName() + " is offline");
}
// Attached consumer store is online.
else
{
Logger.Log.Info("Consumer store " + source.GetName() + " is online");
}
}
}
}
}

Constructor & Destructor Documentation

◆ PushClient()

Gevasys.DataCore.Client.PushClient.PushClient ( String  name)
inlineprotected

Creates a new push client with the given name. The given name is also

used to build the name for the thread for this push client so that <br>

you can identify it during debugging.

Member Function Documentation

◆ AddNewData()

void Gevasys.DataCore.Client.PushClient.AddNewData ( List< UpdateMessage newUpdates)
inline

Let's an IConsumer add all new updates to an internal List for later and independent

processing of updates.

Implements Gevasys.DataCore.Client.IPushClient.

◆ GetCountUpdates()

long Gevasys.DataCore.Client.PushClient.GetCountUpdates ( )
inline

Gets the count of received updates for this client.

Returns
<font color="#3F5FBF" size="2"> <font color="#3F5FBF" size="2">The update count.</font> </font>

◆ GetName()

String Gevasys.DataCore.Client.PushClient.GetName ( )
inline

Gets the name of this push client.

Returns
<font color="#3F5FBF" size="2"> <font color="#3F5FBF" size="2">The name of the Push Client.</font> </font>

◆ ProcessUpdates()

abstract void Gevasys.DataCore.Client.PushClient.ProcessUpdates ( List< UpdateMessage updates)
pure virtual

Abstract method which must be overridden in derived classes. This is the

entry point for user specific code for processing updates.

Implements Gevasys.DataCore.Client.IPushClient.

Implemented in Gevasys.DataCore.Tools.Cache.PriceCache.

◆ Run()

void Gevasys.DataCore.Client.PushClient.Run ( )
inline

For internal use only.

Implements Gevasys.DataCore.Core.IRunnable.

◆ Start()

void Gevasys.DataCore.Client.PushClient.Start ( )
inline

Creates and starts the thread for this push client.

◆ Stop()

void Gevasys.DataCore.Client.PushClient.Stop ( )
inline

Stops the client.

Implements Gevasys.DataCore.Core.IRunnable.

◆ Update()

abstract void Gevasys.DataCore.Client.PushClient.Update ( DataCore.Core.IConsumer  source,
ConsumerStateChangedEventArgs  arg 
)
pure virtual

Abstract method that must be implemented in derived classes to recive status notifications for the underlying consumers.

Property Documentation

◆ Name

string Gevasys.DataCore.Client.PushClient.Name
get

Name of the push client. The name is also used as the name of the push client thread to make identifying your thread during debugging easier.


The documentation for this class was generated from the following file:
Gevasys.DataCore
Definition: BinaryUpstreamClient.cs:5
Gevasys.DataCore.Client.PushClient.PushClient
PushClient(String name)
Definition: PushClient.cs:169
Gevasys.DataCore.Client.PushClient.Update
abstract void Update(DataCore.Core.IConsumer source, ConsumerStateChangedEventArgs arg)
Abstract method that must be implemented in derived classes to recive status notifications for the un...
Gevasys.DataCore.Client.PushClient.ProcessUpdates
abstract void ProcessUpdates(List< UpdateMessage > updates)
Gevasys.DataCore.Client
Definition: BinaryUpstreamClient.cs:5
Gevasys.DataCore.Core.Protocol
Definition: RequestStatusMessage.cs:8
Gevasys
Definition: BinaryUpstreamClient.cs:5
Gevasys.DataCore.Core.ConsumerType
ConsumerType
Definition: ConsumerType.cs:6
Gevasys.DataCore.Core
Definition: CompressionHelper.cs:7

Copyright (C) 2021 Infront Financial Technology GmbH
Mainzer Landstrasse 178 – 190
60327 Frankfurt am Main
Infront Data Manager Connect V4.1