Package com.wombat.mamda
Class MamdaSubscription
- java.lang.Object
-
- com.wombat.mamda.MamdaSubscription
-
public class MamdaSubscription extends java.lang.ObjectA MamdaSubscription is used to register interest in a particular symbol and source. A MamaTransport is required to actually activate the subscription. Multiple listeners can be added to the MamdaSubscription. In this way, an application can make use of more than one of the specialized value added MAMDA listeners, such as MamdaTradeListener and MamdaQuoteListener.
-
-
Constructor Summary
Constructors Constructor Description MamdaSubscription()Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivate()Activate the subscription.voidaddErrorListener(MamdaErrorListener listener)Add a listener for error events.voidaddMsgListener(MamdaMsgListener listener)Add a listener for regular messages.voidaddStaleListener(MamdaStaleListener listener)Add a listener for changes in stale status.voidcreate(com.wombat.mama.MamaTransport transport, com.wombat.mama.MamaQueue queue, java.lang.String source, java.lang.String symbol, java.lang.Object closure)Create and activate a subscription.voiddeactivate()Deactivate the subscription.com.wombat.mama.MamaMdDataTypegetAppDataType()Retrieve the application-specific data type.java.lang.ObjectgetClosure()Get the additional object passed as the closure to the create() method.com.wombat.mama.MamaSubscriptiongetMamaSubscription()java.util.VectorgetMsgListeners()com.wombat.mama.MamaMsgQualifiergetMsgQualifier()Return the MamaMsgQualifierintgetPreInitialCacheSize()Return the initial value cache sizecom.wombat.mama.MamaQueuegetQueue()booleangetRecoverGaps()Whether the specified subscription will attempt to recover from sequence number gaps.booleangetRequiresInitial()Returns a value of true or false indicating whether this Subscription is interested in initial values.intgetRetries()longgetSeqNum()shortgetServiceLevel()Get the service level for the specified Subscription.longgetServiceLevelOpt()Get the service level options for the specified subscription.java.lang.StringgetSource()com.wombat.mama.MamaSubscriptionTypegetSubscriptionType()Returns the underlyingMamaSubscriptionTypefor the specified Subscription.java.lang.StringgetSymbol()doublegetTimeout()com.wombat.mama.MamaTransportgetTransport()voidrequestRecap()Force a recap request to be sent for this subscription.voidsetAppDataType(com.wombat.mama.MamaMdDataType appDataType)Set the application-specific data type.voidsetClosure(java.lang.Object closure)Set the closure.voidsetPreInitialCacheSize(int cacheSize)Set the number of messages to cache for each symbol before the initial value arrives.voidsetQueue(com.wombat.mama.MamaQueue queue)Set the MAMA queue.voidsetRecoverGaps(boolean doesRecover)Whether a Subscription should attempt to recover from sequence number gaps.voidsetRequireInitial(boolean require)Set whether an initial value is required.voidsetRequiresInitial(boolean requiresInitial)Whether an initial value is required for the specified Subscription.voidsetRetries(int retries)Set the retries for this subscirption.voidsetServiceLevel(short serviceLevel, short serviceLevelOpt)Set the MAMA service level.voidsetSource(java.lang.String source)Set the data source name.voidsetSymbol(java.lang.String symbol)Set the symbol.voidsetTimeout(double timeout)Set the timeout (in seconds) for this subscription.voidsetTransport(com.wombat.mama.MamaTransport transport)Set the MAMA transport.voidsetType(com.wombat.mama.MamaSubscriptionType type)Set the subscrption type.
-
-
-
Method Detail
-
create
public void create(com.wombat.mama.MamaTransport transport, com.wombat.mama.MamaQueue queue, java.lang.String source, java.lang.String symbol, java.lang.Object closure)Create and activate a subscription. Any properties for the subscription should be set prior to calling this method.
-
setSource
public void setSource(java.lang.String source)
Set the data source name. Do this before calling activate().
-
setSymbol
public void setSymbol(java.lang.String symbol)
Set the symbol. Do this before calling activate().
-
setTransport
public void setTransport(com.wombat.mama.MamaTransport transport)
Set the MAMA transport. Do this before calling activate().
-
setQueue
public void setQueue(com.wombat.mama.MamaQueue queue)
Set the MAMA queue. Do this before calling activate().
-
setType
public void setType(com.wombat.mama.MamaSubscriptionType type)
Set the subscrption type. Do this before calling activate(). Default isMamaSubscriptionType.NORMAL
-
setServiceLevel
public void setServiceLevel(short serviceLevel, short serviceLevelOpt)Set the MAMA service level. Do this before calling activate(). Default value isMamaServiceLevel.REAL_TIMEand 0
-
setRequireInitial
public void setRequireInitial(boolean require)
Set whether an initial value is required. Do this before calling activate(). Default istrue
-
setTimeout
public void setTimeout(double timeout)
Set the timeout (in seconds) for this subscription. Do this before calling activate(). Default is 10 seconds.
-
setRetries
public void setRetries(int retries)
Set the retries for this subscirption. Do this before calling activate. Default is 3
-
setClosure
public void setClosure(java.lang.Object closure)
Set the closure. Do this before calling activate().
-
addMsgListener
public void addMsgListener(MamdaMsgListener listener)
Add a listener for regular messages.
-
getMsgListeners
public java.util.Vector getMsgListeners()
-
addStaleListener
public void addStaleListener(MamdaStaleListener listener)
Add a listener for changes in stale status.
-
addErrorListener
public void addErrorListener(MamdaErrorListener listener)
Add a listener for error events.
-
activate
public void activate()
Activate the subscription. Until this method is invoked, no updates will be received.
-
deactivate
public void deactivate()
Deactivate the subscription. No more updates will be received for this subscription (unless activate() is invoked again). This function must be called from the same thread dispatching on the associated event queue unless both the default queue and dispatch queue are not actively dispatching.
-
getSubscriptionType
public com.wombat.mama.MamaSubscriptionType getSubscriptionType()
Returns the underlyingMamaSubscriptionTypefor the specified Subscription.
-
getServiceLevel
public short getServiceLevel()
Get the service level for the specified Subscription.
-
getServiceLevelOpt
public long getServiceLevelOpt()
Get the service level options for the specified subscription.- Returns:
- serviceLevel
-
setRequiresInitial
public void setRequiresInitial(boolean requiresInitial)
Whether an initial value is required for the specified Subscription. This only applies to market data subscriptions and not to basic subscriptions. Default value of true indicating that initial values are required.- Parameters:
requiresInitial- [true|false] Whether to request an initial value or not.
-
getRequiresInitial
public boolean getRequiresInitial()
Returns a value of true or false indicating whether this Subscription is interested in initial values.- Returns:
- boolean
-
setAppDataType
public void setAppDataType(com.wombat.mama.MamaMdDataType appDataType)
Set the application-specific data type.- Parameters:
appDataType- The application-specific data type.
-
getAppDataType
public com.wombat.mama.MamaMdDataType getAppDataType()
Retrieve the application-specific data type.- Returns:
- appDataType .
-
setRecoverGaps
public void setRecoverGaps(boolean doesRecover)
Whether a Subscription should attempt to recover from sequence number gaps.- Parameters:
doesRecover- indicates not to recover. true The Subscription will attempt to recover via a recap request.
-
getRecoverGaps
public boolean getRecoverGaps()
Whether the specified subscription will attempt to recover from sequence number gaps.- Returns:
- boolean - false does not recoever true - does attempt to recover
-
setPreInitialCacheSize
public void setPreInitialCacheSize(int cacheSize)
Set the number of messages to cache for each symbol before the initial value arrives. This allows the Subscription to recover when the initial value arrives late (after a subsequent trade or quote already arrived). For group subscription, a separate cache is used for each group member. The default is 10.- Parameters:
cacheSize- The size of the cache.
-
getPreInitialCacheSize
public int getPreInitialCacheSize()
Return the initial value cache size- Returns:
- cacheSize
-
getMsgQualifier
public com.wombat.mama.MamaMsgQualifier getMsgQualifier()
Return the MamaMsgQualifier- Returns:
- MamaMsgQualifier
-
requestRecap
public void requestRecap()
Force a recap request to be sent for this subscription.
-
getRetries
public int getRetries()
-
getTimeout
public double getTimeout()
-
getSource
public java.lang.String getSource()
-
getSymbol
public java.lang.String getSymbol()
-
getQueue
public com.wombat.mama.MamaQueue getQueue()
-
getTransport
public com.wombat.mama.MamaTransport getTransport()
-
getClosure
public java.lang.Object getClosure()
Get the additional object passed as the closure to the create() method.
-
getSeqNum
public long getSeqNum()
-
getMamaSubscription
public com.wombat.mama.MamaSubscription getMamaSubscription()
-
-