Classes Files

Wombat::MamaQueue

MamaQueues allow applications to dispatch events in order with multiple threads.

Inherits from Wombat.MamaWrapper, IDisposable

Public Functions

  Name
  MamaQueue(MamaBridge bridgeImpl)
Create a queue
void setHighWatermark(int highWatermark)
Specify a high watermark for events on the queue. The behaviour for setting this value results in on the underlying middleware varies.
int getHighWatermark()
Get the value of the high water mark for the specified queue. A value of 0 will be returned if no high water mark was previously specified.
void setLowWatermark(int lowWatermark)
Set the low water mark for the queue. Only supported by Wombat TCP middleware.
void setQueueName(string queueName)
Sets the name of the queue to the given name (for stats, OS naming etc).
int getLowWatermark()
Get the value of the low water mark for the specified queue. A value of 1 will be returned if no low water mark was previously specified.
int getEventCount()
string getQueueBridgeName()
Get the name of the bridge associated with the queue - either “wmw”, “lbm”, or “tibrv”.
void setQueueMonitorCallbacks(MamaQueueMonitorCallback callback, object closure)
Specify a set of callbacks which may be invoked in response to certain conditions arising on the queue.
void setEnqueueCallback(MamaQueueEnqueueCallback callback)
Register the specified callback function to receive a callback each time an event is enqueued on the specified MamaQueue
void enqueueEvent(MamaQueueEventCallback callback, object closure)
This function will enqueue an event on the mama queue.
bool canDestroy()
Check to see if a queue can be destroyed. The queue cannot be destroyed if there are currently open event objects on it.
void destroy()
Destroy a queue. Note that the queue can only be destroyed if all of the objects created on it, (timers, subscriptions etc), have been destroyed.
void destroyWait()
Destroy a queue. Note that the queue can only be destroyed if all of the objects created on it, (timers, subscriptions etc), have been destroyed. This function will block until all of the objects have been destroyed and will then destroy the queue.
void destroyTimedWait(long timeout)
Destroy a queue. Note that the queue can only be destroyed if all of the objects created on it, (timers, subscriptions etc), have been destroyed. This function will block until all of the objects have been destroyed and will then destroy the queue.
void dispatch()
Dispatch messages from the queue. This call blocks and dispatches until stopDispatch() is called.
void dispatchEvent()
Dispatch a single event from the specified queue. If there is no event on the queue simply return and do nothing.
void stopDispatch()
Unblock the queue as soon as possible. This will cause mamaDispatchers to exit. Creating a new dispatcher will resume dispatching events.
void timedDispatch(long timeout)
Dispatch messages from the queue until timeout has elapsed. Some middleware implementations will always block until timeout (dispatching multiple times), whereas others will always unblock once the first event is dispatched or the timeout has elapsed - whichever comes first.

Protected Functions

  Name
virtual override MamaStatus.mamaStatus DestroyNativePeer()
This function is called by the base class whenever the MamaQueue is disposed, it will attempt to destroy the queue if this has not already been done. MamaWrapper.DestroyNativePeer

Additional inherited members

Public Functions inherited from Wombat.MamaWrapper

  Name
void Dispose()
Destroys the underlying peer object and unbinds the wrapper from it.
void setNativeHandle(IntPtr nHandle)
Sets the native handle of the native peer object. Should only be used by subclasses and in the same assembly.

Protected Functions inherited from Wombat.MamaWrapper

  Name
  MamaWrapper()
Constructs a new wrapper object but doesn’t create it. If the object is not explicitly disposed it will remain registered for finalization and will attempt the destroy the native peer object when finalized.
  MamaWrapper(IntPtr nativeHandle)
Constructs a managed wrapper from an existing native peer. The peer object will not be automatically finalized
virtual void Dispose(bool disposing, bool destroyNativeHandle =true)
The actual implementation of Dispose - called by both the Dispose method and the finalizer.
virtual void OnDispose()

Protected Attributes inherited from Wombat.MamaWrapper

  Name
IntPtr nativeHandle
the handle to the native peer object

Public Functions Documentation

function MamaQueue

MamaQueue(
    MamaBridge bridgeImpl
)

Create a queue

function setHighWatermark

void setHighWatermark(
    int highWatermark
)

Specify a high watermark for events on the queue. The behaviour for setting this value results in on the underlying middleware varies.

LBM: LBM uses an unbounded event queue. Setting this values allows users of the API to receive a callback if the value is exceeded. (MamaQueue.setQueueMonitorCallbacks for setting queue-related callbacks.) The default behaviour is for the queue to grow unbounded without notifications.

