Example usage for javax.jms JMSException getMessage

List of usage examples for javax.jms JMSException getMessage

Introduction

In this page you can find the example usage for javax.jms JMSException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:de.fzi.ALERT.actor.MessageObserver.ComplexEventObserver.JMSMessageListener.java

public void onMessage(Message msg) {
    // TODO Auto-generated method stub
    if (msg instanceof TextMessage) {
        //         model.Message message = new model.Message();
        //         message.setMsgID(1);
        ////         Pattern pattern = (Pattern) patternDAO.findByPatternName("pattern1");
        //         Pattern pattern = (Pattern) patternDAO.find(2);
        //         message.setPatternId(pattern);
        TextMessage tMsg = (TextMessage) msg;
        try {/*from  w ww.j  a  va  2s.c o  m*/
            //            message.setContent(tMsg.getText());
            de.fzi.ALERT.actor.Model.Message message = parser.parseJsoup(tMsg.getText());
            if (message == null)
                return;
            //            messageDAO.create(message);
            if (!message.getContent().equals("ERROR!") && !message.getContent().equals("")) {
                manager.saveMessage(message);
                manager.sendAnnouncement(message);
            } else {
                System.out.println("message doesn't have content and will be discarded!");
            }

        } catch (JMSException e) {
            System.out.println("ERROR in paring complex event: " + e.getMessage());
        }
    }
}

From source file:org.wso2.carbon.sample.consumer.TopicConsumer.java

public void run() {
    // create topic connection
    TopicConnection topicConnection = null;
    try {/*from ww w. ja v  a 2 s. c  o  m*/
        topicConnection = topicConnectionFactory.createTopicConnection();
        topicConnection.start();
    } catch (JMSException e) {
        log.error("Can not create topic connection." + e.getMessage(), e);
        return;
    }
    Session session = null;
    try {
        session = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
        Destination destination = session.createTopic(topicName);
        MessageConsumer consumer = session.createConsumer(destination);
        log.info("Listening for messages");
        while (active) {
            Message message = consumer.receive(1000);
            if (message != null) {
                if (message instanceof MapMessage) {
                    MapMessage mapMessage = (MapMessage) message;
                    Map<String, Object> map = new HashMap<String, Object>();
                    Enumeration enumeration = mapMessage.getMapNames();
                    while (enumeration.hasMoreElements()) {
                        String key = (String) enumeration.nextElement();
                        map.put(key, mapMessage.getObject(key));
                    }
                    log.info("Received Map Message : " + map);
                } else if (message instanceof TextMessage) {
                    log.info("Received Text Message : " + ((TextMessage) message).getText());
                } else {
                    log.info("Received message : " + message.toString());
                }
            }
        }
        log.info("Finished listening for messages.");
        session.close();
        topicConnection.stop();
        topicConnection.close();
    } catch (JMSException e) {
        log.error("Can not subscribe." + e.getMessage(), e);
    }
}

From source file:org.wso2.carbon.appfactory.eventing.jms.Subscriber.java

public void stopSubscription() throws AppFactoryEventException {
    try {//from   ww  w .ja  va  2 s  .  c o  m
        if (topicConnection != null) {
            topicConnection.stop();
            topicConnection.close();
        }
    } catch (JMSException e) {
        String errorMsg = "Failed to un-subscribe due to:" + e.getMessage();
        if (log.isDebugEnabled()) {
            log.debug(errorMsg, e);
        }
    }
}

From source file:org.wso2.carbon.sample.consumer.QueueConsumer.java

