Movatterモバイル変換


[0]ホーム

URL:


         


Interface MessageProducer

All Known Subinterfaces:
QueueSender,TopicPublisher

public interfaceMessageProducer

A client uses aMessageProducer object to send messages to a destination. AMessageProducer object is created by passing aDestination 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'sJMSReplyTo 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:
TopicPublisher,QueueSender,Session

close()
          Closes the message producer.
getDeliveryMode()
          Gets the producer's default delivery mode.
getDisableMessageID()
          Gets an indication of whether message IDs are disabled.
getDisableMessageTimestamp()
          Gets an indication of whether message timestamps are disabled.
getPriority()
          Gets the producer's default priority.
getTimeToLive()
          Gets the default length of time in milliseconds from its dispatch time that a produced message should be retained by the message system.
setDeliveryMode(int deliveryMode)
          Sets the producer's default delivery mode.
setDisableMessageID(boolean value)
          Sets whether message IDs are disabled.
setDisableMessageTimestamp(boolean value)
          Sets whether message timestamps are disabled.
setPriority(int defaultPriority)
          Sets the producer's default priority.
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.
 

setDisableMessageID

public voidsetDisableMessageID(boolean value)                         throwsJMSException
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 thesetDisableMessageID 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.

Parameters:
value - indicates if message IDs are disabled
Throws:
JMSException - if the JMS provider fails to set message ID to disabled due to some internal error.

getDisableMessageID

public booleangetDisableMessageID()                            throwsJMSException
Gets an indication of whether message IDs are disabled.
Returns:
an indication of whether message IDs are disabled
Throws:
JMSException - if the JMS provider fails to determine if message IDs are disabled due to some internal error.

setDisableMessageTimestamp

public voidsetDisableMessageTimestamp(boolean value)                                throwsJMSException
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 thesetDisableMessageTimestamp 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.

Parameters:
value - indicates if message timestamps are disabled
Throws:
JMSException - if the JMS provider fails to set timestamps to disabled due to some internal error.

getDisableMessageTimestamp

public booleangetDisableMessageTimestamp()                                   throwsJMSException
Gets an indication of whether message timestamps are disabled.
Returns:
an indication of whether message timestamps are disabled
Throws:
JMSException - if the JMS provider fails to determine if timestamps are disabled due to some internal error.

setDeliveryMode

public voidsetDeliveryMode(int deliveryMode)                     throwsJMSException
Sets the producer's default delivery mode.

Delivery mode is set toPERSISTENT by default.

Parameters:
deliveryMode - the message delivery mode for this message producer; legal values areDeliveryMode.NON_PERSISTENT andDeliveryMode.PERSISTENT
Throws:
JMSException - if the JMS provider fails to set the delivery mode due to some internal error.
See Also:
getDeliveryMode(),DeliveryMode.NON_PERSISTENT,DeliveryMode.PERSISTENT,Message.DEFAULT_DELIVERY_MODE

getDeliveryMode

public intgetDeliveryMode()                    throwsJMSException
Gets the producer's default delivery mode.
Returns:
the message delivery mode for this message producer
Throws:
JMSException - if the JMS provider fails to get the delivery mode due to some internal error.
See Also:
setDeliveryMode(int)

setPriority

public voidsetPriority(int defaultPriority)                 throwsJMSException
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.

Parameters:
defaultPriority - the message priority for this message producer; must be a value between 0 and 9
Throws:
JMSException - if the JMS provider fails to set the priority due to some internal error.
See Also:
getPriority(),Message.DEFAULT_PRIORITY

getPriority

public intgetPriority()                throwsJMSException
Gets the producer's default priority.
Returns:
the message priority for this message producer
Throws:
JMSException - if the JMS provider fails to get the priority due to some internal error.
See Also:
setPriority(int)

setTimeToLive

public voidsetTimeToLive(long timeToLive)                   throwsJMSException
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.

Parameters:
timeToLive - the message time to live in milliseconds; zero is unlimited
Throws:
JMSException - if the JMS provider fails to set the time to live due to some internal error.
See Also:
getTimeToLive(),Message.DEFAULT_TIME_TO_LIVE

getTimeToLive

public longgetTimeToLive()                   throwsJMSException
Gets the default length of time in milliseconds from its dispatch time that a produced message should be retained by the message system.
Returns:
the message time to live in milliseconds; zero is unlimited
Throws:
JMSException - if the JMS provider fails to get the time to live due to some internal error.
See Also:
setTimeToLive(long)

close

public voidclose()           throwsJMSException
Closes the message producer.

Since a provider may allocate some resources on behalf of aMessageProducer 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.

Throws:
JMSException - if the JMS provider fails to close the producer due to some internal error.

         


[8]ページ先頭

©2009-2025 Movatter.jp