C# Class Wombat.Mama

MAMA - Middleware Agnostic Messaging API
MAMA provides an abstraction layer over various messaging middleware platforms. In particular, MAMA adds market data semantics to messaging platforms that would otherwise be too limited for use as a market data distribution middleware. Features that MAMA adds to any messaging middleware are: Subscription management (initial values, throttling). Entitlements/permissioning. Data quality. MAMA currently supports the following middleware platforms: Wombat TCP Middleware 29West Latency Busters Messaging (see http://29west.com) Tibco TIB/RV versions 6 and 7 (see http://tibco.com)

Future supported platforms may include: Tibco SmartSockets (see http://tibco.com) Reuters SSL, SFC, TibMsg, etc.

A higher level market data API is also available: the Middleware Agnostic Market Data API (MAMDA). While MAMA provides a field-based abstraction to market data, MAMDA provides smart, specialized data types to deal with specific market data events, such as trades, quotes, order books, etc. MAMDA is particularly suitable for applications such as program trading and tick capture systems, where context is important. MAMA is more suited to applications that don't care about the meaning of fields, such as a simple, field-based market data display application.

Exibir arquivo Open project: OpenMAMA/OpenMAMA Class Usage Examples

Public Methods

Method Description
close ( ) : void

Close MAMA and free all associated resource. MAMA employs a reference count to track multiple calls to Mama.open() and Mama.close(). The count is incremented every time Mama.open() is called and decremented when Mama.close() is called. The resources are not actually released until the count reaches zero. This function is thread safe.

defaultLogFunction ( MamaLogLevel level, string text ) : void

This function will invoke the default log function.

disableLogging ( ) : void

Disable logging.

enableLogging ( MamaLogLevel level ) : void

Enable logging.

getDefaultEventQueue ( Wombat.MamaBridge bridgeImpl ) : Wombat.MamaQueue

getLogLevel ( ) : MamaLogLevel

Get the log level.

getProperty ( string name ) : string

Retrieve a specific property from the API. If the property has not been set, a null value will be returned.

getVersion ( Wombat.MamaBridge bridgeImpl ) : string

Return the version information for the library The version of Mama follows in parenthesis

loadBridge ( string middleware ) : Wombat.MamaBridge

Load the bridge specified by middleware string. If the bridge has already been loaded then the existing bridge instance will be returned.

loadBridge ( string middleware, string path ) : Wombat.MamaBridge

Load the bridge specified by middleware string using the path specified by the user. If the bridge has already been loaded then the existing bridge instance will be returned

loadPayloadBridge ( string payload ) : Wombat.MamaPayloadBridge

Load the payload brige specified by the payload string.

log ( MamaLogLevel level, string text ) : void

Add string to mama log at specified mama level.

logToFile ( string fileName, MamaLogLevel level ) : void

Enable logging, accepts a string representing the file location.

loggingToFile ( ) : bool

Get logging to file status

onNativeLogCallback ( int level, string message ) : void

This handler is called by the C layer whenever a log comes in, it will invoke the managed object.

open ( ) : void

Initialize MAMA. MAMA employs a reference count to track multiple calls to Mama.open() and Mama.close(). The count is incremented every time Mama.open() is called and decremented when Mama.close() is called. The resources are not actually released until the count reaches zero. If entitlements are enabled for the library, the available entitlement server names are read from the entitlement.servers property in the mama.properties file located in the %WOMBAT_PATH% directory. This function is thread safe.

openWithProperties ( string path, string filename ) : void

Initialize MAMA. Allows users of the API to override the default behavior of mama_open() where a file mama.properties is required to be located in the directory specified by %WOMBAT_PATH%. The properties file must have the same structure as a standard mama.properties file. If null is passed as the path the API will look for the properties file on the %WOMBAT_PATH%. If null is passed as the filename the API will look for the default filename of mama.properties

setAppendToLogFile ( bool append ) : void

Set append to prevent overwriting existing logfiles.

setDefaultQueueHighWatermark ( int highWatermark ) : void

Set the high watermark for the internal default MAMA queue. See mamaQueue_setHighWatermark() for details. Although the monitoring callbacks on the default queue cannot be specified for RV, setting of the high water mark is still supported.

setDefaultQueueLowWatermark ( int lowWatermark ) : void

Set the low watermark for the internal default MAMA queue. See mamaQueue_setLowWatermark() for details. Currently supported only on Wombat TCP middleware.

setLogCallback ( MamaLogFileCallback2 callback ) : void

Sets the log callback, this will be invoked every time a log is written in MAMA.

setLogFilePolicy ( MamaLogFilePolicy policy ) : void

Set logging policy.

setLogLevel ( MamaLogLevel level ) : void

Set the log level.

setLogSize ( ulong size ) : void

Set the log file max size.

setLogSizeCb ( MamaLogFileCallback callback ) : void

Set callback for log max size exceeded. Applies only to USER policy.

setNumLogFiles ( int numFiles ) : void

Set the max number of log files.

setProperty ( string name, string value ) : void

Set a specific property for the API. If the property being set has already been given a value from a properties file that value will be replaced. See the example mama.properties provided with the distribution for examples of property formatting. The properties set via this function should be formatted in the same manner as those specified in mama.properties. The strings passed to the function are copied.

start ( Wombat.MamaBridge bridgeImpl ) : void

Start processing messages on the internal queue. This starts Mama's internal throttle, refresh logic, and other internal Mama processes as well as dispatching messages from the internal queue.

Mama.start( ) blocks until an invocation of Mama.stop() occurs. MAMA employs a reference count to track multiple calls to Mama.start() and Mama.stop(). The count is incremented every time Mama.start() is called and decremented when Mama.stop() is called. The first Mama.start() call does not unblock until the count reaches zero. This function is thread safe.

startBackground ( Wombat.MamaBridge bridgeImpl, MamaStartBackgroundCallback callback ) : void

Start Mama in the background. This method invokes Mama.start() in a separate thread.

stop ( Wombat.MamaBridge bridgeImpl ) : void

Stop dispatching on the default event queue for the specified bridge. MAMA employs a reference count to track multiple calls to Mama.start() and Mama.stop(). The count is incremented every time Mama.start() is called and decremented when Mama.stop() is called. The first Mama.start() call does not unblock until the count reaches zero. This function is thread safe.

Private Methods

Method Description
getVersion ( IntPtr bridgeImpl ) : string

Return the version information for the library The version of Mama follows in parenthesis

initGetVersionWrapper ( ) : void
onNativeLogSizeExceeded ( ) : void

This event handler is called whenever the log size is exceeded.

Method Details

close() public static method

Close MAMA and free all associated resource. MAMA employs a reference count to track multiple calls to Mama.open() and Mama.close(). The count is incremented every time Mama.open() is called and decremented when Mama.close() is called. The resources are not actually released until the count reaches zero. This function is thread safe.
public static close ( ) : void
return void

defaultLogFunction() public static method

This function will invoke the default log function.
/// The logging text has not been supplied. /// /// The logging level is invalid. ///
public static defaultLogFunction ( MamaLogLevel level, string text ) : void
level MamaLogLevel /// The level to log at. ///
text string /// The log message. ///
return void

disableLogging() public static method

Disable logging.
public static disableLogging ( ) : void
return void

enableLogging() public static method

Enable logging.
/// The file name contains invalid characters. ///
public static enableLogging ( MamaLogLevel level ) : void
level MamaLogLevel /// The logging level allowed. ///
return void

getDefaultEventQueue() public static method

public static getDefaultEventQueue ( Wombat.MamaBridge bridgeImpl ) : Wombat.MamaQueue
bridgeImpl Wombat.MamaBridge
return Wombat.MamaQueue

getLogLevel() public static method

Get the log level.
public static getLogLevel ( ) : MamaLogLevel
return MamaLogLevel

getProperty() public static method

Retrieve a specific property from the API. If the property has not been set, a null value will be returned.
public static getProperty ( string name ) : string
name string
return string

getVersion() public static method

Return the version information for the library The version of Mama follows in parenthesis
public static getVersion ( Wombat.MamaBridge bridgeImpl ) : string
bridgeImpl Wombat.MamaBridge
return string

loadBridge() public static method

Load the bridge specified by middleware string. If the bridge has already been loaded then the existing bridge instance will be returned.
public static loadBridge ( string middleware ) : Wombat.MamaBridge
middleware string
return Wombat.MamaBridge

loadBridge() public static method

Load the bridge specified by middleware string using the path specified by the user. If the bridge has already been loaded then the existing bridge instance will be returned
public static loadBridge ( string middleware, string path ) : Wombat.MamaBridge
middleware string
path string
return Wombat.MamaBridge

loadPayloadBridge() public static method

Load the payload brige specified by the payload string.
public static loadPayloadBridge ( string payload ) : Wombat.MamaPayloadBridge
payload string
return Wombat.MamaPayloadBridge

log() public static method

Add string to mama log at specified mama level.
/// The logging level is invalid. ///
public static log ( MamaLogLevel level, string text ) : void
level MamaLogLevel /// The level to log at. ///
text string /// The log message. ///
return void

logToFile() public static method

Enable logging, accepts a string representing the file location.
/// The file name is null or blank. /// /// The file name contains invalid characters. ///
public static logToFile ( string fileName, MamaLogLevel level ) : void
fileName string /// The full path to the log file. ///
level MamaLogLevel /// The logging level allowed. ///
return void

loggingToFile() public static method

Get logging to file status
public static loggingToFile ( ) : bool
return bool

onNativeLogCallback() public static method

This handler is called by the C layer whenever a log comes in, it will invoke the managed object.
public static onNativeLogCallback ( int level, string message ) : void
level int /// The log level. ///
message string /// The log message. ///
return void

open() public static method

Initialize MAMA. MAMA employs a reference count to track multiple calls to Mama.open() and Mama.close(). The count is incremented every time Mama.open() is called and decremented when Mama.close() is called. The resources are not actually released until the count reaches zero. If entitlements are enabled for the library, the available entitlement server names are read from the entitlement.servers property in the mama.properties file located in the %WOMBAT_PATH% directory. This function is thread safe.
public static open ( ) : void
return void

openWithProperties() public static method

Initialize MAMA. Allows users of the API to override the default behavior of mama_open() where a file mama.properties is required to be located in the directory specified by %WOMBAT_PATH%. The properties file must have the same structure as a standard mama.properties file. If null is passed as the path the API will look for the properties file on the %WOMBAT_PATH%. If null is passed as the filename the API will look for the default filename of mama.properties
public static openWithProperties ( string path, string filename ) : void
path string /// Fully qualified path to the directory containing the properties /// file ///
filename string /// The name of the file containing MAMA properties. ///
return void

setAppendToLogFile() public static method

Set append to prevent overwriting existing logfiles.
public static setAppendToLogFile ( bool append ) : void
append bool
return void

setDefaultQueueHighWatermark() public static method

Set the high watermark for the internal default MAMA queue. See mamaQueue_setHighWatermark() for details. Although the monitoring callbacks on the default queue cannot be specified for RV, setting of the high water mark is still supported.
public static setDefaultQueueHighWatermark ( int highWatermark ) : void
highWatermark int
return void

setDefaultQueueLowWatermark() public static method

Set the low watermark for the internal default MAMA queue. See mamaQueue_setLowWatermark() for details. Currently supported only on Wombat TCP middleware.
public static setDefaultQueueLowWatermark ( int lowWatermark ) : void
lowWatermark int
return void

setLogCallback() public static method

Sets the log callback, this will be invoked every time a log is written in MAMA.
public static setLogCallback ( MamaLogFileCallback2 callback ) : void
callback MamaLogFileCallback2 /// The callback to invoke. ///
return void

setLogFilePolicy() public static method

Set logging policy.
public static setLogFilePolicy ( MamaLogFilePolicy policy ) : void
policy MamaLogFilePolicy
return void

setLogLevel() public static method

Set the log level.
/// The file name contains invalid characters. ///
public static setLogLevel ( MamaLogLevel level ) : void
level MamaLogLevel /// The logging level allowed. ///
return void

setLogSize() public static method

Set the log file max size.
/// Thrown if the size is 0. ///
public static setLogSize ( ulong size ) : void
size ulong
return void

setLogSizeCb() public static method

Set callback for log max size exceeded. Applies only to USER policy.
public static setLogSizeCb ( MamaLogFileCallback callback ) : void
callback MamaLogFileCallback /// The callback object to invoke whenever the log size is exceeded. ///
return void

setNumLogFiles() public static method

Set the max number of log files.
/// Thrown if the number of files is 0 or less. ///
public static setNumLogFiles ( int numFiles ) : void
numFiles int
return void

setProperty() public static method

Set a specific property for the API. If the property being set has already been given a value from a properties file that value will be replaced. See the example mama.properties provided with the distribution for examples of property formatting. The properties set via this function should be formatted in the same manner as those specified in mama.properties. The strings passed to the function are copied.
public static setProperty ( string name, string value ) : void
name string
value string
return void

start() public static method

Start processing messages on the internal queue. This starts Mama's internal throttle, refresh logic, and other internal Mama processes as well as dispatching messages from the internal queue.

Mama.start( ) blocks until an invocation of Mama.stop() occurs. MAMA employs a reference count to track multiple calls to Mama.start() and Mama.stop(). The count is incremented every time Mama.start() is called and decremented when Mama.stop() is called. The first Mama.start() call does not unblock until the count reaches zero. This function is thread safe.

public static start ( Wombat.MamaBridge bridgeImpl ) : void
bridgeImpl Wombat.MamaBridge /// The bridge specific structure. ///
return void

startBackground() public static method

Start Mama in the background. This method invokes Mama.start() in a separate thread.
public static startBackground ( Wombat.MamaBridge bridgeImpl, MamaStartBackgroundCallback callback ) : void
bridgeImpl Wombat.MamaBridge /// The bridge specific structure. ///
callback MamaStartBackgroundCallback /// The callback for asynchronous status. ///
return void

stop() public static method

Stop dispatching on the default event queue for the specified bridge. MAMA employs a reference count to track multiple calls to Mama.start() and Mama.stop(). The count is incremented every time Mama.start() is called and decremented when Mama.stop() is called. The first Mama.start() call does not unblock until the count reaches zero. This function is thread safe.
public static stop ( Wombat.MamaBridge bridgeImpl ) : void
bridgeImpl Wombat.MamaBridge /// The bridge specific structure. ///
return void