Send a Message Using Queue Sender

5-18 Programming JMS for Oracle WebLogic Server For more information about the MessageProducer class, see Section 2.4.5, MessageProducer and MessageConsumer or the javax.jms.MessageProducer Javadoc, at http:java.sun.comjavaee5docsapijavaxjmsMessageProducer. html .

5.3.3.1 Send a Message Using Queue Sender

You can send messages using the following QueueSender methods: public void send Message message throws JMSException public void send Message message, int deliveryMode, int priority, long timeToLive throws JMSException public void send Queue queue, Message message throws JMSException public void send Queue queue, Message message, int deliveryMode, int priority, long timeToLive throws JMSException You must specify a message. You may also specify the queue name for anonymous message producers, delivery mode DeliveryMode.PERSISTENT or DeliveryMode.NON_PERSISTENT, priority 0-9, and time-to-live in milliseconds. If not specified, the delivery mode, priority, and time-to-live attributes are set to one of the following: ■ Connection factory or destination override configuration attributes defined for the producer, as described Configure default delivery parameters in the Oracle WebLogic Server Administration Console Help. ■ Values specified using the message producers set methods, as described in Section 5.3.4, Setting Message Producer Attributes. Note: If multiple topic subscribers are defined for the same topic, each subscriber will receive its own local copy of a message. Once received, you can modify the header field values; however, the message properties and message body are read only. You can modify the message body by executing the corresponding message types clearbody method to clear the existing contents and enable write permission. Developing a Basic JMS Application 5-19 If you define the delivery mode as PERSISTENT, you should configure a backing store for the destination, as described in Configure persistent stores in the Oracle WebLogic Server Administration Console Help. If the queue sender is an anonymous producer that is, if when the queue was created, the name was set to null, then you must specify the queue name using one of the last two methods to indicate where to deliver messages. For more information about defining anonymous producers, see Section 5.2.5.1, Create QueueSenders and QueueReceivers. For example, the following code sends a persistent message with a priority of 4 and a time-to-live of one hour: QueueSender.sendmessage, DeliveryMode.PERSISTENT, 4, 3600000; For additional information about the QueueSender class methods, see the javax.jms.QueueSender Javadoc, at http:java.sun.comjavaee5docsapijavaxjmsQueueSender.html .

5.3.3.2 Send a Message Using TopicPublisher