Specifying the Message Quality of Service
It's possible to specify the Quality of Service (QoS) level for a message, which determines if it is published as Persistent (Guaranteed), Non-Persistent, or Direct. The following sections describe how to configure each option:
Publishing Persistent Messages
Set
Send-Settle-Mode
in the attach frame withrole=sender
from the client to eitherunsettled
(0) ormixed
(2).- the
Durable
field in the message header totrue
.
Example Code Snippets
- with Qpid JMS, this is the default QoS. To explicitly specify it, format the url as
"amqp://" + host + ":" + port + "?jms.presettlePolicy.presettleProducers=false"
and specify the delivery mode in the send
producer.send(txMessage,DeliveryMode.PERSISTENT, 0, txLongData);
var policy = amqp.Policy.merge({
attach: { sndSettleMode: 0},
header: {'durable' : encoder(['boolean', true])}
});
var client = new AMQPClient(policy);
...
client.connect(uri)
.then(function() {
return Promise.all([
client.createSender('', policy),
]);
})
.spread(function(sender) {
var promises = [];
promises.push(sender.send('message', policy));
...
});
message = Message(durable=True, body='message')
self.sender.send(message)
sender.snd_settle_mode = sender.SND_UNSETTLED
message = Message(durable=True, body='message')
Publishing Non-Persistent Messages
Set
Send-Settle-Mode
in the attach frame withrole=sender
from the client to eitherunsettled
(0) ormixed
(2).- the
Durable
field in the message header tofalse
.
Example Code Snippets
- with Qpid JMS format the url as
"amqp://" + host + ":" + port + "?jms.presettlePolicy.presettleProducers=false"
and specify the delivery mode in the send:
producer.send(txMessage,DeliveryMode.NON_PERSISTENT,…
var policy = amqp.Policy.merge({
attach: { sndSettleMode: 0},
header: {'durable' : encoder(['boolean', false])}
});
var client = new AMQPClient(policy);
...
client.connect(uri)
.then(function() {
return Promise.all([
client.createSender('', policy),
]);
})
.spread(function(sender) {
var promises = [];
promises.push(sender.send('message', policy));
...
});
message = Message(durable=False, body='message')
self.sender.send(message)
sender.snd_settle_mode = sender.SND_UNSETTLED
message = Message(durable=False, body='message')
Publishing Direct Messages
Set
Send-Settle-Mode
in the attach frame withrole=sender
from the client tosettled
(1).- the
Settled
field in the message header totrue
.
Most clients automatically set the Settled
field in the message header consistent with the specified Send-Settle-Mode
.
Example Code Snippets
- with Qpid JMS, format the url as
"amqp://" + host + ":" + port + "?jms.presettlePolicy.presettleProducers=true”
var policy = amqp.Policy.merge({
attach: { sndSettleMode: 1},
header: {'durable' : encoder(['boolean', false])}
});
var client = new AMQPClient(policy);
...
client.connect(uri)
.then(function() {
return Promise.all([
client.createSender('', policy),
]);
})
.spread(function(sender) {
var promises = [];
promises.push(sender.send('message', policy));
...
});
self.sender = event.container.create_sender(self.url, options=AtMostOnce())
sender.snd_settle_mode = sender.SND_SETTLED