public void run() {
    // create queue connection
    QueueConnection queueConnection = null;
    try {// w w  w  .  j  a  va 2 s .  com
        queueConnection = queueConnectionFactory.createQueueConnection();
        queueConnection.start();
    } catch (JMSException e) {
        log.error("Can not create queue connection." + e.getMessage(), e);
        return;
    }
    Session session = null;
    try {
        session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
        Destination destination = session.createQueue(queueName);
        MessageConsumer consumer = session.createConsumer(destination);
        log.info("Listening for messages");
        while (active) {
            Message message = consumer.receive(1000);
            if (message != null) {
                if (message instanceof MapMessage) {
                    MapMessage mapMessage = (MapMessage) message;
                    Map<String, Object> map = new HashMap<String, Object>();
                    Enumeration enumeration = mapMessage.getMapNames();
                    while (enumeration.hasMoreElements()) {
                        String key = (String) enumeration.nextElement();
                        map.put(key, mapMessage.getObject(key));
                    }
                    log.info("Received Map Message : " + map);
                } else if (message instanceof TextMessage) {
                    log.info("Received Text Message : " + ((TextMessage) message).getText());
                } else {
                    log.info("Received message : " + message.toString());
                }
            }
        }
        log.info("Finished listening for messages.");
        session.close();
        queueConnection.stop();
        queueConnection.close();
    } catch (JMSException e) {
        log.error("Can not subscribe." + e.getMessage(), e);
    }
}

From source file:org.wso2.carbon.bpmn.extensions.jms.JMSSender.java

/**
 * Sends a message to a queue/topic using shared connections, sessions and message producers
 * @param connectionFactory/* ww w . j  a  va2 s.  c  om*/
 * @param text
 */

public void sendMessage(JMSConnectionFactory connectionFactory, int cacheLevel, String target, String text) {

    try {

        Connection connection = connectionFactory.getConnection();
        Session session = connectionFactory.getSession(connection);
        Destination destination;

        if (connectionFactory.isQueue()) {
            destination = session.createQueue(target);
            if (destination == null) {
            }
        } else {
            destination = session.createTopic(target);
        }

        if (destination != null) {

            log.info("initializing jms message producer..");
            MessageProducer producer = connectionFactory.getMessageProducer(connection, session, destination);

            JMSMessageSender jmsMessageSender = new JMSMessageSender(connection, session, producer, destination,
                    cacheLevel, connectionFactory.isQueue());
            TextMessage message = session.createTextMessage(text);
            jmsMessageSender.send(message, null);

        } else {
            log.error("Destination not specified");
        }
    } catch (JMSException ex) {
        log.error(ex.getMessage(), ex);
    }
}

From source file:org.wso2.carbon.appfactory.stratos.listeners.TenantStratosSubscriptionDurableSubscriber.java

/**
 * Stops all subscriptions//from w ww.  ja v a2s .c  o m
 *
 * @throws AppFactoryEventException
 */
public void stopSubscription() throws AppFactoryEventException {
    try {
        if (topicConnection != null) {
            topicConnection.stop();
            topicConnection.close();
        }
    } catch (JMSException e) {
        String errorMsg = "Failed to un-subscribe due to:" + e.getMessage();
        throw new AppFactoryEventException(errorMsg, e);
    }
}

From source file:org.wso2.siddhi.extension.output.transport.jms.util.QueueConsumer.java

public void run() {
    // create queue connection
    QueueConnection queueConnection = null;
    try {//  w  w w  . j  ava 2s  .  c  o m
        queueConnection = queueConnectionFactory.createQueueConnection();
        queueConnection.start();
    } catch (JMSException e) {
        log.error("Can not create queue connection." + e.getMessage(), e);
        return;
    }
    Session session;
    try {
        session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
        Destination destination = session.createQueue(queueName);
        MessageConsumer consumer = session.createConsumer(destination);
        log.info("Listening for messages at " + queueName);
        while (active) {
            Message message = consumer.receive(1000);
            if (message != null) {
                if (message instanceof MapMessage) {
                    MapMessage mapMessage = (MapMessage) message;
                    Map<String, Object> map = new HashMap<String, Object>();
                    Enumeration enumeration = mapMessage.getMapNames();
                    while (enumeration.hasMoreElements()) {
                        String key = (String) enumeration.nextElement();
                        map.put(key, mapMessage.getObject(key));
                    }
                    log.info("Received Map Message: " + map);
                } else if (message instanceof TextMessage) {
                    log.info("Received Text Message: " + ((TextMessage) message).getText());
                } else {
                    log.info("Received message: " + message.toString());
                }
            }
        }
        log.info("Finished listening for messages.");
        session.close();
        queueConnection.stop();
        queueConnection.close();
    } catch (JMSException e) {
        log.error("Can not subscribe." + e.getMessage(), e);
    }
}

