IBM Support

Difference between message.setJMSDeliveryMode and producer.setDeliveryMode (JMS)

Question & Answer


Question

You want to know the difference between the WebSphere MQ JMS methods: message.setJMSDeliveryMode and producer.setDeliveryMode

Answer

a) By default, the delivery mode from a JMS Producer is to set the attribute PERSISTENT for messages.

b) If you want to specify Non-Persistent messages from a JMS Producer, you will need to use "setDeliveryMode" as follows:



import javax.jms.DeliveryMode;
...
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);

c) The JMS message.setJMSDeliveryMode is ONLY applicable when receiving messages.
This method is IGNORED when sending messages.

+++ References

com.ibm.mq.jms Class MQMessageProducer
    setDeliveryMode
      Sets the producer's default delivery mode.
      Parameters:
      deliveryMode - the message delivery mode for this message producer. Possible values are:
      DeliveryMode.NON_PERSISTENT
      DeliveryMode.PERSISTENT, the default
    See Also:
    getDeliveryMode(), Message.DEFAULT_DELIVERY_MODE


javax.jms Interface Message
    DEFAULT_DELIVERY_MODE
    public static final int DEFAULT_DELIVERY_MODE
    The message producer's default delivery mode is PERSISTENT.

com.ibm.jms Class JMSTextMessage
    Sets the delivery mode for this message.
    Any value set using this method is ignored when the message is sent, but this method can be used to change the value in a received message.
    To alter the delivery mode when a message is sent, use the setDeliveryMode() method on the QueueSender or TopicPublisher (this method is inherited from MessageProducer).
    Specified by:
    setJMSDeliveryMode in interface Message
    Parameters:
    deliveryMode - the delivery mode for this message

[{"Product":{"code":"SSFKSJ","label":"WebSphere MQ"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Java","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"9.0;8.0;7.5;7.1;7.0;6.0","Edition":"","Line of Business":{"code":"LOB36","label":"IBM Automation"}}]

Document Information

Modified date:
15 June 2018

UID

swg21584622