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
You can send messages using the following TopicPublisher methods: public void publish
Message message throws JMSException
public void publish Message message,
int deliveryMode, int priority,
long timeToLive throws JMSException
public void publish Topic topic,
Message message throws JMSException
Notes: WebLogic JMS also provides the following proprietary
attributes, as described in Section 5.3.4, Setting Message Producer
Attributes :
■
TimeToDeliver that is, birth time, which represents the delay before a sent message is made visible on its target destination.
■
RedeliveryLimit, which determines the number of times a message is redelivered after a recover or rollback.
■
SendTimeout, which is the maximum time the producer will wait for space when sending a message.
Note: If no backing store is configured, then the delivery mode is
changed to NON_PERSISTENT and messages are not written to the persistent store.
5-20 Programming JMS for Oracle WebLogic Server
public void publish Topic topic,
Message message, int deliveryMode,
int priority, long timeToLive
throws JMSException
You must provide a message. You may also specify the topic name, 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.
If you define the delivery mode as PERSISTENT, you should configure a backing store, as described in Configure custom persistent stores in the Oracle WebLogic
Server Administration Console Help.
If the topic publisher is an anonymous producer that is, if when the topic was created, the name was set to null, then you must specify the topic name using either of the
last two methods to indicate where to deliver messages. For more information about defining anonymous producers, see
Section 5.2.5.2, Create TopicPublishers and TopicSubscribers.
For example, the following code sends a persistent message with a priority of 4 and a time-to-live of one hour:
TopicPublisher.publishmessage, DeliveryMode.PERSISTENT, 4,3600000;
For more information about the TopicPublisher class methods, see the javax.jms.TopicPublisher Javadoc, at
http:java.sun.comjavaee5docsapijavaxjmsTopicPublisher.h tml
.
Notes: WebLogic JMS also provides the following proprietary
attributes, as described in Section 5.3.4, Setting Message Producer
Attributes :
■
TimeToDeliver that is, birth time, which represents the delay before a sent message is made visible on its target destination.
■
RedeliveryLimit, which determines the number of times a message is redelivered after a recover or rollback.
■
SendTimeout, which is the maximum time the producer will wait for space when sending a message.
Note: If no backing store is configured, then the delivery mode is
changed to NON_PERSISTENT and no messages are stored.
Developing a Basic JMS Application 5-21
5.3.4 Setting Message Producer Attributes