Table of Contents

Class DXEndpoint

Namespace
DxFeed.Graal.Net.Api
Assembly
DxFeed.Graal.Net.dll

Manages network connections to DXFeed or DXPublisher.
Porting a Java class com.dxfeed.api.DXEndpoint.
For more details see Javadoc.
There are ready-to-use singleton instances that are available with GetInstance() and GetInstance(Role) methods as wel as factory methods Create() and Create(Role), and a number of configuration methods.
Advanced properties can be configured with DXEndpoint.Builder (creates with NewBuilder()).

Threads and locks

This class is thread-safe and can be used concurrently from multiple threads without external synchronization.

Lifetimes

This class will not be garbage-collected and its resources will not be freed until Dispose(), Close() or CloseAndAwaitTermination() methods are called. Calling these methods ensures that instance can be safely garbage-collected when all outside references to it are lost. If a reference to an instance of this class is lost before calling the above methods, it causes a memory/resource leak. This behavior was implemented intentionally. Inner instances of DXFeed and DXPublisher have the same lifetime as DXEndpoint. DXFeed and DXPublisher have no public resource release methods, and exist as long as DXEndpoint exists.

public sealed class DXEndpoint : IDisposable
Inheritance
DXEndpoint
Implements
Inherited Members

Examples

DXFeed feed = DXEndpoint.Create()
    .User("demo").Password("demo")
    .Connect("demo.dxfeed.com:7300")
    .GetFeed();

Fields

DXEndpointEventTimeProperty

Set this property to true to enable EventTime support. By default, the endpoint does not support event time.
The event time is available only when the corresponding DXEndpoint is created with this property and the data source has embedded event times. This is typically true only for data events that are read from historical tape files. Events that are coming from a network connections do not have an embedded event time information and event time is not available for them anyway.

public const string DXEndpointEventTimeProperty = "dxendpoint.eventTime"

Field Value

string

DXEndpointStoreEverythingProperty

Set this property to to store all ILastingEvent and ILastingEvent events even when there is no subscription on them. By default, the endpoint stores only events from subscriptions. It works in the same way both for DXFeed and DXPublisher.
Use this property with extreme care, since API does not currently provide any means to remove those events from the storage and there might be an effective memory leak if the spaces of symbols on which events are published grows without bound.

public const string DXEndpointStoreEverythingProperty = "dxendpoint.storeEverything"

Field Value

string

DXFeedAddressProperty

Defines default connection address for an endpoint with role Feed or OnDemandFeed. Connection is established to this address by role Feed as soon as endpoint is created.
By default, without this property, connection is not established until Connect(string) is invoked.
Credentials for access to premium services may be configured with DXFeedUserProperty and DXFeedPasswordProperty.

public const string DXFeedAddressProperty = "dxfeed.address"

Field Value

string
See Also

DXFeedAggregationPeriodProperty

Defines data aggregation period an endpoint with role Feed that limits the rate of data notifications. For example, setting the value of this property to "0.1s" limits notification to once every 100ms (at most 10 per second).

public const string DXFeedAggregationPeriodProperty = "dxfeed.aggregationPeriod"

Field Value

string
See Also

DXFeedPasswordProperty

Defines default password for an endpoint with role Feed or OnDemandFeed.

public const string DXFeedPasswordProperty = "dxfeed.password"

Field Value

string
See Also

DXFeedPropertiesProperty

Defines path to a file with properties for an endpoint with role Feed or OnDemandFeed.
This file must be in the Java properties file format.
This property can also be set using SetProperty(string, string), as the default property for all instances DXEndpoint with Feed or or OnDemandFeed role.
When the path to this properties file not provided (SetProperty(string, string) and WithProperty(string, string)), the file "dxfeed.properties" loaded from current runtime directory. It means that the corresponding file can be placed into the current directory with any need to specify additional properties.

public const string DXFeedPropertiesProperty = "dxfeed.properties"

Field Value

string
See Also

DXFeedThreadPoolSizeProperty

Defines thread pool size for an endpoint with role Feed. By default, the thread pool size is equal to the number of available processors.

public const string DXFeedThreadPoolSizeProperty = "dxfeed.threadPoolSize"

Field Value

string
See Also

DXFeedUserProperty

Defines default user name for an endpoint with role Feed or OnDemandFeed.

public const string DXFeedUserProperty = "dxfeed.user"

Field Value

string
See Also

DXFeedWildcardEnableProperty

Set this property to true to turns on wildcard support. By default, the endpoint does not support wildcards. This property is needed for WildcardSymbol support and for the use of "tape:..." address in DXPublisher.

public const string DXFeedWildcardEnableProperty = "dxfeed.wildcard.enable"

Field Value

string
See Also

DXPublisherAddressProperty

Defines default connection address for an endpoint with role Publisher. Connection is established to this address as soon as endpoint is created. By default, connection is not established until Connect(string) is invoked.

public const string DXPublisherAddressProperty = "dxpublisher.address"

