Market data publisher components
The Depth and Tick publisher components provide a convenient action-based interface for tracking subscriptions for com.apama.marketdata.Depth and Tick events and for publishing these events to subscribers in response to market data updates. These components will generally be used by adapter services but they are recommended for any service that needs to publish market data to users or other parts of an application. The publisher components handle all of the book-keeping associated with publishing market data to multiple subscribers, such as subscription reference counting and caching of the last market depth to send to new subscribers.
A new com.apama.marketdata.DepthPublisher object can be initialized in two different ways:
1. From a com.apama.marketdata.SubscribeDepth event. This reflects the most common case, where a service is listening for the first subscription request made for each symbol offered by the service, then constructing a depth publisher to handle this and all subsequent subscriptions.
2. From a com.apama.marketdata.DepthKey event. Using this method implies that the service knows in advance which symbols applications will be subscribing to, so that the depth publishers can be constructed in advance.
In both cases, the depth publisher will set up listeners for future subscription and unsubscription events for the same key (such as, the same combination of service, exchange and market identifiers, and symbol). The publisher will keep track of the number of active subscriptions and route a com.apama.marketdata.DepthRefCount0 event when this number falls to zero. The service should listen for this event so it knows when to stop publishing depth updates for a given symbol.
Market depth updates are routed by the publisher when its setData() or setDataWithExtraParams() actions are called. The publisher also provides actions to update market depth in response to common order management operations:
New order submitted:
changeDepthOnNewOrder()Order amended:
changeDepthOnAmendOrder()Order canceled:
changeDepthOnCancelOrder()Order filled:
changeDepthOnOrdersFilled()After using the changeDepth*() actions, the service should call the routeData() action to deliver the updated market depth to all subscribers.
The design of the com.apama.marketdata.TickPublisher object is very similar to that of the depth publisher. See the ApamaDoc pages for these objects for full details of the actions they offer.