...
The C++ Broker M4 or later supports the following additional Queue constraints.
- Applying Queue Sizing Constraints
- Changing the Queue ordering Behaviors
- Setting additional behaviors
- Other Clients
Table of Contents |
---|
Applying Queue Sizing Constraints
...
A fully worked LVQ Example can be found here
Setting additional behaviors
...
Optimistic Consume allows the consumer to dequeue the message before the broker has acknowledged the producer. This is useful to reduce latency when doing duarble messaging, but has the following additional consideration.
In a failure it is possible that the consumer will receive duplicate messages. These can come from two sources.
- The producer might re-send a message the consumer receiver, because the broker had not acknowledged the producer yet
- The broker might not have persisted the consumers dequeue, resulting in a duplicate resend.
Example:
Code Block |
---|
#include "qpid/client/QueueOptions.h"
QueueOptions qo;
qo.setOptimisticConsume();
session.queueDeclare(arg::queue=queue, arg::arguments=qo);
|
...
Persist Last Node
This option is used in conjunction with clustering. It allows for a queue configured with this option to persist transient messages if the cluster fails down to the last node. If additional nodes in the cluster are restored it will stop persisting transient messages.
...
- if a cluster is started with only one active node, this mode will not be triggered. It is only triggered the first time the cluster fails down to 1 node.
- Messages that are in the Queue are flushed to the store optimistically. New messages received honor the Optimistic mode that has been configured on the queue.
- The queue MUST be configured durable
...
Code Block |
---|
#include "qpid/client/QueueOptions.h"
QueueOptions qo;
qo.clearPersistLastNode();
session.queueDeclare(arg::queue=queue, arg::durable=true, arg::arguments=qo);
|
Queue event generation
This option is used to determine whether enqueue/dequeue events representing changes made to queue state are generated. These events can then be processed by plugins such as that used for queue state replication.
Example:
Code Block |
---|
#include "qpid/client/QueueOptions.h"
QueueOptions options;
options.enableQueueEvents(1);
session.queueDeclare(arg::queue="my-queue", arg::arguments=options);
|
The boolean option indicates whether only enqueue events should be generated. The key set by this is 'qpid.queue_event_generation' and the value is and integer value of 1 (to replicate only enqueue events) or 2 (to replicate both enqueue and dequeue events).
Other Clients
Note that these options can be set from any client. QueueOptions just correctly formats the arguments passed to the QueueDeclare() method.