From source file:org.wso2.extension.siddhi.io.jms.sink.util.QueueConsumer.java

public void run() {
    // create queue connection
    QueueConnection queueConnection = null;
    try {/*from   w w w. j av a  2  s  .c  om*/
        queueConnection = queueConnectionFactory.createQueueConnection();
        queueConnection.start();
    } catch (JMSException e) {
        log.error("Can not create queue connection." + e.getMessage(), e);
        return;
    }
    Session session;
    try {
        session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
        Destination destination = session.createQueue(queueName);
        MessageConsumer consumer = session.createConsumer(destination);
        log.info("Listening for messages at " + queueName);
        while (active) {
            Message message = consumer.receive(1000);
            if (message != null) {
                resultContainer.eventReceived(message);
                if (message instanceof MapMessage) {
                    MapMessage mapMessage = (MapMessage) message;
                    Map<String, Object> map = new HashMap<String, Object>();
                    Enumeration enumeration = mapMessage.getMapNames();
                    while (enumeration.hasMoreElements()) {
                        String key = (String) enumeration.nextElement();
                        map.put(key, mapMessage.getObject(key));
                    }
                    log.info("Received Map Message: " + map);
                } else if (message instanceof TextMessage) {
                    log.info("Received Text Message: " + ((TextMessage) message).getText());
                } else {
                    log.info("Received message: " + message.toString());
                }
            }
        }
        log.info("Finished listening for messages.");
        session.close();
        queueConnection.stop();
        queueConnection.close();
    } catch (JMSException e) {
        log.error("Can not subscribe." + e.getMessage(), e);
    }
}

From source file:org.wso2.extension.siddhi.io.jms.sink.util.TopicConsumer.java

public void run() {
    // create topic connection
    TopicConnection topicConnection = null;
    try {//from ww  w .  ja  v a2  s.c om
        topicConnection = topicConnectionFactory.createTopicConnection();
        topicConnection.start();
    } catch (JMSException e) {
        log.error("Can not create topic connection." + e.getMessage(), e);
        return;
    }
    Session session = null;
    try {
        session = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
        Destination destination = session.createTopic(topicName);
        MessageConsumer consumer = session.createConsumer(destination);
        log.info("Listening for messages");
        while (active) {
            Message message = consumer.receive(1000);
            if (message != null) {
                resultContainer.eventReceived(message);
                if (message instanceof MapMessage) {
                    MapMessage mapMessage = (MapMessage) message;
                    Map<String, Object> map = new HashMap<String, Object>();
                    Enumeration enumeration = mapMessage.getMapNames();
                    while (enumeration.hasMoreElements()) {
                        String key = (String) enumeration.nextElement();
                        map.put(key, mapMessage.getObject(key));
                    }
                    log.info("Received Map Message : " + map);
                } else if (message instanceof TextMessage) {
                    log.info("Received Text Message : " + ((TextMessage) message).getText());
                } else {
                    log.info("Received message : " + message.toString());
                }
            }
        }
        log.info("Finished listening for messages.");
        session.close();
        topicConnection.stop();
        topicConnection.close();
    } catch (JMSException e) {
        log.error("Can not subscribe." + e.getMessage(), e);
    }
}

From source file:org.sdnmq.jms_demoapps.FilteringPacketInSubscriber.java

@Override
public void onMessage(Message msg) {
    if (msg instanceof TextMessage) {
        String messageStr = null;
        try {/*from ww w . j  a  v  a2  s.  c  om*/
            messageStr = ((TextMessage) (msg)).getText();
        } catch (JMSException e) {
            System.err.println(e.getMessage());
        }

        // Parse JSON message payload

        JSONObject json = null;
        try {
            json = new JSONObject(messageStr);
            // Print the JSON message to show how it looks like.
            System.out.println(json.toString());
            System.out.println();
            // Print all message attributes. These attributes can be used for
            // message filtering.
            printMsgProperties(msg);
        } catch (JSONException e) {
            System.err.println(e.getMessage());
        }
    }
}