public class ActiveMQMessageProducer extends ActiveMQMessageProducerSupport implements StatsCapable, Disposable
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.
Modifier and Type | Field and Description |
---|---|
protected boolean |
closed |
protected ProducerInfo |
info |
defaultDeliveryMode, defaultPriority, defaultTimeToLive, disableMessageID, disableMessageTimestamp, sendTimeout, session
Modifier | Constructor and Description |
---|---|
protected |
ActiveMQMessageProducer(ActiveMQSession session,
ProducerId producerId,
ActiveMQDestination destination,
int sendTimeout) |
Modifier and Type | Method and Description |
---|---|
protected void |
checkClosed()
Check if the instance of this producer has been closed.
|
void |
close()
Closes the message producer.
|
void |
dispose() |
Destination |
getDestination()
Gets the destination associated with this
MessageProducer . |
protected long |
getMessageSequence() |
protected ProducerInfo |
getProducerInfo() |
JMSProducerStatsImpl |
getProducerStats() |
protected long |
getStartTime() |
StatsImpl |
getStats() |
MessageTransformer |
getTransformer() |
void |
onProducerAck(ProducerAck pa) |
void |
send(Destination destination,
Message message,
AsyncCallback onComplete) |
void |
send(Destination destination,
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.
|
void |
send(Destination destination,
Message message,
int deliveryMode,
int priority,
long timeToLive,
AsyncCallback onComplete) |
void |
send(Message message,
AsyncCallback onComplete) |
void |
send(Message message,
int deliveryMode,
int priority,
long timeToLive,
AsyncCallback onComplete) |
protected void |
setMessageSequence(AtomicLong messageSequence) |
protected void |
setProducerInfo(ProducerInfo info) |
void |
setTransformer(MessageTransformer transformer)
Sets the transformer used to transform messages before they are sent on
to the JMS bus
|
String |
toString() |
getDeliveryMode, getDisableMessageID, getDisableMessageTimestamp, getPriority, getSendTimeout, getTimeToLive, send, send, send, setDeliveryMode, setDisableMessageID, setDisableMessageTimestamp, setPriority, setSendTimeout, setTimeToLive
protected ProducerInfo info
protected boolean closed
protected ActiveMQMessageProducer(ActiveMQSession session, ProducerId producerId, ActiveMQDestination destination, int sendTimeout) throws JMSException
JMSException
public StatsImpl getStats()
getStats
in interface StatsCapable
public JMSProducerStatsImpl getProducerStats()
public Destination getDestination() throws JMSException
MessageProducer
.getDestination
in interface MessageProducer
Destination/
JMSException
- if the JMS provider fails to close the producer due to
some internal error.public void close() throws JMSException
Since a provider may allocate some resources on behalf of a
MessageProducer
outside 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.
close
in interface MessageProducer
close
in interface Closeable
JMSException
- if the JMS provider fails to close the producer due
to some internal error.public void dispose()
dispose
in interface Disposable
protected void checkClosed() throws IllegalStateException
checkClosed
in class ActiveMQMessageProducerSupport
IllegalStateException
public void send(Destination destination, Message message, int deliveryMode, int priority, long timeToLive) throws JMSException
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.
send
in interface MessageProducer
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)JMSException
- if the JMS provider fails to send the message due to
some internal error.UnsupportedOperationException
- if an invalid destination is
specified.InvalidDestinationException
- if a client uses this method with an
invalid destination.Session.createProducer(javax.jms.Destination)
public void send(Message message, AsyncCallback onComplete) throws JMSException
JMSException
public void send(Destination destination, Message message, AsyncCallback onComplete) throws JMSException
JMSException
public void send(Message message, int deliveryMode, int priority, long timeToLive, AsyncCallback onComplete) throws JMSException
JMSException
public void send(Destination destination, Message message, int deliveryMode, int priority, long timeToLive, AsyncCallback onComplete) throws JMSException
JMSException
public MessageTransformer getTransformer()
public void setTransformer(MessageTransformer transformer)
protected long getStartTime()
protected long getMessageSequence()
protected void setMessageSequence(AtomicLong messageSequence)
messageSequence
- The messageSequence to set.protected ProducerInfo getProducerInfo()
protected void setProducerInfo(ProducerInfo info)
info
- The info to setpublic void onProducerAck(ProducerAck pa)
Copyright © 2005–2016 The Apache Software Foundation. All rights reserved.