Example usage for javax.jms IllegalStateException getMessage

List of usage examples for javax.jms IllegalStateException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.oneops.inductor.MessagePublisher.java

@Override
protected boolean process(MessageHolder holder) {
    Map<String, String> event = holder.getMap();
    try {//from   w w  w  . j a v  a  2s.  co  m
        TextMessage message = session.createTextMessage(event.get("body"));
        message.setJMSCorrelationID(event.get("correlationID"));

        for (Map.Entry<String, String> kv : event.entrySet()) {
            if (!kv.getKey().equals("body")) {
                message.setStringProperty(kv.getKey(), kv.getValue());
            }
        }

        MessageProducer producer = regularProducer;
        if ("high".equals(event.get("priority"))) {
            producer = priorityProducer;
            logger.debug("using priority producer to publish message");
        }

        producer.send(message);
        logger.debug("Published: " + message.toString());
        return true;
    } catch (NullPointerException npe) {
        // happens when amq session is null
        logger.warn("caught NullPointerException - reconnecting to broker");
        waitSome();
        init();
        return false;

    } catch (IllegalStateException e) {
        // this happens when connection is hosed - lets re-init
        logger.warn("caught IllegalStateException - reconnecting to broker");
        init();
        return false;

    } catch (JMSException e) {
        logger.error(e.getMessage());
        logger.debug(e.getMessage(), e);
        return false;
    }
}