|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.activemq.ActiveMQMessageProducer
A client uses a 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.
TopicPublisher
,
QueueSender
,
Session.createProducer(javax.jms.Destination)
Field Summary | |
protected boolean |
closed
|
protected ActiveMQDestination |
defaultDestination
|
protected String |
producerId
|
protected ActiveMQSession |
session
|
Constructor Summary | |
protected |
ActiveMQMessageProducer(ActiveMQSession theSession,
ActiveMQDestination destination)
|
Method Summary | |
protected void |
checkClosed()
|
void |
close()
Closes the message producer. |
int |
getDeliveryMode()
Gets the producer's default delivery mode. |
Destination |
getDestination()
Gets the destination associated with this MessageProducer . |
boolean |
getDisableMessageID()
Gets an indication of whether message IDs are disabled. |
boolean |
getDisableMessageTimestamp()
Gets an indication of whether message timestamps are disabled. |
protected IdGenerator |
getIdGenerator()
|
int |
getPriority()
Gets the producer's default priority. |
protected String |
getProducerId()
|
JMSProducerStatsImpl |
getProducerStats()
|
protected long |
getStartTime()
|
Stats |
getStats()
|
long |
getTimeToLive()
Gets the default length of time in milliseconds from its dispatch time that a produced message should be retained by the message system. |
boolean |
isResuseMessageId()
|
void |
send(Destination destination,
Message message)
Sends a message to a destination for an unidentified message producer. |
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(Message message)
Sends a message using the MessageProducer 's default
delivery mode, priority, and time to live. |
void |
send(Message message,
int deliveryMode,
int priority,
long timeToLive)
Sends a message to the destination, specifying delivery mode, priority, and time to live. |
void |
setDeliveryMode(int newDeliveryMode)
Sets the producer's default delivery mode. |
void |
setDisableMessageID(boolean value)
Sets whether message IDs are disabled. |
void |
setDisableMessageTimestamp(boolean value)
Sets whether message timestamps are disabled. |
void |
setPriority(int newDefaultPriority)
Sets the producer's default priority. |
protected void |
setProducerId(String producerId)
|
void |
setReuseMessageId(boolean reuseMessageId)
|
void |
setTimeToLive(long timeToLive)
Sets the default length of time in milliseconds from its dispatch time that a produced message should be retained by the message system. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected ActiveMQSession session
protected String producerId
protected boolean closed
protected ActiveMQDestination defaultDestination
Constructor Detail |
protected ActiveMQMessageProducer(ActiveMQSession theSession, ActiveMQDestination destination) throws JMSException
Method Detail |
public Stats getStats()
getStats
in interface StatsCapable
public JMSProducerStatsImpl getProducerStats()
public void setDisableMessageID(boolean value) throws JMSException
Since message IDs take some effort to create and increase a message's
size, some JMS providers may be able to optimize message overhead if
they are given a hint that the message ID is not used by an application.
By calling the setDisableMessageID
method on this message
producer, a JMS client enables this potential optimization for all
messages sent by this message producer. If the JMS provider accepts this
hint, these messages must have the message ID set to null; if the
provider ignores the hint, the message ID must be set to its normal
unique value.
Message IDs are enabled by default.
setDisableMessageID
in interface MessageProducer
value
- indicates if message IDs are disabled
JMSException
- if the JMS provider fails to close the producer due to
some internal error.public boolean getDisableMessageID() throws JMSException
getDisableMessageID
in interface MessageProducer
JMSException
- if the JMS provider fails to determine if message IDs are
disabled due to some internal error.public void setDisableMessageTimestamp(boolean value) throws JMSException
Since timestamps take some effort to create and increase a message's
size, some JMS providers may be able to optimize message overhead if
they are given a hint that the timestamp is not used by an application.
By calling the setDisableMessageTimestamp
method on this
message producer, a JMS client enables this potential optimization for
all messages sent by this message producer. If the JMS provider accepts
this hint, these messages must have the timestamp set to zero; if the
provider ignores the hint, the timestamp must be set to its normal
value.
Message timestamps are enabled by default.
setDisableMessageTimestamp
in interface MessageProducer
value
- indicates if message timestamps are disabled
JMSException
- if the JMS provider fails to close the producer due to
some internal error.public boolean getDisableMessageTimestamp() throws JMSException
getDisableMessageTimestamp
in interface MessageProducer
JMSException
- if the JMS provider fails to close the producer due to
some internal error.public void setDeliveryMode(int newDeliveryMode) throws JMSException
Delivery mode is set to PERSISTENT
by default.
setDeliveryMode
in interface MessageProducer
newDeliveryMode
- the message delivery mode for this message producer; legal
values are DeliveryMode.NON_PERSISTENT
and
DeliveryMode.PERSISTENT
JMSException
- if the JMS provider fails to set the delivery mode due to
some internal error.MessageProducer.getDeliveryMode()
,
DeliveryMode.NON_PERSISTENT
,
DeliveryMode.PERSISTENT
,
Message.DEFAULT_DELIVERY_MODE
public int getDeliveryMode() throws JMSException
getDeliveryMode
in interface MessageProducer
JMSException
- if the JMS provider fails to close the producer due to
some internal error.public void setPriority(int newDefaultPriority) throws JMSException
The JMS API defines ten levels of priority value, with 0 as the lowest priority and 9 as the highest. Clients should consider priorities 0-4 as gradations of normal priority and priorities 5-9 as gradations of expedited priority. Priority is set to 4 by default.
setPriority
in interface MessageProducer
newDefaultPriority
- the message priority for this message producer; must be a
value between 0 and 9
JMSException
- if the JMS provider fails to set the delivery mode due to
some internal error.MessageProducer.getPriority()
,
Message.DEFAULT_PRIORITY
public int getPriority() throws JMSException
getPriority
in interface MessageProducer
JMSException
- if the JMS provider fails to close the producer due to
some internal error.MessageProducer.setPriority(int)
public void setTimeToLive(long timeToLive) throws JMSException
Time to live is set to zero by default.
setTimeToLive
in interface MessageProducer
timeToLive
- the message time to live in milliseconds; zero is unlimited
JMSException
- if the JMS provider fails to set the time to live due to
some internal error.MessageProducer.getTimeToLive()
,
Message.DEFAULT_TIME_TO_LIVE
public long getTimeToLive() throws JMSException
getTimeToLive
in interface MessageProducer
JMSException
- if the JMS provider fails to get the time to live due to
some internal error.MessageProducer.setTimeToLive(long)
public Destination getDestination() throws JMSException
MessageProducer
.
getDestination
in interface MessageProducer
Destination/
- Throws:
JMSException
- if the JMS provider fails to close the producer due to
some internal error.- Since:
- 1.1
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
JMSException
- if the JMS provider fails to close the producer due to
some internal error.protected void checkClosed() throws IllegalStateException
IllegalStateException
public void send(Message message) throws JMSException
MessageProducer
's default
delivery mode, priority, and time to live.
send
in interface MessageProducer
message
- the message to send
JMSException
- if the JMS provider fails to send the message due to some
internal error.
MessageFormatException
- if an invalid message is specified.
InvalidDestinationException
- if a client uses this method with a
MessageProducer
with an invalid destination.
UnsupportedOperationException
- if a client uses this method with a
MessageProducer
that did not specify a
destination at creation time.Session.createProducer(javax.jms.Destination)
,
MessageProducer
public void send(Message message, int deliveryMode, int priority, long timeToLive) throws JMSException
send
in interface MessageProducer
message
- 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.
MessageFormatException
- if an invalid message is specified.
InvalidDestinationException
- if a client uses this method with a
MessageProducer
with an invalid destination.
UnsupportedOperationException
- if a client uses this method with a
MessageProducer
that did not specify a
destination at creation time.Session.createProducer(javax.jms.Destination)
public void send(Destination destination, Message message) throws JMSException
MessageProducer
's default 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.
send
in interface MessageProducer
destination
- the destination to send this message tomessage
- the message to send
JMSException
- if the JMS provider fails to send the message due to some
internal error.
MessageFormatException
- if an invalid message is specified.
InvalidDestinationException
- if a client uses this method with an invalid destination.
UnsupportedOperationException
- if a client uses this method with a
MessageProducer
that specified a destination at
creation time.Session.createProducer(javax.jms.Destination)
,
MessageProducer
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.
MessageFormatException
- if an invalid message is specified.
InvalidDestinationException
- if a client uses this method with an invalid destination.Session.createProducer(javax.jms.Destination)
public boolean isResuseMessageId()
public void setReuseMessageId(boolean reuseMessageId)
reuseMessageId
- The resuseMessageId to set.protected String getProducerId()
protected void setProducerId(String producerId)
producerId
- The producerId to set.protected long getStartTime()
protected IdGenerator getIdGenerator()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |