public interface Publisher
Two kinds of exception are thrown :
This example shows a simple publication of a TextMessage on a topic:
try {
Publisher p = PubSubFactory.publisher();
} catch (MOMException momEx) { ... }
// ...
try {
TextMessage msg = p.createTextMessage();
msg.setText("This is the text");
p.publish("CMW.DEVICES.PowerConverter.PC1.Current", msg);
// ...
p.close();
}
catch (JMSException jmsEx) { ... }
catch (NamingException namingEx) { ... }
PubSubFactory,
Subscriber,
MappingService| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the publisher singleton instance and dealloacate any resource
|
BytesMessage |
createBytesMessage()
Create an instance of BytesMessage.
|
MapMessage |
createMapMessage()
Create an instance of MapMessage.
|
Message |
createMessage()
Create an instance of Message.
|
ObjectMessage |
createObjectMessage()
Create an instance of ObjectMessage.
|
StreamMessage |
createStreamMessage()
Create an instance of StreamMessage.
|
TextMessage |
createTextMessage()
Create an instance of TextMessage.
|
void |
publish(java.lang.String topic,
Message message)
Publish a message to the given topic.
|
void |
publish(java.lang.String topic,
Message message,
int deliveryMode,
int priority,
long timeToLive)
Publish a message to the given topic.
|
void |
setExceptionListener(ExceptionListener listener)
Set the listener for exceptions handling
|
void setExceptionListener(ExceptionListener listener)
listener - The exceptions listenervoid close()
BytesMessage createBytesMessage()
throws JMSException
JMSException - if JMS fails to create the message due to some internal JMS error.MapMessage createMapMessage()
throws JMSException
JMSException - if JMS fails to create the message due to some internal JMS error.Message createMessage()
throws JMSException
JMSException - if JMS fails to create the message due to some internal JMS error.ObjectMessage createObjectMessage()
throws JMSException
JMSException - if JMS fails to create the message due to some internal JMS error.StreamMessage createStreamMessage()
throws JMSException
JMSException - if JMS fails to create the message due to some internal JMS error.TextMessage createTextMessage()
throws JMSException
JMSException - if JMS fails to create the message due to some internal JMS error.void publish(java.lang.String topic,
Message message)
throws JMSException,
javax.naming.NamingException
topic - The String representation of the topicmessage - The Message object to publishJMSException - if JMS fails to publish the message due to some internal JMS error.javax.naming.NamingException - if there is a violation in the namespace policy.void publish(java.lang.String topic,
Message message,
int deliveryMode,
int priority,
long timeToLive)
throws JMSException,
javax.naming.NamingException
topic - The String representation of the topicmessage - The Message object to publishdeliveryMode - The Message persistence (true, false)priority - The Message priority (0..9)timeToLive - The Message time to live (msec)JMSException - if JMS fails to publish the message due to some internal JMS error.javax.naming.NamingException - if there is a violation in the namespace policy.