The high watermark for LBM can be set for all queues at once by setting the mama.lbm.eventqueuemonitor.queue_size_warning property for the API. Calls to this function will override the value specified in mama.properties at runtime. Callbacks can be disabled by setting this value to 0 - effectively disabling high watermark checking.

RV: This will set a queue limit policy of TIBRVQUEUE_DISCARD_FIRST whereby the oldest events in the queue are discarded first. The discard amount will be set with a value of 1. I.e. events will be dropped from the queue one at a time. The default behaviour is an unlimited queue which does not discard events.

function getHighWatermark

int getHighWatermark()

Get the value of the high water mark for the specified queue. A value of 0 will be returned if no high water mark was previously specified.

function setLowWatermark

void setLowWatermark(
    int lowWatermark
)

Set the low water mark for the queue. Only supported by Wombat TCP middleware.

The low watermark must be greater than 1 and less than highWaterMark otherwise this method returns MAMA_STATUS_INVALID_ARG. For this reason the high water mark must be set before invoking this method.

function setQueueName

void setQueueName(
    string queueName
)

Sets the name of the queue to the given name (for stats, OS naming etc).

function getLowWatermark

int getLowWatermark()

Get the value of the low water mark for the specified queue. A value of 1 will be returned if no low water mark was previously specified.

function getEventCount

int getEventCount()

function getQueueBridgeName

string getQueueBridgeName()

Get the name of the bridge associated with the queue - either “wmw”, “lbm”, or “tibrv”.

function setQueueMonitorCallbacks

void setQueueMonitorCallbacks(
    MamaQueueMonitorCallback callback,
    object closure
)

Specify a set of callbacks which may be invoked in response to certain conditions arising on the queue.

The behaviour here is middleware specific as not all will support all callbacks.

LBM: When the high watermark is exceeded the mamaQueueHighWatermarkExceededCb callback will invoked each time an event on the queue is dispatched until such time as the number of events on the queue falls below the high watermark.

RV: Not currently supported.

function setEnqueueCallback

void setEnqueueCallback(
    MamaQueueEnqueueCallback callback
)

Register the specified callback function to receive a callback each time an event is enqueued on the specified MamaQueue

function enqueueEvent

void enqueueEvent(
    MamaQueueEventCallback callback,
    object closure
)

This function will enqueue an event on the mama queue.

Parameters:

  • callback This callback will be invoked by the thread pumping the queue.
  • closure Utility object that will be passed back to the callback.

Exceptions:

  • ArgumentNullException Thrown if the callback object is null.

function canDestroy

bool canDestroy()

Check to see if a queue can be destroyed. The queue cannot be destroyed if there are currently open event objects on it.

Return: True if the queue can be destroyed.

function destroy

void destroy()

Destroy a queue. Note that the queue can only be destroyed if all of the objects created on it, (timers, subscriptions etc), have been destroyed.

Exceptions:

  • MamaException Thrown with a status code of MAMA_STATUS_QUEUE_OPEN_OBJECTS if there are still open objects against the queue.

function destroyWait

void destroyWait()

Destroy a queue. Note that the queue can only be destroyed if all of the objects created on it, (timers, subscriptions etc), have been destroyed. This function will block until all of the objects have been destroyed and will then destroy the queue.

function destroyTimedWait

void destroyTimedWait(
    long timeout
)

Destroy a queue. Note that the queue can only be destroyed if all of the objects created on it, (timers, subscriptions etc), have been destroyed. This function will block until all of the objects have been destroyed and will then destroy the queue.

Exceptions:

  • MamaException Thrown with a status code of MAMA_STATUS_TIMEOUT if the time period elapses before the queue can be shutdown.

function dispatch

void dispatch()

Dispatch messages from the queue. This call blocks and dispatches until stopDispatch() is called.

function dispatchEvent

void dispatchEvent()

Dispatch a single event from the specified queue. If there is no event on the queue simply return and do nothing.

function stopDispatch

void stopDispatch()

Unblock the queue as soon as possible. This will cause mamaDispatchers to exit. Creating a new dispatcher will resume dispatching events.

function timedDispatch

void timedDispatch(
    long timeout
)

Dispatch messages from the queue until timeout has elapsed. Some middleware implementations will always block until timeout (dispatching multiple times), whereas others will always unblock once the first event is dispatched or the timeout has elapsed - whichever comes first.

Protected Functions Documentation

function DestroyNativePeer

virtual override MamaStatus.mamaStatus DestroyNativePeer()

This function is called by the base class whenever the MamaQueue is disposed, it will attempt to destroy the queue if this has not already been done. MamaWrapper.DestroyNativePeer

Return: MAMA Status code

Reimplements: Wombat::MamaWrapper::DestroyNativePeer


Updated on 2023-03-31 at 15:29:32 +0100