Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.activemq
Class ActiveMQMessageProducer  view ActiveMQMessageProducer download ActiveMQMessageProducer.java

java.lang.Object
  extended byorg.activemq.ActiveMQMessageProducer
All Implemented Interfaces:
Closeable, javax.jms.MessageProducer, org.activemq.management.StatsCapable
Direct Known Subclasses:
ActiveMQQueueSender, ActiveMQTopicPublisher

public class ActiveMQMessageProducer
extends java.lang.Object
implements javax.jms.MessageProducer, org.activemq.management.StatsCapable, Closeable

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.

Version:
$Revision: 1.1.1.1 $

Field Summary
protected  boolean closed
           
private  int defaultDeliveryMode
           
protected  org.activemq.message.ActiveMQDestination defaultDestination
           
private  int defaultPriority
           
private  long defaultTimeToLive
           
private  boolean disableMessageID
           
private  boolean disableMessageTimestamp
           
private  org.activemq.util.IdGenerator idGenerator
           
private  short producerId
           
private  boolean reuseMessageId
           
protected  ActiveMQSession session
           
private  long startTime
           
private  org.activemq.management.JMSProducerStatsImpl stats
           
 
Constructor Summary
protected ActiveMQMessageProducer(ActiveMQSession theSession, org.activemq.message.ActiveMQDestination destination)
           
 
Method Summary
protected  void checkClosed()
           
 void close()
          Closes the message producer.
 int getDeliveryMode()
          Gets the producer's default delivery mode.
 javax.jms.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  org.activemq.util.IdGenerator getIdGenerator()
           
protected  long getNextSequenceNumber()
           
 int getPriority()
          Gets the producer's default priority.
protected  short getProducerId()
           
protected  java.lang.String getProducerMessageKey()
           
 org.activemq.management.JMSProducerStatsImpl getProducerStats()
           
protected  long getStartTime()
           
 org.activemq.management.StatsImpl 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(javax.jms.Destination destination, javax.jms.Message message)
          Sends a message to a destination for an unidentified message producer.
 void send(javax.jms.Destination destination, javax.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.
 void send(javax.jms.Message message)
          Sends a message using the MessageProducer's default delivery mode, priority, and time to live.
 void send(javax.jms.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.
 void setProducerId(short 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

session

protected ActiveMQSession session

idGenerator

private org.activemq.util.IdGenerator idGenerator

closed

protected boolean closed

disableMessageID

private boolean disableMessageID

disableMessageTimestamp

private boolean disableMessageTimestamp

defaultDeliveryMode

private int defaultDeliveryMode

defaultPriority

private int defaultPriority

defaultTimeToLive

private long defaultTimeToLive

defaultDestination

protected org.activemq.message.ActiveMQDestination defaultDestination

startTime

private long startTime

stats

private org.activemq.management.JMSProducerStatsImpl stats

producerId

private short producerId

reuseMessageId

private boolean reuseMessageId
Constructor Detail

ActiveMQMessageProducer

protected ActiveMQMessageProducer(ActiveMQSession theSession,
                                  org.activemq.message.ActiveMQDestination destination)
                           throws javax.jms.JMSException
Method Detail

getStats

public org.activemq.management.StatsImpl getStats()
Specified by:
getStats in interface org.activemq.management.StatsCapable

getProducerStats

public org.activemq.management.JMSProducerStatsImpl getProducerStats()

setDisableMessageID

public void setDisableMessageID(boolean value)
                         throws javax.jms.JMSException
Sets whether message IDs are disabled.

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.

Specified by:
setDisableMessageID in interface javax.jms.MessageProducer

getDisableMessageID

public boolean getDisableMessageID()
                            throws javax.jms.JMSException
Gets an indication of whether message IDs are disabled.

Specified by:
getDisableMessageID in interface javax.jms.MessageProducer

setDisableMessageTimestamp

public void setDisableMessageTimestamp(boolean value)
                                throws javax.jms.JMSException
Sets whether message timestamps are disabled.

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.

Specified by:
setDisableMessageTimestamp in interface javax.jms.MessageProducer

getDisableMessageTimestamp

public boolean getDisableMessageTimestamp()
                                   throws javax.jms.JMSException
Gets an indication of whether message timestamps are disabled.

Specified by:
getDisableMessageTimestamp in interface javax.jms.MessageProducer

setDeliveryMode

public void setDeliveryMode(int newDeliveryMode)
                     throws javax.jms.JMSException
Sets the producer's default delivery mode.

Delivery mode is set to PERSISTENT by default.

Specified by:
setDeliveryMode in interface javax.jms.MessageProducer

getDeliveryMode

public int getDeliveryMode()
                    throws javax.jms.JMSException
Gets the producer's default delivery mode.

Specified by:
getDeliveryMode in interface javax.jms.MessageProducer

setPriority

public void setPriority(int newDefaultPriority)
                 throws javax.jms.JMSException
Sets the producer's default priority.

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.

Specified by:
setPriority in interface javax.jms.MessageProducer

getPriority

public int getPriority()
                throws javax.jms.JMSException
Gets the producer's default priority.

Specified by:
getPriority in interface javax.jms.MessageProducer

setTimeToLive

public void setTimeToLive(long timeToLive)
                   throws javax.jms.JMSException
Sets the default length of time in milliseconds from its dispatch time that a produced message should be retained by the message system.

Time to live is set to zero by default.

Specified by:
setTimeToLive in interface javax.jms.MessageProducer

getTimeToLive

public long getTimeToLive()
                   throws javax.jms.JMSException
Gets the default length of time in milliseconds from its dispatch time that a produced message should be retained by the message system.

Specified by:
getTimeToLive in interface javax.jms.MessageProducer

getDestination

public javax.jms.Destination getDestination()
                                     throws javax.jms.JMSException
Gets the destination associated with this MessageProducer.

Specified by:
getDestination in interface javax.jms.MessageProducer
Since:
1.1

close

public void close()
           throws javax.jms.JMSException
Closes the message producer.

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.

Specified by:
close in interface javax.jms.MessageProducer

checkClosed

protected void checkClosed()
                    throws javax.jms.IllegalStateException

send

public void send(javax.jms.Message message)
          throws javax.jms.JMSException
Sends a message using the MessageProducer's default delivery mode, priority, and time to live.

Specified by:
send in interface javax.jms.MessageProducer
Since:
1.1

send

public void send(javax.jms.Message message,
                 int deliveryMode,
                 int priority,
                 long timeToLive)
          throws javax.jms.JMSException
Sends a message to the destination, specifying delivery mode, priority, and time to live.

Specified by:
send in interface javax.jms.MessageProducer
Since:
1.1

send

public void send(javax.jms.Destination destination,
                 javax.jms.Message message)
          throws javax.jms.JMSException
Sends a message to a destination for an unidentified message producer. Uses the 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.

Specified by:
send in interface javax.jms.MessageProducer
Since:
1.1

send

public void send(javax.jms.Destination destination,
                 javax.jms.Message message,
                 int deliveryMode,
                 int priority,
                 long timeToLive)
          throws javax.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:
send in interface javax.jms.MessageProducer
Since:
1.1

isResuseMessageId

public boolean isResuseMessageId()

setReuseMessageId

public void setReuseMessageId(boolean reuseMessageId)

getProducerId

protected short getProducerId()

setProducerId

public void setProducerId(short producerId)

getStartTime

protected long getStartTime()

getIdGenerator

protected org.activemq.util.IdGenerator getIdGenerator()

getNextSequenceNumber

protected long getNextSequenceNumber()

getProducerMessageKey

protected java.lang.String getProducerMessageKey()