ClassesClasses | | Operators

dequeue_messagedequeue_messageDequeueMessageDequeueMessage (Operator)

Name

dequeue_messagedequeue_messageDequeueMessageDequeueMessage — Receive one or more messages from the message queue.

Signature

dequeue_message( : : QueueHandle, GenParamName, GenParamValue : MessageHandle)

Herror dequeue_message(const Hlong QueueHandle, const char* GenParamName, const char* GenParamValue, Hlong* MessageHandle)

Herror T_dequeue_message(const Htuple QueueHandle, const Htuple GenParamName, const Htuple GenParamValue, Htuple* MessageHandle)

void DequeueMessage(const HTuple& QueueHandle, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* MessageHandle)

HMessageArray HMessageQueue::DequeueMessage(const HTuple& GenParamName, const HTuple& GenParamValue) const

HMessage HMessageQueue::DequeueMessage(const HString& GenParamName, const HTuple& GenParamValue) const

HMessage HMessageQueue::DequeueMessage(const char* GenParamName, const HTuple& GenParamValue) const

static void HOperatorSet.DequeueMessage(HTuple queueHandle, HTuple genParamName, HTuple genParamValue, out HTuple messageHandle)

HMessage[] HMessageQueue.DequeueMessage(HTuple genParamName, HTuple genParamValue)

HMessage HMessageQueue.DequeueMessage(string genParamName, HTuple genParamValue)

Description

dequeue_messagedequeue_messageDequeueMessageDequeueMessageDequeueMessage dequeues a message from the message queue denoted by the QueueHandleQueueHandleQueueHandleQueueHandlequeueHandle parameter. The message must have been enqueued by any thread using enqueue_messageenqueue_messageEnqueueMessageEnqueueMessageEnqueueMessage.

The messages are delivered in FIFO (first-in first-out) order, every message is delivered only once. If the queue is not empty, dequeue_messagedequeue_messageDequeueMessageDequeueMessageDequeueMessage immediately delivers the oldest message from the queue. This message is removed from the queue and a handle to the message is returned in the MessageHandleMessageHandleMessageHandleMessageHandlemessageHandle output parameter. The message data ownership is transferred (no copy) from the message queue to the newly created message handle.

If the queue is empty, dequeue_messagedequeue_messageDequeueMessageDequeueMessageDequeueMessage blocks until a message becomes available for delivery (being queued from another thread using enqueue_messageenqueue_messageEnqueueMessageEnqueueMessageEnqueueMessage).

The data stored in the message can be queried using get_message_tupleget_message_tupleGetMessageTupleGetMessageTupleGetMessageTuple, get_message_objget_message_objGetMessageObjGetMessageObjGetMessageObj, or get_message_paramget_message_paramGetMessageParamGetMessageParamGetMessageParam.

The message handles obtained through dequeue_messagedequeue_messageDequeueMessageDequeueMessageDequeueMessage can be further reused (modified and/or enqueued to another message queue). When the message is no more needed, all associated resources, in particular the tuple or object data stored in the message, should be released using clear_messageclear_messageClearMessageClearMessageClearMessage.

If multiple messages were enqueued using a single enqueue_messageenqueue_messageEnqueueMessageEnqueueMessageEnqueueMessage call, all those messages will be also retrieved together through a single dequeue_messagedequeue_messageDequeueMessageDequeueMessageDequeueMessage call, delivering multiple mesage handles via the MessageHandleMessageHandleMessageHandleMessageHandlemessageHandle tuple.

The queue access is internally fully synchronized, no external locking is required.

During application reconfiguration or cleanup, it might be necessary to wake threads waiting for messages in dequeue_messagedequeue_messageDequeueMessageDequeueMessageDequeueMessage. This can be achieved using the operator set_message_queue_paramset_message_queue_paramSetMessageQueueParamSetMessageQueueParamSetMessageQueueParam with the parameter 'abort_dequeuing'"abort_dequeuing""abort_dequeuing""abort_dequeuing""abort_dequeuing". In such case the currently blocked dequeue_messagedequeue_messageDequeueMessageDequeueMessageDequeueMessage calls return immediately with H_ERR_MQCNCL.

Finally, it is possible to adjust dequeue_messagedequeue_messageDequeueMessageDequeueMessageDequeueMessage behavior through generic parameters within GenParamNameGenParamNameGenParamNameGenParamNamegenParamName and GenParamValueGenParamValueGenParamValueGenParamValuegenParamValue. Currently, just a single generic parameter is supported:

'timeout'"timeout""timeout""timeout""timeout":

Timeout controlling how long the operator will block while waiting for a message if the queue is empty. When expired, the operator returns with H_ERR_TIMEOUT. The timeout can be specified as an integer or double value in seconds or as the string 'infinite'"infinite""infinite""infinite""infinite". When no timeout is specified, infinite timeout is used as default, meaning that the operator would block until a new message is enqueued or until the operation is aborted.

Execution Information

This operator returns a handle. Note that the state of an instance of this handle type may be changed by specific operators even though the handle is used as an input parameter by those operators.

Parameters

QueueHandleQueueHandleQueueHandleQueueHandlequeueHandle (input_control)  message_queue HMessageQueue, HTupleHTupleHtuple (integer) (IntPtr) (Hlong) (Hlong)

Message queue handle.

Number of elements: QueueHandle == 1

Restriction: QueueHandle != 0

GenParamNameGenParamNameGenParamNameGenParamNamegenParamName (input_control)  string(-array) HTupleHTupleHtuple (string) (string) (HString) (char*)

Names of optional generic parameters

Number of elements: GenParamName == GenParamValue

Default value: 'timeout' "timeout" "timeout" "timeout" "timeout"

List of values: 'timeout'"timeout""timeout""timeout""timeout"

GenParamValueGenParamValueGenParamValueGenParamValuegenParamValue (input_control)  tuple(-array) HTupleHTupleHtuple (string / integer / real) (string / int / long / double) (HString / Hlong / double) (char* / Hlong / double)

Values of optional generic parameters

Number of elements: GenParamName == GenParamValue

Default value: 'infinite' "infinite" "infinite" "infinite" "infinite"

List of values: 'infinite'"infinite""infinite""infinite""infinite"

MessageHandleMessageHandleMessageHandleMessageHandlemessageHandle (output_control)  message(-array) HMessage, HTupleHTupleHtuple (integer) (IntPtr) (Hlong) (Hlong)

Handle(s) of the dequeued message(s).

Number of elements: MessageHandle > 0

Assertion: MessageHandle != 0

Example (HDevelop)

	create_message_queue (Queue)
* ...
dequeue_message (Queue, [], [], Message)
get_message_obj (Image, Message, 'my_image')
clear_message (Message)

Result

If the operation succeeds, dequeue_messagedequeue_messageDequeueMessageDequeueMessageDequeueMessage returns 2 (H_MSG_TRUE). Otherwise an exception is raised. Possible error conditions include invalid parameters, message dequeue wait timeout (H_ERR_TIMEOUT) or message dequeue wait abortion (H_ERR_MQCNCL). Note that in some rare cases, when an error occurs when finishing the operator call (after the message has already been removed from the queue), the operator will attempt to requeue the message back to the front of the queue to not loose it. This might lead to a different message delivery order if another thread removed another message from the queue in the meanwhile.

Possible Successors

get_message_tupleget_message_tupleGetMessageTupleGetMessageTupleGetMessageTuple, get_message_objget_message_objGetMessageObjGetMessageObjGetMessageObj, get_message_paramget_message_paramGetMessageParamGetMessageParamGetMessageParam

See also

create_message_queuecreate_message_queueCreateMessageQueueCreateMessageQueueCreateMessageQueue, clear_message_queueclear_message_queueClearMessageQueueClearMessageQueueClearMessageQueue, enqueue_messageenqueue_messageEnqueueMessageEnqueueMessageEnqueueMessage, set_message_queue_paramset_message_queue_paramSetMessageQueueParamSetMessageQueueParamSetMessageQueueParam, get_message_queue_paramget_message_queue_paramGetMessageQueueParamGetMessageQueueParamGetMessageQueueParam, create_messagecreate_messageCreateMessageCreateMessageCreateMessage, clear_messageclear_messageClearMessageClearMessageClearMessage, set_message_tupleset_message_tupleSetMessageTupleSetMessageTupleSetMessageTuple, get_message_tupleget_message_tupleGetMessageTupleGetMessageTupleGetMessageTuple, set_message_objset_message_objSetMessageObjSetMessageObjSetMessageObj, get_message_objget_message_objGetMessageObjGetMessageObjGetMessageObj

Module

Foundation


ClassesClasses | | Operators