List of usage examples for javax.jms TopicPublisher publish
void publish(Topic topic, Message message) throws JMSException;
From source file:org.nuxeo.ecm.core.jms.CoreEventPublisher.java
public void publish(Object content, Topic topic, MessageFactory factory, String eventId) throws JMSException { TopicConnection connection = null;//from w ww .j a va 2s .com TopicSession session = null; TopicPublisher publisher = null; try { // get a connection from topic connection pool connection = getTopicConnection(); // create a not transacted session session = connection.createTopicSession(transacted, TopicSession.AUTO_ACKNOWLEDGE); // create the publisher publisher = session.createPublisher(topic); publisher.setDeliveryMode(isDeliveryPersistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT); publisher.setDisableMessageID(isDisableMessageID); publisher.setDisableMessageTimestamp(isDisableMessageTimestamp); // create the message using the given factory Message msg = factory.createMessage(session, content); if (eventId != null) { msg.setStringProperty("NuxeoEventId", eventId); } // publish the message publisher.publish(topic, msg); } finally { if (publisher != null) { publisher.close(); } if (session != null) { session.close(); } if (connection != null) { connection.close(); } } }