MQMessageProducer
public class MQMessageProducer
extends Object
implements MessageProducer
java.lang.Object
|
+----com.ibm.mq.jms.MQMessageProducer
A client uses an MQMessageProducer to send messages to a destination.
Methods
close
public void close() throws JMSException;
Closes the message producer. Because a provider can allocate some resources
outside the JVM on behalf of a MessageProducer, clients must close them when
they are not needed. You cannot rely on garbage collection to reclaim these
resources because this might not occur soon enough.
- Exceptions
-
- JMSException - with reason MQJMS_EXCEPTION_MQ_Q_CLOSE_FAILED
getDeliveryMode
public int getDeliveryMode() throws JMSException;
Gets the producer's default delivery mode.
- Returns
-
- the message delivery mode for this message producer.
- Exceptions
-
- JMSException - with reason MQJMS_MESSAGEPRODUCER_CLOSED
getDestination
public Destination getDestination() throws JMSException;
Gets the destination associated with the message producer.
- Returns
-
- Exceptions
-
- JMSException - with reasons MQJMS_E_INTERNAL_ERROR
getDisableMessageID
public boolean getDisableMessageID() throws JMSException;
Indicates whether message IDs are disabled.
- Returns
-
- true if message IDs are disabled.
- Exceptions
-
- JMSException - with reason MQJMS_MESSAGEPRODUCER_CLOSED
getDisableMessageTimestamp
public boolean getDisableMessageTimestamp() throws JMSException;
Indicates whether message timestamps are disabled.
- Returns
-
- true indicates that timestamps are disabled.
- Exceptions
-
- JMSException - with reason MQJMS_MESSAGEPRODUCER_CLOSED
getPriority
public int getPriority() throws JMSException;
Gets the producer's default priority.
- Returns
-
- the message priority for this message producer.
- Exceptions
-
- JMSException - with reason MQJMS_MESSAGEPRODUCER_CLOSED
getTimeToLive
public long getTimeToLive() throws JMSException;
Gets the default length of time that a produced message will be retained
by the message system.
- Returns
-
- the length of time from its dispatch that a message is retained by default
(milliseconds).
- Exceptions
-
- JMSException - with reason MQJMS_MESSAGEPRODUCER_CLOSED
send
public void send(Destination destination, Message message)
throws JMSException;
Sends a message to a destination if you are using a message producer for
which no destination was specified when the message producer was created.
The method uses the message producer's default delivery mode, default priority,
and default message lifetime. Typically, you specify a destination when you
create a message producer but, if you do not, you must specify a destination
every time you send a message.
- Parameters
-
- destination - the message destination.
- message - the message to send.
- Exceptions
-
- JMSException - with one of the following reasons:
- MQJMS_PUBLISHER_CLOSED
- MQJMS_E_IDENT_PRO_INVALID_OP
- MQJMS_EXCEPTION_MQ_NULL_Q
- MQJMS_EXCEPTION_MQ_Q_OPEN_FAILED
- MQJMS_E_SESSION_ASYNC
- MQJMS_PS_PUBLISH_MSG_FAILED
- MQJMS_EXCEPTION_INVALID_DESTINATION
- MQJMS_EXCEPTION_BAD_VALUE
- MQJMS_E_UNKNOWN_TARGET_CLIENT
- MQJMS_PS_PUBLISH_MSG_BUILD
- MQJMS_EXCEPTION_MSG_CREATE_ERROR
- MQJMS_ERR_QSENDER_CLOSED
- MQJMS_E_SESSION_CLOSED
- MQJMS_E_UNIDENT_PRO_INVALID_OP
- MQJMS_EXCEPTION_MQ_Q_CLOSE_FAILED
- MQRC_Q_TYPE_ERROR
- MQJMS_E_INTERNAL_ERROR
- MQJMS_EXCEPTION_PUT_MSG_FAILED
- MQJMS_MESSAGEPRODUCER_CLOSED
send
public void send(Destination destination, Message message,
int deliveryMode, int priority, long timeToLive)
throws JMSException;
Sends a message to a destination if you are using a message producer for
which no destination was specified when the message producer was created.
The method specifies a delivery mode, a priority, and message lifetime. Typically,
you specify a destination when you create a message producer but, if do not,
you must specify a destination every time you send a message.
- Parameters
-
- destination - the destination to which to send the message.
- message - the message to send.
- deliveryMode - the delivery mode to use
- priority - the priority for the message
- timeToLive - the lifetime of the message in milliseconds
- Exceptions
-
- JMSException - with one of the following reasons:
- MQJMS_PUBLISHER_CLOSED
- MQJMS_E_IDENT_PRO_INVALID_OP
- MQJMS_EXCEPTION_MQ_NULL_Q
- MQJMS_EXCEPTION_MQ_Q_OPEN_FAILED
- MQJMS_E_SESSION_ASYNC
- MQJMS_PS_PUBLISH_MSG_FAILED
- MQJMS_EXCEPTION_INVALID_DESTINATION
- MQJMS_EXCEPTION_BAD_VALUE
- MQJMS_E_UNKNOWN_TARGET_CLIENT
- MQJMS_PS_PUBLISH_MSG_BUILD
- MQJMS_EXCEPTION_MSG_CREATE_ERROR
- MQJMS_ERR_QSENDER_CLOSED
- MQJMS_E_SESSION_CLOSED
- MQJMS_E_UNIDENT_PRO_INVALID_OP
- MQJMS_EXCEPTION_MQ_Q_CLOSE_FAILED
- MQRC_Q_TYPE_ERROR
- MQJMS_EXCEPTION_BAD_VALUE
- MQJMS_E_INTERNAL_ERROR
- MQJMS_EXCEPTION_PUT_MSG_FAILED
send
public void send(Message message) throws JMSException;
Sends a message. Uses the message producer's default delivery mode, default
priority, and default time to live.
- Parameters
-
- message - the message to be sent.
- Exceptions
-
- JMSException - with one of the following reasons:
- MQJMS_PS_TOPIC_NULL
- MQJMS_E_TMPT_DELETED
- MQJMS_EXCEPTION_BAD_VALUE
- MQJMS_PUBLISHER_CLOSED
- MQJMS_E_UNIDENT_PRO_INVALID_OP
- MQJMS_EXCEPTION_MQ_NULL_Q
- MQJMS_E_SESSION_ASYNC
- MQJMS_PS_PUBLISH_MSG_FAILED
- MQJMS_ERR_QSENDER_CLOSED
- MQJMS_E_SESSION_CLOSED
- MQJMS_E_UNKNOWN_TARGET_CLIENT
- MQJMS_PS_PUBLISH_MSG_BUILD
- MQJMS_EXCEPTION_MSG_CREATE_ERROR
- MQJMS_UTIL_PS_NO_BROKER
- MQJMS_E_11_SERVICES_NOT_SETUP
- MQJMS_E_INTERNAL_ERROR
- MQJMS_EXCEPTION_PUT_MSG_FAILED
- MQJMS_MESSAGEPRODUCER_CLOSED
- java.lang.UnsupportedOperationException - if a client uses this method
with a message producer for which no destination was specified when it was
created.
send
public void send(Message message, int deliveryMode, int priority,
long timeToLive) throws JMSException;
Sends a message specifying a delivery mode, a priority, and the lifetime
of the message.
- Parameters
-
- message - the message to send.
- deliveryMode - the delivery mode to use.
- priority - the priority for the message
- timeToLive - the lifetime of the message in milliseconds.
- Exceptions
-
- JMSException - with one of the following reasons:
- MQJMS_PS_TOPIC_NULL
- MQJMS_E_TMPT_DELETED
- MQJMS_EXCEPTION_BAD_VALUE
- MQJMS_PUBLISHER_CLOSED
- MQJMS_E_UNIDENT_PRO_INVALID_OP
- MQJMS_EXCEPTION_MQ_NULL_Q
- MQJMS_E_SESSION_ASYNC
- MQJMS_PS_PUBLISH_MSG_FAILED
- MQJMS_ERR_QSENDER_CLOSED
- MQJMS_E_SESSION_CLOSED
- MQJMS_E_UNKNOWN_TARGET_CLIENT
- MQJMS_PS_PUBLISH_MSG_BUILD
- MQJMS_EXCEPTION_MSG_CREATE_ERROR
- MQJMS_UTIL_PS_NO_BROKER
- MQJMS_E_11_SERVICES_NOT_SETUP
- MQJMS_E_INTERNAL_ERROR
- MQJMS_EXCEPTION_PUT_MSG_FAILED
setDeliveryMode
public void setDeliveryMode(int deliveryMode) throws JMSException;
Sets the producer's default delivery mode.
- Parameters
-
- deliveryMode - the message delivery mode for this message producer. Possible
values are:
- DeliveryMode.NON_PERSISTENT
- DeliveryMode.PERSISTENT, the default
- Exceptions
-
- JMSException - with one of the following reasons:
- MQJMS_MESSAGEPRODUCER_CLOSED
- MQJMS_EXCEPTION_BAD_VALUE
setDisableMessageID
public void setDisableMessageID(boolean value) throws JMSException;
Sets whether message IDs are disabled.
Note: This method is ignored in the WebSphere MQ classes for Java Message
Service implementation.
- Parameters
-
- value - true if message IDs are disabled. Message
IDs are enabled by default.
- Exceptions
-
- JMSException - with reason MQJMS_MESSAGEPRODUCER_CLOSED
setDisableMessageTimestamp
public void setDisableMessageTimestamp(boolean value) throws JMSException;
Sets whether message timestamps are disabled. They are enabled by default.
Note: This method is ignored in the WebSphere MQ classes for Java Message
Service implementation.
- Parameters
-
- value - true indicates that timestamps are disabled.
- Exceptions
-
- JMSException - with reason MQJMS_MESSAGEPRODUCER_CLOSED
setPriority
public void setPriority(int priority) throws JMSException;
Sets the producer's default priority.
- Parameters
-
- priority - the message priority for this message producer. Values can
be between 0 and 9, inclusive. The default is 4.
- Exceptions
-
- JMSException - with one of the following reasons:
- MQJMS_MESSAGEPRODUCER_CLOSED
- MQJMS_EXCEPTION_BAD_VALUE
setTimeToLive
public void setTimeToLive(long timeToLive) throws JMSException;
Sets the default length of time that the message system retains a produced
message.
Note that this method throws a JMSException if set to other than 0 when
you make a direct connection to a broker.
- Parameters
-
- timeToLive - the length of time from its dispatch that a message is retained
by default (milliseconds). The default is zero which means unlimited time.
- Exceptions
-
- JMSException - with one of the following reasons:
- MQJMS_MESSAGEPRODUCER_CLOSED
- MQJMS_EXCEPTION_BAD_VALUE