Class ActiveMQMessageProducer
- All Implemented Interfaces:
jakarta.jms.MessageProducer,AutoCloseable,Closeable,Disposable,StatsCapable
- Direct Known Subclasses:
ActiveMQQueueSender,ActiveMQTopicPublisher
MessageProducer object to send messages to a
destination. A MessageProducer object is created by passing a
Destination object to a message-producer creation method
supplied by a session.
MessageProducer is the parent interface for all message
producers.
A client also has the option of creating a message producer without supplying
a destination. In this case, a destination must be provided with every send
operation. A typical use for this kind of message producer is to send replies
to requests using the request's JMSReplyTo destination.
A client can specify a default delivery mode, priority, and time to live for messages sent by a message producer. It can also specify the delivery mode, priority, and time to live for an individual message.
A client can specify a time-to-live value in milliseconds for each message it sends. This value defines a message expiration time that is the sum of the message's time-to-live and the GMT when it is sent (for transacted sends, this is the time the client sends the message, not the time the transaction is committed).
A JMS provider should do its best to expire messages accurately; however, the JMS API does not define the accuracy provided.
- See Also:
-
TopicPublisherQueueSenderSession.createProducer(jakarta.jms.Destination)
-
Field Summary
FieldsFields inherited from class org.apache.activemq.ActiveMQMessageProducerSupport
defaultDeliveryMode, defaultPriority, defaultTimeToLive, disableMessageID, disableMessageTimestamp, JMS_PROPERTY_NAMES_DISALLOWED, sendTimeout, session -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedActiveMQMessageProducer(ActiveMQSession session, ProducerId producerId, ActiveMQDestination destination, int sendTimeout) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCheck if the instance of this producer has been closed.voidclose()Closes the message producer.voiddispose()jakarta.jms.DestinationGets the destination associated with thisMessageProducer.protected longprotected ProducerInfoprotected longgetStats()voidvoidsend(jakarta.jms.Destination destination, jakarta.jms.Message message, int deliveryMode, int priority, long timeToLive) Sends a message to a destination for an unidentified message producer, specifying delivery mode, priority and time to live.voidsend(jakarta.jms.Destination destination, jakarta.jms.Message message, int deliveryMode, int priority, long timeToLive, boolean disableMessageID, boolean disableMessageTimestamp, AsyncCallback onComplete) voidsend(jakarta.jms.Destination destination, jakarta.jms.Message message, int deliveryMode, int priority, long timeToLive, jakarta.jms.CompletionListener completionListener) voidsend(jakarta.jms.Destination destination, jakarta.jms.Message message, int deliveryMode, int priority, long timeToLive, AsyncCallback onComplete) voidsend(jakarta.jms.Destination destination, jakarta.jms.Message message, jakarta.jms.CompletionListener completionListener) voidsend(jakarta.jms.Destination destination, jakarta.jms.Message message, AsyncCallback onComplete) voidsend(jakarta.jms.Message message, int deliveryMode, int priority, long timeToLive, jakarta.jms.CompletionListener completionListener) voidsend(jakarta.jms.Message message, int deliveryMode, int priority, long timeToLive, AsyncCallback onComplete) voidsend(jakarta.jms.Message message, jakarta.jms.CompletionListener completionListener) voidsend(jakarta.jms.Message message, AsyncCallback onComplete) protected voidsetMessageSequence(AtomicLong messageSequence) protected voidsetProducerInfo(ProducerInfo info) voidsetTransformer(MessageTransformer transformer) Sets the transformer used to transform messages before they are sent on to the JMS bustoString()Methods inherited from class org.apache.activemq.ActiveMQMessageProducerSupport
getDeliveryDelay, getDeliveryMode, getDisableMessageID, getDisableMessageTimestamp, getPriority, getSendTimeout, getTimeToLive, send, send, send, setDeliveryDelay, setDeliveryMode, setDisableMessageID, setDisableMessageTimestamp, setPriority, setSendTimeout, setTimeToLive, validateValidPropertyName, validateValidPropertyValue
-
Field Details
-
info
-
closed
protected boolean closed
-
-
Constructor Details
-
ActiveMQMessageProducer
protected ActiveMQMessageProducer(ActiveMQSession session, ProducerId producerId, ActiveMQDestination destination, int sendTimeout) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
-
Method Details
-
getStats
- Specified by:
getStatsin interfaceStatsCapable- Returns:
- the Stats for this object
-
getProducerStats
-
getDestination
public jakarta.jms.Destination getDestination() throws jakarta.jms.JMSExceptionGets the destination associated with thisMessageProducer.- Specified by:
getDestinationin interfacejakarta.jms.MessageProducer- Returns:
- this producer's
Destination/ - Throws:
jakarta.jms.JMSException- if the JMS provider fails to close the producer due to some internal error.- Since:
- 1.1
-
close
public void close() throws jakarta.jms.JMSExceptionCloses the message producer.Since a provider may allocate some resources on behalf of a
MessageProduceroutside the Java virtual machine, clients should close them when they are not needed. Relying on garbage collection to eventually reclaim these resources may not be timely enough.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfacejakarta.jms.MessageProducer- Throws:
jakarta.jms.JMSException- if the JMS provider fails to close the producer due to some internal error.
-
dispose
public void dispose()- Specified by:
disposein interfaceDisposable
-
checkClosed
protected void checkClosed() throws jakarta.jms.IllegalStateExceptionCheck if the instance of this producer has been closed.- Specified by:
checkClosedin classActiveMQMessageProducerSupport- Throws:
jakarta.jms.IllegalStateException
-
send
public void send(jakarta.jms.Destination destination, jakarta.jms.Message message, int deliveryMode, int priority, long timeToLive) throws jakarta.jms.JMSException Sends a message to a destination for an unidentified message producer, specifying delivery mode, priority and time to live.Typically, a message producer is assigned a destination at creation time; however, the JMS API also supports unidentified message producers, which require that the destination be supplied every time a message is sent.
- Specified by:
sendin interfacejakarta.jms.MessageProducer- Parameters:
destination- the destination to send this message tomessage- the message to senddeliveryMode- the delivery mode to usepriority- the priority for this messagetimeToLive- the message's lifetime (in milliseconds)- Throws:
jakarta.jms.JMSException- if the JMS provider fails to send the message due to some internal error.UnsupportedOperationException- if an invalid destination is specified.jakarta.jms.InvalidDestinationException- if a client uses this method with an invalid destination.- Since:
- 1.1
- See Also:
-
Session.createProducer(jakarta.jms.Destination)
-
send
public void send(jakarta.jms.Message message, jakarta.jms.CompletionListener completionListener) throws jakarta.jms.JMSException - Specified by:
sendin interfacejakarta.jms.MessageProducer- Parameters:
message- the message to sendCompletionListener- to callback- Throws:
jakarta.jms.JMSException- if the JMS provider fails to send the message due to some internal error.UnsupportedOperationException- if an invalid destination is specified.jakarta.jms.InvalidDestinationException- if a client uses this method with an invalid destination.- Since:
- 2.0
- See Also:
-
Session.createProducer(jakarta.jms.Destination)
-
send
public void send(jakarta.jms.Message message, int deliveryMode, int priority, long timeToLive, jakarta.jms.CompletionListener completionListener) throws jakarta.jms.JMSException - Specified by:
sendin interfacejakarta.jms.MessageProducer- Throws:
jakarta.jms.JMSException
-
send
public void send(jakarta.jms.Destination destination, jakarta.jms.Message message, jakarta.jms.CompletionListener completionListener) throws jakarta.jms.JMSException - Specified by:
sendin interfacejakarta.jms.MessageProducer- Throws:
jakarta.jms.JMSException
-
send
public void send(jakarta.jms.Destination destination, jakarta.jms.Message message, int deliveryMode, int priority, long timeToLive, jakarta.jms.CompletionListener completionListener) throws jakarta.jms.JMSException - Specified by:
sendin interfacejakarta.jms.MessageProducer- Throws:
jakarta.jms.JMSException
-
send
public void send(jakarta.jms.Message message, AsyncCallback onComplete) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
send
public void send(jakarta.jms.Destination destination, jakarta.jms.Message message, AsyncCallback onComplete) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
send
public void send(jakarta.jms.Message message, int deliveryMode, int priority, long timeToLive, AsyncCallback onComplete) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
send
public void send(jakarta.jms.Destination destination, jakarta.jms.Message message, int deliveryMode, int priority, long timeToLive, AsyncCallback onComplete) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
send
public void send(jakarta.jms.Destination destination, jakarta.jms.Message message, int deliveryMode, int priority, long timeToLive, boolean disableMessageID, boolean disableMessageTimestamp, AsyncCallback onComplete) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
getTransformer
-
setTransformer
Sets the transformer used to transform messages before they are sent on to the JMS bus -
getStartTime
protected long getStartTime()- Returns:
- the time in milli second when this object was created.
-
getMessageSequence
protected long getMessageSequence()- Returns:
- Returns the messageSequence.
-
setMessageSequence
- Parameters:
messageSequence- The messageSequence to set.
-
getProducerInfo
- Returns:
- Returns the info.
-
setProducerInfo
- Parameters:
info- The info to set
-
toString
-
onProducerAck
-