Package jakarta.jms

Interface JMSProducer


public interface JMSProducer
A JMSProducer is a simple object used to send messages on behalf of a JMSContext. An instance of JMSProducer is created by calling the createProducer method on a JMSContext. It provides various send methods to send a message to a specified destination. It also provides methods to allow message send options, message properties and message headers to be specified prior to sending a message or set of messages.

Message send options may be specified using one or more of the following methods: setDeliveryMode, setPriority, setTimeToLive, setDeliveryDelay, setDisableMessageTimestamp, setDisableMessageID and setAsync.

Message properties may be may be specified using one or more of nine setProperty methods. Any message properties set using these methods will override any message properties that have been set directly on the message.

Message headers may be specified using one or more of the following methods: setJMSCorrelationID, setJMSCorrelationIDAsBytes, setJMSType or setJMSReplyTo. Any message headers set using these methods will override any message headers that have been set directly on the message.

All the above methods return the JMSProducer to allow method calls to be chained together, allowing a fluid programming style. For example:

context.createProducer().setDeliveryMode(DeliveryMode.NON_PERSISTENT).setTimeToLive(1000).send(destination, message);

Instances of JMSProducer are intended to be lightweight objects which can be created freely and which do not consume significant resources. This interface therefore does not provide a close method.

Since:
JMS 2.0
Version:
Jakarta Messaging 2.0