package com.tatacommunications.tp.jcm.dispatcher; import javax.ejb.Stateless; import javax.jms.ObjectMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /* Event dispatcher */ @Stateless public class JcmDispatcher implements JcmDispatcherInterface { private static final Logger LOGGER = LoggerFactory.getLogger(JcmDispatcher.class); private ConfEventProducer confEventProducer = new ConfEventProducer(); public JcmDispatcher() { LOGGER.info("JcmDispatcher Start"); } public void queueConfEvent(ConfEvent confEvent) { try { if (confEvent == null) { return; } else { LOGGER.info("JcmDispatcher: confEvent = " + confEvent.toString()); } if (confEventProducer != null) { LOGGER.info("ConferenceProducer: "+ confEventProducer.toString()); ObjectMessage confMessage = confEventProducer.createObjectMessage(confEvent); if (confMessage != null) { //confMessage.setStringProperty("JMSXGroupID", confEvent.getConferenceId()); confEventProducer.send(confMessage); LOGGER.info("JcmDispatcher Sending message: " + confMessage.toString() + " " + confEvent.toString()); } else { LOGGER.info("JcmDispatcher: confMessage is null:" + confEvent.toString()); } } else { LOGGER.info("JcmDispatcher: confProducer is null:" + confEvent.toString()); } } catch(Exception e) { LOGGER.info("JcmDispatcher:Queue Exception {}",e); e.printStackTrace(); this.close(); } } public void close() { if (confEventProducer != null){ confEventProducer.close(); } } }