use of cern.cmw.mom.pubsub.MOMException in project ACS by ACS-Community.
the class DefaultPublisherImpl method initialize.
/**
* Method initialize.
*
* @param retry
* @throws MOMException
*/
private void initialize(boolean retry) throws MOMException {
momProperties = MomConfig.getProperties(this.getClass().getClassLoader());
defaultPersistance = (momProperties.getProperty(MomConfig.MSG_PERSISTANCE_PROPERTY).equals("true") ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
defaultPriority = Integer.parseInt(momProperties.getProperty(MomConfig.MSG_PRIORITY_PROPERTY));
defaultTimeToLive = Long.parseLong(momProperties.getProperty(MomConfig.MSG_TIMETOLIVE_PROPERTY));
topicDirectory = new HashMap();
try {
connection = JMSTopicConnectionFactory.createJMSTopicConnection(username, password, brokerList, loadBalancing, sequential, selectorAtBroker);
connection.connect(retry);
connection.setExceptionListener(this);
session = connection.createTopicSession();
connection.start();
publisher = session.createPublisher(null);
closed = false;
} catch (ConnectionException e) {
System.out.println("Exception caught: " + e.getMessage());
e.printStackTrace(System.err);
throw new MOMException("Unable to estabilish a connection, cause is : " + e.getMessage());
} catch (JMSException e) {
System.out.println("Exception caught: " + e.getMessage());
e.printStackTrace(System.err);
throw (new MOMException(e.getMessage()));
}
}
use of cern.cmw.mom.pubsub.MOMException in project ACS by ACS-Community.
the class DefaultSubscriberImpl method initialize.
/**
* Method initialize
*
* @param retry
* @throws MOMException
*/
private void initialize(boolean retry) throws MOMException {
cat.debug("initialize()");
momProperties = MomConfig.getProperties(this.getClass().getClassLoader());
keepAliveInterval = Integer.valueOf(momProperties.getProperty(MomConfig.KEEP_ALIVE_PROPERTY)).intValue();
notificationsEnabled = Boolean.valueOf(momProperties.getProperty(MomConfig.NOTIFICATION_PROPERTY)).booleanValue();
topicDirectory = new HashMap();
try {
connection = JMSTopicConnectionFactory.createJMSTopicConnection(username, password, brokerList, loadBalancing, sequential, selectorAtBroker);
connection.connect(retry);
connection.setExceptionListener(this);
serviceSession = connection.createTopicSession();
connection.start();
} catch (ConnectionException e) {
throw new MOMException("Unable to estabilish a connection, cause is : " + e.getMessage());
}
try {
notificationPublisher = serviceSession.createPublisher(null);
notificationPublisher.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
notificationPublisher.setTimeToLive(60000);
notificationMessage = serviceSession.createMessage();
} catch (JMSException e) {
System.out.println("Exception caught: " + e.getMessage());
e.printStackTrace(System.err);
throw (new MOMException("Exception raised attempting to create the notifications publisher, cause is : " + e.getMessage()));
}
}
Aggregations