You can specify a number of the reply message's QoS settings including:
the reply message's priority
the reply message's persistence
the reply message's lifespan
These properties are stored in the JMS message header. By default, the JMS broker automatically populates their values. You can, however, configure an endpoint to override the broker's default.
JMS uses a priority system to determine the relative importance of delivering a message. Messages with higher priority are delivered before messages with a lower priority.
You configure the priority of the reply message messages by setting the consumer's replyPriority
attribute. The value is used to set the reply message's JMSPriority property.
JMS supports priority values between 0 and 9. The lowest priority is 0 and the highest priority is 9. The default priority for a message is 4.
JMS uses a message's delivery mode to determine its persistence in the system. You can set the delivery mode for the reply messages sent by an endpoint by setting the endpoint's replyDeliveryMode
attribute. The value you provide for the replyDeliveryMode
attribute is used to set the reply message's JMSDeliveryMode property.
JMS implementations support two delivery modes: persistent and non-persistent.
Persistent messages can survive a shutdown of the JMS broker. This is the default setting for JMS messages. You can specify persistence by setting the endpoint's deliveryMode
attribute to 2
. This setting corresponds to DeliveryMode.PERSISTENT
.
Non-persistent messages are lost if the JMS broker is shutdown before they are delivered. You can specify non-persistence by setting the endpoint's deliveryMode
attribute to 1
. This setting corresponds to DeliveryMode.NON_PERSISTENT
.
You can control how long reply messages live before the JMS broker reap them by setting the endpoint's replyTimeToLive
attribute. The value is the number of milliseconds you want the message to be available from the time it is sent.
The value of the replyTimeToLive
attribute is used to compute the value for the reply message's JMSExpirary property. The value is computed by adding the specified number of milliseconds to the time the message is created.
The default behavior is to allow messages to persist forever.
By default, the consumer ignores these settings and allows the JMS provider to insert its own default values for the reply message's QoS settings. To force your settings to be used, you need to set the endpoint's replyExplicitQosEnabled
to true
. Doing so instructs the consumer to always use the values provided in the configuration.
Example 3.12 shows the configuration for a consumer whose reply messages are set to have low priority and to be non-persistent.
Example 3.12. Consumer with Reply QoS Properties
<beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
... >
...
<jms:jca-consumer service="my:widgetService"
endpoint="jbiWidget"
connectionFactory="#connectionFactory"
destinationName="widgetQueue"
resourceAdapter="#ra"
activationSpec="#as"
replyExplicitQosEnabled="true"
replyDeliveryMode="1"
replyPriority="0" />
...
</beans>