Field Value

string
See Also

DXPublisherPropertiesProperty

Defines path to a file with properties for an endpoint with role Publisher.
This file must be in the Java properties file format.
This property can also be set using SetProperty(string, string), as the default property for all instances DXEndpoint with Publisher role.
When the path to this properties file not provided (SetProperty(string, string) and WithProperty(string, string)), the file "dxpublisher.properties" loaded from current runtime directory. It means that the corresponding file can be placed into the current directory with any need to specify additional properties.

public const string DXPublisherPropertiesProperty = "dxpublisher.properties"

Field Value

string
See Also

DXPublisherThreadPoolSizeProperty

Defines thread pool size for an endpoint with role Publisher. By default, the thread pool size is equal to the number of available processors.

public const string DXPublisherThreadPoolSizeProperty = "dxpublisher.threadPoolSize"

Field Value

string
See Also

DXSchemeEnabledPropertyPrefix

Defines whether a specified field from the scheme should be enabled instead of it's default behaviour.
Use it according to following format:
dxscheme.enabled.field_property_name=event_name_mask_glob
For example, dxscheme.enabled.TimeNanoPart=Trade enables NanoTimePart internal field only in Trade events. There is a shortcut for turning on nano-time support using DXSchemeNanoTimeProperty.

public const string DXSchemeEnabledPropertyPrefix = "dxscheme.enabled."

Field Value

string

DXSchemeNanoTimeProperty

Set this property to true to turn on nanoseconds precision business time. By default, this feature is turned off. Business time in most events is available with millisecond precision by default, while Quote events business Time is available with seconds precision.
This method provides a higher-level control than turning on individual properties that are responsible for nano-time via DXSchemeEnabledPropertyPrefix. The later can be used to override of fine-time nano-time support for individual fields. Setting this property to true is essentially equivalent to setting:

dxscheme.enabled.Sequence=*
dxscheme.enabled.TimeNanoPart=*
public const string DXSchemeNanoTimeProperty = "dxscheme.nanoTime"

Field Value

string

NameProperty

Defines property for endpoint name that is used to distinguish multiple endpoints in the same JVM in logs and in other diagnostic means. Use WithProperty(string, string) method. This property is also changed by WithName(string) method.

public const string NameProperty = "name"

Field Value

string

Methods

AddStateChangeListener(StateChangeListener)

Adds listener that is notified about changes in GetState() property.
Installed listener can be removed with RemoveStateChangeListener(StateChangeListener) method.

public void AddStateChangeListener(DXEndpoint.StateChangeListener listener)

Parameters

listener DXEndpoint.StateChangeListener

The listener to add.

AwaitNotConnected()

Waits while this endpoint DXEndpoint.State becomes NotConnected or Closed. It is a signal that any files that were opened with Connect("file:...") method were finished reading, but not necessary were completely processed by the corresponding subscription listeners. Use CloseAndAwaitTermination() after this method returns to make sure that all processing has completed.
This method is blocking.

public void AwaitNotConnected()

AwaitProcessed()

Waits until this endpoint stops processing data (becomes quiescent). This is important when writing data to file via "tape:..." connector to make sure that all published data was written before closing this endpoint.
This method is blocking.

public void AwaitProcessed()

Close()

Closes this endpoint. All network connection are terminated as with Disconnect() method and no further connections can be established. The endpoint DXEndpoint.State immediately becomes Closed.
This method ensures that DXEndpoint can be safely garbage-collected when all outside references to it are lost.

public void Close()

CloseAndAwaitTermination()

Closes this endpoint and wait until all pending data processing tasks are completed. This method performs the same actions as close Close(), but also awaits termination of all outstanding data processing tasks. It is designed to be used with StreamFeed role after AwaitNotConnected() method returns to make sure that file was completely processed.
This method is blocking.
This method ensures that DXEndpoint can be safely garbage-collected when all outside references to it are lost.

public void CloseAndAwaitTermination()

Connect(string)

Connects to the specified remote address. Previously established connections are closed if the new address is different from the old one. This method does nothing if address does not change or if this endpoint is Closed. The endpoint DXEndpoint.State immediately becomes Connecting otherwise.
The address string is provided with the market data vendor agreement. Use "demo.dxfeed.com:7300" for a demo quote feed.

  • host:port to establish a TCP/IP connection.
  • :port to listen for a TCP/IP connection with a plain socket connector (good for up to a few hundred of connections).

For premium services access credentials must be configured before invocation of Connect(string) method using User(string) and Password(string) methods.
This method does not wait until connection actually gets established. The actual connection establishment happens asynchronously after the invocation of this method. However, this method waits until notification about state transition from NotConnected to Connecting gets processed by all DXEndpoint.StateChangeListener that were installed via AddStateChangeListener(StateChangeListener) method.
public DXEndpoint Connect(string address)

Parameters

address string

The data source address.

Returns

DXEndpoint

Returns this DXEndpoint.

Exceptions

ArgumentNullException

