Class WmMessageProducerImpl
- java.lang.Object
-
- com.webmethods.locks.Node
-
- com.webmethods.jms.impl.WmMessageProducerImpl
-
- All Implemented Interfaces:
WmMessageProducer
,javax.jms.MessageProducer
- Direct Known Subclasses:
WmClusterMultiSendProducerImpl
,WmQueueSenderImpl
,WmTopicPublisherImpl
public class WmMessageProducerImpl extends Node implements WmMessageProducer
-
-
Field Summary
Fields Modifier and Type Field Description protected WmDestinationImpl
_destination
protected boolean
_logApi
protected WmSessionImpl
_session
-
Fields inherited from class com.webmethods.locks.Node
_lockManager
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
WmMessageProducerImpl(WmSessionImpl session)
Default contructor for subclasses.protected
WmMessageProducerImpl(WmSessionImpl session, WmDestinationImpl destination)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkState()
void
close()
Closes the message producer.protected static java.lang.String
deliveryModeToString(int deliveryMode)
int
getCompressionLevel()
Get the compression level for this producer.int
getCompressionThreshold()
Get the compression threshold for this producer.int
getDeliveryMode()
Gets the producer's default delivery mode.javax.jms.Destination
getDestination()
Gets the destination associated with thisMessageProducer
.boolean
getDisableMessageID()
Gets an indication of whether message IDs are disabled.boolean
getDisableMessageTimestamp()
Gets an indication of whether message timestamps are disabled.java.io.OutputStream
getOutputStream()
Returns an OutputStream that writes data over a MessageConsumer.java.io.OutputStream
getOutputStream(int packetSize)
Returns an OutputStream that writes data over a MessageConsumer.int
getPriority()
Gets the producer's default priority.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.java.lang.String
nextMessageIdentifier()
protected void
reconnect()
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[] messages)
Sends multiple messages to a destination for an unidentified message producer.void
send(javax.jms.Destination destination, javax.jms.Message[] messages, int deliveryMode, int priority, long timeToLive)
Sends multiple messages to a destination for an unidentified message producer, specifying delivery mode, priority and time to live.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 theMessageProducer
's default delivery mode, priority, and time to live.void
send(javax.jms.Message[] messages)
Sends multiple messages using theMessageProducer
's default delivery mode, priority, and time to live.void
send(javax.jms.Message[] messages, int deliveryMode, int priority, long timeToLive)
Sends multiple messages to the destination, specifying 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
setCompressionLevel(int level)
Set the compression level for this producer.void
setCompressionThreshold(int compressionThreshold)
Set the compression threshold for this producer.void
setDeliveryMode(int deliveryMode)
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 defaultPriority)
Sets the producer's default priority.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.java.lang.String
toString()
-
Methods inherited from class com.webmethods.locks.Node
getLockManager, getParent
-
-
-
-
Field Detail
-
_session
protected WmSessionImpl _session
-
_destination
protected WmDestinationImpl _destination
-
_logApi
protected boolean _logApi
-
-
Constructor Detail
-
WmMessageProducerImpl
protected WmMessageProducerImpl(WmSessionImpl session, WmDestinationImpl destination)
-
WmMessageProducerImpl
protected WmMessageProducerImpl(WmSessionImpl session)
Default contructor for subclasses.
-
-
Method Detail
-
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 interfacejavax.jms.MessageProducer
- Parameters:
value
- indicates if message IDs are disabled- Throws:
javax.jms.JMSException
- if the JMS provider fails to set message ID to disabled due to some internal error.
-
getDisableMessageID
public boolean getDisableMessageID() throws javax.jms.JMSException
Gets an indication of whether message IDs are disabled.- Specified by:
getDisableMessageID
in interfacejavax.jms.MessageProducer
- Returns:
- an indication of whether message IDs are disabled
- Throws:
javax.jms.JMSException
- if the JMS provider fails to determine if message IDs are disabled due to some internal error.
-
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 interfacejavax.jms.MessageProducer
- Parameters:
value
- indicates if message timestamps are disabled- Throws:
javax.jms.JMSException
- if the JMS provider fails to set timestamps to disabled due to some internal error.
-
getDisableMessageTimestamp
public boolean getDisableMessageTimestamp() throws javax.jms.JMSException
Gets an indication of whether message timestamps are disabled.- Specified by:
getDisableMessageTimestamp
in interfacejavax.jms.MessageProducer
- Returns:
- an indication of whether message timestamps are disabled
- Throws:
javax.jms.JMSException
- if the JMS provider fails to determine if timestamps are disabled due to some internal error.
-
setDeliveryMode
public void setDeliveryMode(int deliveryMode) throws javax.jms.JMSException
Sets the producer's default delivery mode.Delivery mode is set to
PERSISTENT
by default.- Specified by:
setDeliveryMode
in interfacejavax.jms.MessageProducer
- Parameters:
deliveryMode
- the message delivery mode for this message producer; legal values areDeliveryMode.NON_PERSISTENT
andDeliveryMode.PERSISTENT
- Throws:
javax.jms.JMSException
- if the JMS provider fails to set the delivery mode due to some internal error.- See Also:
MessageProducer.getDeliveryMode()
,DeliveryMode.NON_PERSISTENT
,DeliveryMode.PERSISTENT
,Message.DEFAULT_DELIVERY_MODE
-
getDeliveryMode
public int getDeliveryMode() throws javax.jms.JMSException
Gets the producer's default delivery mode.- Specified by:
getDeliveryMode
in interfacejavax.jms.MessageProducer
- Returns:
- the message delivery mode for this message producer
- Throws:
javax.jms.JMSException
- if the JMS provider fails to get the delivery mode due to some internal error.- See Also:
MessageProducer.setDeliveryMode(int)
-
setPriority
public void setPriority(int defaultPriority) 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 interfacejavax.jms.MessageProducer
- Parameters:
defaultPriority
- the message priority for this message producer; must be a value between 0 and 9- Throws:
javax.jms.JMSException
- if the JMS provider fails to set the priority due to some internal error.- See Also:
MessageProducer.getPriority()
,Message.DEFAULT_PRIORITY
-
getPriority
public int getPriority() throws javax.jms.JMSException
Gets the producer's default priority.- Specified by:
getPriority
in interfacejavax.jms.MessageProducer
- Returns:
- the message priority for this message producer
- Throws:
javax.jms.JMSException
- if the JMS provider fails to get the priority due to some internal error.- See Also:
MessageProducer.setPriority(int)
-
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 interfacejavax.jms.MessageProducer
- Parameters:
timeToLive
- the message time to live in milliseconds; zero is unlimited- Throws:
javax.jms.JMSException
- if the JMS provider fails to set the time to live due to some internal error.- See Also:
MessageProducer.getTimeToLive()
,Message.DEFAULT_TIME_TO_LIVE
-
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 interfacejavax.jms.MessageProducer
- Returns:
- the message time to live in milliseconds; zero is unlimited
- Throws:
javax.jms.JMSException
- if the JMS provider fails to get the time to live due to some internal error.- See Also:
MessageProducer.setTimeToLive(long)
-
getDestination
public javax.jms.Destination getDestination() throws javax.jms.JMSException
Gets the destination associated with thisMessageProducer
.- Specified by:
getDestination
in interfacejavax.jms.MessageProducer
- Returns:
- this producer's
Destination/
- Throws:
javax.jms.JMSException
- if the JMS provider fails to get the destination for thisMessageProducer
due to some internal error.- 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 interfacejavax.jms.MessageProducer
- Throws:
javax.jms.JMSException
- if the JMS provider fails to close the producer due to some internal error.
-
send
public void send(javax.jms.Message message) throws javax.jms.JMSException
Sends a message using theMessageProducer
's default delivery mode, priority, and time to live.- Specified by:
send
in interfacejavax.jms.MessageProducer
- Parameters:
message
- the message to send- Throws:
javax.jms.JMSException
- if the JMS provider fails to send the message due to some internal error.javax.jms.MessageFormatException
- if an invalid message is specified.javax.jms.InvalidDestinationException
- if a client uses this method with aMessageProducer
with an invalid destination.java.lang.UnsupportedOperationException
- if a client uses this method with aMessageProducer
that did not specify a destination at creation time.- Since:
- 1.1
- See Also:
Session.createProducer(javax.jms.Destination)
,MessageProducer
-
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 interfacejavax.jms.MessageProducer
- Parameters:
message
- the message to senddeliveryMode
- the delivery mode to usepriority
- the priority for this messagetimeToLive
- the message's lifetime (in milliseconds)- Throws:
javax.jms.JMSException
- if the JMS provider fails to send the message due to some internal error.javax.jms.MessageFormatException
- if an invalid message is specified.javax.jms.InvalidDestinationException
- if a client uses this method with aMessageProducer
with an invalid destination.java.lang.UnsupportedOperationException
- if a client uses this method with aMessageProducer
that did not specify a destination at creation time.- Since:
- 1.1
- See Also:
Session.createProducer(javax.jms.Destination)
-
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 theMessageProducer
'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 interfacejavax.jms.MessageProducer
- Parameters:
destination
- the destination to send this message tomessage
- the message to send- Throws:
javax.jms.JMSException
- if the JMS provider fails to send the message due to some internal error.javax.jms.MessageFormatException
- if an invalid message is specified.javax.jms.InvalidDestinationException
- if a client uses this method with an invalid destination.java.lang.UnsupportedOperationException
- if a client uses this method with aMessageProducer
that specified a destination at creation time.- Since:
- 1.1
- See Also:
Session.createProducer(javax.jms.Destination)
,MessageProducer
-
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 interfacejavax.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:
javax.jms.JMSException
- if the JMS provider fails to send the message due to some internal error.javax.jms.MessageFormatException
- if an invalid message is specified.javax.jms.InvalidDestinationException
- if a client uses this method with an invalid destination.- Since:
- 1.1
- See Also:
Session.createProducer(javax.jms.Destination)
-
send
public void send(javax.jms.Message[] messages) throws javax.jms.JMSException
Description copied from interface:WmMessageProducer
Sends multiple messages using theMessageProducer
's default delivery mode, priority, and time to live.- Specified by:
send
in interfaceWmMessageProducer
- Parameters:
messages
- the messages to send- Throws:
javax.jms.JMSException
- if the JMS provider fails to send the message due to some internal error.javax.jms.MessageFormatException
- if an invalid message is specified.javax.jms.InvalidDestinationException
- if a client uses this method with aMessageProducer
with an invalid destination.- See Also:
Session.createProducer(javax.jms.Destination)
-
send
public void send(javax.jms.Message[] messages, int deliveryMode, int priority, long timeToLive) throws javax.jms.JMSException
Description copied from interface:WmMessageProducer
Sends multiple messages to the destination, specifying delivery mode, priority, and time to live.- Specified by:
send
in interfaceWmMessageProducer
- Parameters:
messages
- the messages to senddeliveryMode
- the delivery mode to usepriority
- the priority for this messagetimeToLive
- the message's lifetime (in milliseconds)- Throws:
javax.jms.JMSException
- if the JMS provider fails to send the message due to some internal error.javax.jms.MessageFormatException
- if an invalid message is specified.javax.jms.InvalidDestinationException
- if a client uses this method with aMessageProducer
with an invalid destination.- See Also:
Session.createProducer(javax.jms.Destination)
-
send
public void send(javax.jms.Destination destination, javax.jms.Message[] messages) throws javax.jms.JMSException
Description copied from interface:WmMessageProducer
Sends multiple messages to a destination for an unidentified message producer. Uses theMessageProducer
'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 interfaceWmMessageProducer
- Parameters:
destination
- the destination to send the messages tomessages
- the messages to send- Throws:
javax.jms.JMSException
- if the JMS provider fails to send the message due to some internal error.javax.jms.MessageFormatException
- if an invalid message is specified.javax.jms.InvalidDestinationException
- if a client uses this method with an invalid destination.- See Also:
Session.createProducer(javax.jms.Destination)
-
send
public void send(javax.jms.Destination destination, javax.jms.Message[] messages, int deliveryMode, int priority, long timeToLive) throws javax.jms.JMSException
Description copied from interface:WmMessageProducer
Sends multiple messages 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 interfaceWmMessageProducer
- Parameters:
destination
- the destination to send the messages tomessages
- the messages to senddeliveryMode
- the delivery mode to usepriority
- the priority for this messagetimeToLive
- the message's lifetime (in milliseconds)- Throws:
javax.jms.JMSException
- if the JMS provider fails to send the message due to some internal error.javax.jms.MessageFormatException
- if an invalid message is specified.javax.jms.InvalidDestinationException
- if a client uses this method with an invalid destination.- See Also:
Session.createProducer(javax.jms.Destination)
-
setCompressionThreshold
public void setCompressionThreshold(int compressionThreshold) throws javax.jms.JMSException
Description copied from interface:WmMessageProducer
Set the compression threshold for this producer. Any message sent by this producer whose size exceeds the threshold will be automatically compressed.A value of -1 disables all message compression.
- Specified by:
setCompressionThreshold
in interfaceWmMessageProducer
- Parameters:
compressionThreshold
- The compression threshold.- Throws:
javax.jms.JMSException
- for any internal errors.
-
getCompressionThreshold
public int getCompressionThreshold() throws javax.jms.JMSException
Description copied from interface:WmMessageProducer
Get the compression threshold for this producer.- Specified by:
getCompressionThreshold
in interfaceWmMessageProducer
- Returns:
- The compression threshold.
- Throws:
javax.jms.JMSException
- for any internal errors.
-
setCompressionLevel
public void setCompressionLevel(int level) throws javax.jms.JMSException
Description copied from interface:WmMessageProducer
Set the compression level for this producer.- Specified by:
setCompressionLevel
in interfaceWmMessageProducer
- Parameters:
level
- The compression level (0-9) as defined byjava.util.zip.Deflater
.- Throws:
javax.jms.JMSException
- for any internal errors.
-
getCompressionLevel
public int getCompressionLevel() throws javax.jms.JMSException
Description copied from interface:WmMessageProducer
Get the compression level for this producer.- Specified by:
getCompressionLevel
in interfaceWmMessageProducer
- Returns:
- The compression level (0-9) as defined by
java.util.zip.Deflater
. - Throws:
javax.jms.JMSException
- for any internal errors.
-
getOutputStream
public java.io.OutputStream getOutputStream(int packetSize) throws javax.jms.JMSException
Description copied from interface:WmMessageProducer
Returns an OutputStream that writes data over a MessageConsumer.- Specified by:
getOutputStream
in interfaceWmMessageProducer
- Parameters:
packetSize
- the maximum number of bytes to include in each underlying BytesMessage that represents the stream.- Returns:
- an OutputStream
- Throws:
javax.jms.InvalidDestinationException
- if a client uses this method with aMessageProducer
with an invalid destination.javax.jms.JMSException
- if the MessageProducer's OutputStream could not be returned.
-
getOutputStream
public java.io.OutputStream getOutputStream() throws javax.jms.JMSException
Description copied from interface:WmMessageProducer
Returns an OutputStream that writes data over a MessageConsumer. The default packet size is used.- Specified by:
getOutputStream
in interfaceWmMessageProducer
- Returns:
- an OutputStream
- Throws:
javax.jms.InvalidDestinationException
- if a client uses this method with aMessageProducer
with an invalid destination.javax.jms.JMSException
- if the MessageProducer's OutputStream could not be returned.
-
checkState
protected void checkState() throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
reconnect
protected void reconnect() throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
nextMessageIdentifier
public java.lang.String nextMessageIdentifier()
-
deliveryModeToString
protected static java.lang.String deliveryModeToString(int deliveryMode)
-
-