If address is null.

JavaException

If address string is malformed.

Create()

Creates an endpoint with a role Feed.

public static DXEndpoint Create()

Returns

DXEndpoint

The created DXEndpoint.

Create(Role)

Creates an endpoint with a specified DXEndpoint.Role.

public static DXEndpoint Create(DXEndpoint.Role role)

Parameters

role DXEndpoint.Role

The specified DXEndpoint.Role.

Returns

DXEndpoint

The created DXEndpoint.

Disconnect()

Terminates all remote network connections. This method does nothing if this endpoint is Closed. The endpoint DXEndpoint.State immediately becomes NotConnected otherwise.
This method does not release all resources that are associated with this endpoint. Use Close(), Dispose() or CloseAndAwaitTermination() methods to release all resources.

public void Disconnect()

DisconnectAndClear()

Terminates all remote network connections and clears stored data. This method does nothing if this endpoint is Closed. The endpoint DXEndpoint.State immediately becomes NotConnected otherwise.
This method does not release all resources that are associated with this endpoint. Use Close(), Dispose() or CloseAndAwaitTermination() methods to release all resources.

public void DisconnectAndClear()

Dispose()

Closes this endpoint and releases all resources used by the current instance of the DXEndpoint class. This is the same as Close().
This method ensures that DXEndpoint can be safely garbage-collected when all outside references to it are lost.

public void Dispose()

GetEventTypes()

Gets all IEventType types supported by DXEndpoint.

public static IEnumerable<Type> GetEventTypes()

Returns

IEnumerable<Type>

A collection of event types.

GetFeed()

Gets DXFeed that is associated with this endpoint.

public DXFeed GetFeed()

Returns

DXFeed

The DXFeed.

GetInstance()

Gets a default application-wide singleton instance of DXEndpoint with a Feed role. Most applications use only a single data-source and should rely on this method to get one.

public static DXEndpoint GetInstance()

Returns

DXEndpoint

Returns singleton instance of DXEndpoint.

GetInstance(Role)

Gets a default application-wide singleton instance of DXEndpoint with a specific DXEndpoint.Role. Most applications use only a single data-source and should rely on this method to get one.

public static DXEndpoint GetInstance(DXEndpoint.Role role)

Parameters

role DXEndpoint.Role

The DXEndpoint.Role.

Returns

DXEndpoint

Returns singleton instance of DXEndpoint.

GetName()

Gets endpoint name.

public string GetName()

Returns

string

Returns endpoint name.

GetPublisher()

Gets DXPublisher that is associated with this endpoint.

public DXPublisher GetPublisher()

Returns

DXPublisher

The DXPublisher.

GetRole()

Gets the DXEndpoint.Role of this endpoint.

public DXEndpoint.Role GetRole()

Returns

DXEndpoint.Role

The DXEndpoint.Role.

GetState()

Gets the DXEndpoint.State of this endpoint.

public DXEndpoint.State GetState()

Returns

DXEndpoint.State

The DXEndpoint.State.

IsClosed()

Gets a value indicating whether if this endpoint is closed. There is a shortcut for GetState() == Closed.

public bool IsClosed()

Returns

bool

Returns true if this endpoint is closed.

NewBuilder()

Creates new DXEndpoint.Builder instance. Use Build() to build an instance of DXEndpoint when all configuration properties were set.

public static DXEndpoint.Builder NewBuilder()

Returns

DXEndpoint.Builder

The created DXEndpoint.Builder instance.

Password(string)

Changes password for this endpoint. This method shall be called before Connect(string) together with User(string) to configure service access credentials.

public DXEndpoint Password(string password)

Parameters

password string

The user password.

Returns

DXEndpoint

Returns this DXEndpoint.

Exceptions

ArgumentNullException

If password is null.

Reconnect()

Terminates all established network connections and initiates connecting again with the same address.
The effect of the method is alike to invoking Disconnect() and Connect(string) with the current address, but internal resources used for connections may be reused by implementation. TCP connections with multiple target addresses will try switch to an alternative address, configured reconnect timeouts will apply.
Note: The method will not connect endpoint that was not initially connected with Connect(string) method or was disconnected with Disconnect() method.
The method initiates a short-path way for reconnecting, so whether observers will have a chance to see an intermediate state NotConnected depends on the implementation.

public void Reconnect()

RemoveStateChangeListener(StateChangeListener)

Removes listener that is notified about changes in GetState() property.
It removes the listener that was previously installed with AddStateChangeListener(StateChangeListener) method.

public void RemoveStateChangeListener(DXEndpoint.StateChangeListener listener)

Parameters

listener DXEndpoint.StateChangeListener

The listener to remove.

User(string)

Changes user name for this endpoint. This method shall be called before Connect(string) together with Password(string) to configure service access credentials.

public DXEndpoint User(string user)

Parameters

user string

The user name.

Returns

DXEndpoint

Returns this DXEndpoint.

Exceptions

ArgumentNullException

If user is null.