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:org.wso2.carbon.inbound.endpoint.protocol.jms.factory.JMSConnectionFactory.java

protected Session createSession(Connection connection) {
    try {/*from   w  ww .  j  a  va2  s.  c o m*/
        if (JMSConstants.JMS_SPEC_VERSION_1_1.equals(jmsSpec)
                || JMSConstants.JMS_SPEC_VERSION_2_0.equals(jmsSpec)) {
            return connection.createSession(transactedSession, sessionAckMode);
        } else {
            if (this.destinationType.equals(JMSConstants.JMSDestinationType.QUEUE)) {
                return (QueueSession) ((QueueConnection) (connection)).createQueueSession(transactedSession,
                        sessionAckMode);
            } else if (this.destinationType.equals(JMSConstants.JMSDestinationType.TOPIC)) {
                return (TopicSession) ((TopicConnection) (connection)).createTopicSession(transactedSession,
                        sessionAckMode);
            }
        }
    } catch (JMSException e) {
        logger.error("JMS Exception while obtaining session for factory '" + this.connectionFactoryString + "' "
                + e.getMessage(), e);
    }

    return null;
}

From source file:org.wso2.carbon.inbound.endpoint.protocol.jms.factory.JMSConnectionFactory.java

public QueueConnection createQueueConnection(String userName, String password) throws JMSException {
    try {//  w  w w.j  a  va  2s  .  com
        return ((QueueConnectionFactory) (this.connectionFactory)).createQueueConnection(userName, password);
    } catch (JMSException e) {
        logger.error("JMS Exception while creating queue connection through factory '"
                + this.connectionFactoryString + "' " + e.getMessage(), e);
    }

    return null;
}

From source file:org.wso2.carbon.inbound.endpoint.protocol.jms.factory.JMSConnectionFactory.java

public TopicConnection createTopicConnection() throws JMSException {
    try {//  ww w  .  ja  v  a  2  s . co  m
        return ((TopicConnectionFactory) (this.connectionFactory)).createTopicConnection();
    } catch (JMSException e) {
        logger.error("JMS Exception while creating topic connection through factory '"
                + this.connectionFactoryString + "' " + e.getMessage(), e);
    }

    return null;
}

From source file:org.wso2.carbon.inbound.endpoint.protocol.jms.factory.JMSConnectionFactory.java

public TopicConnection createTopicConnection(String userName, String password) throws JMSException {
    try {/*www.j  av  a2  s .c om*/
        return ((TopicConnectionFactory) (this.connectionFactory)).createTopicConnection(userName, password);
    } catch (JMSException e) {
        logger.error("JMS Exception while creating topic connection through factory '"
                + this.connectionFactoryString + "' " + e.getMessage(), e);
    }

    return null;
}

From source file:au.com.redboxresearchdata.fascinator.plugins.JsonHarvestQueueConsumer.java

/**
 * Harvests JSON objects as messages.//from  w w  w . j  a  va  2  s . com
 * 
 * Expects the ff. JSON structure:
 * "data" -  data object
 * "type" -  indicates which harvest config file to use, maps to "{portal.harvestFiles}/{type}.json"
 */
public void onMessage(Message message) {
    try {
        log.info("Got message..");
        String text = ((TextMessage) message).getText();
        log.info(name + ", got message: " + text);
        processJsonText(text);
    } catch (JMSException jmse) {
        log.error("Failed to send/receive message: {}", jmse.getMessage());
    } catch (IOException ioe) {
        log.error("Failed to parse message: {}", ioe.getMessage());
    } catch (Exception ex) {
        log.error("Failed to harvest object: {}", ex.getMessage());
        log.error("Stack trace:", ex);
    }
}

From source file:org.wso2.carbon.inbound.endpoint.protocol.jms.factory.JMSConnectionFactory.java

public Connection createConnection(String userName, String password) {
    Connection connection = null;
    try {/*from   ww  w  . j a  va 2  s .  c  o m*/
        if (JMSConstants.JMS_SPEC_VERSION_1_1.equals(jmsSpec)) {
            if (this.destinationType.equals(JMSConstants.JMSDestinationType.QUEUE)) {
                connection = ((QueueConnectionFactory) (this.connectionFactory)).createQueueConnection(userName,
                        password);
            } else if (this.destinationType.equals(JMSConstants.JMSDestinationType.TOPIC)) {
                connection = ((TopicConnectionFactory) (this.connectionFactory)).createTopicConnection(userName,
                        password);
            }
            if (isDurable) {
                connection.setClientID(clientId);
            }
            return connection;
        } else {
            QueueConnectionFactory qConFac = null;
            TopicConnectionFactory tConFac = null;
            if (this.destinationType.equals(JMSConstants.JMSDestinationType.QUEUE)) {
                qConFac = (QueueConnectionFactory) this.connectionFactory;
            } else {
                tConFac = (TopicConnectionFactory) this.connectionFactory;
            }
            if (qConFac != null) {
                connection = qConFac.createQueueConnection(userName, password);
            } else if (tConFac != null) {
                connection = tConFac.createTopicConnection(userName, password);
            }
            if (isDurable && !isSharedSubscription) {
                connection.setClientID(clientId);
            }
            return connection;
        }
    } catch (JMSException e) {
        logger.error("JMS Exception while creating connection through factory '" + this.connectionFactoryString
                + "' " + e.getMessage());
        // Need to close the connection in the case if durable subscriptions
        if (connection != null) {
            try {
                connection.close();
            } catch (Exception ex) {
            }
        }
    }

    return null;
}

From source file:org.wso2.carbon.inbound.endpoint.protocol.jms.factory.JMSConnectionFactory.java

public Connection createConnection() {
    if (connectionFactory == null) {
        logger.error("Connection cannot be establish to the broker. Please check the broker libs provided.");
        return null;
    }//from  w  w  w.  ja v  a  2  s .  c  o m
    Connection connection = null;
    try {
        if ("1.1".equals(jmsSpec)) {
            if (this.destinationType.equals(JMSConstants.JMSDestinationType.QUEUE)) {
                connection = ((QueueConnectionFactory) (this.connectionFactory)).createQueueConnection();
            } else if (this.destinationType.equals(JMSConstants.JMSDestinationType.TOPIC)) {
                connection = ((TopicConnectionFactory) (this.connectionFactory)).createTopicConnection();
            }
            if (isDurable) {
                connection.setClientID(clientId);
            }
            return connection;
        } else {
            QueueConnectionFactory qConFac = null;
            TopicConnectionFactory tConFac = null;
            if (this.destinationType.equals(JMSConstants.JMSDestinationType.QUEUE)) {
                qConFac = (QueueConnectionFactory) this.connectionFactory;
            } else {
                tConFac = (TopicConnectionFactory) this.connectionFactory;
            }
            if (qConFac != null) {
                connection = qConFac.createQueueConnection();
            } else if (tConFac != null) {
                connection = tConFac.createTopicConnection();
            }
            if (isDurable && !isSharedSubscription) {
                connection.setClientID(clientId);
            }
            return connection;
        }
    } catch (JMSException e) {
        logger.error("JMS Exception while creating connection through factory '" + this.connectionFactoryString
                + "' " + e.getMessage(), e);
        // Need to close the connection in the case if durable subscriptions
        if (connection != null) {
            try {
                connection.close();
            } catch (Exception ex) {
            }
        }
    }

    return null;
}

From source file:org.sdnmq.jms.FlowProgrammer.java

/**
 * Starts the receiver thread receiving flow programming requests via JMS queue.
 *//*from  ww w. ja  v  a2s  .  c o m*/
private void startMsgListener() {
    try {
        receiver.setMessageListener(this);
    } catch (JMSException e) {
        log.error(e.getMessage());
        return;
    }

    try {
        connection.start();
    } catch (JMSException e) {
        log.error(e.getMessage());
        return;
    }
}

From source file:com.mirth.connect.connectors.jms.transformers.AbstractJmsTransformer.java

/**
 * @param src The source data to compress
 * @return/*from w  w  w  .  j  av  a  2s  .  c  o m*/
 * @throws TransformerException
 */
protected Message transformToMessage(Object src) throws TransformerException {
    try {
        // The session can be closed by the dispatcher closing so its more
        // reliable to get it from the dispatcher each time
        if (requireNewSession || getEndpoint() != null) {
            session = (Session) getEndpoint().getConnector().getDispatcher("transformerSession")
                    .getDelegateSession();
            requireNewSession = session == null;
        }

        Message msg = null;
        if (src instanceof Message) {
            msg = (Message) src;
            msg.clearProperties();
        } else {
            msg = JmsMessageUtils.getMessageForObject(src, session);
        }
        // set the event properties on the Message
        UMOEventContext ctx = RequestContext.getEventContext();
        if (ctx == null) {
            logger.warn("There is no current event context");
            return msg;
        }

        Map props = ctx.getProperties();
        props = PropertiesHelper.getPropertiesWithoutPrefix(props, "JMS");

        // FIXME: If we add the "destinations" property, then this message will be
        // ignored by channels that are not related to the original source
        // channel.
        // Bug: MIRTH-1689
        props.remove("destinations");

        Map.Entry entry;
        String key;
        for (Iterator iterator = props.entrySet().iterator(); iterator.hasNext();) {
            entry = (Map.Entry) iterator.next();
            key = entry.getKey().toString();
            if (MuleProperties.MULE_CORRELATION_ID_PROPERTY.equals(key)) {
                msg.setJMSCorrelationID(entry.getValue().toString());
            }
            //We dont want to set the ReplyTo property again as it will be set using JMSReplyTo
            if (!(MuleProperties.MULE_REPLY_TO_PROPERTY.equals(key)
                    && entry.getValue() instanceof Destination)) {
                try {
                    msg.setObjectProperty(encodeHeader(key), entry.getValue());
                } catch (JMSException e) {
                    //Various Jms servers have slightly different rules to what can be set as an object property on the message
                    //As such we have to take a hit n' hope approach
                    if (logger.isDebugEnabled())
                        logger.debug("Unable to set property '" + encodeHeader(key) + "' of type "
                                + entry.getValue().getClass().getName() + "': " + e.getMessage());
                }
            }
        }

        return msg;
        // }
    } catch (Exception e) {
        throw new TransformerException(this, e);
    }
}

From source file:org.wso2.carbon.inbound.endpoint.protocol.jms.factory.JMSConnectionFactory.java

public Destination createDestination(Session session, String destinationName) {
    Destination destination = null;
    try {/*  w ww.j a va  2s.co m*/
        if (this.destinationType.equals(JMSConstants.JMSDestinationType.QUEUE)) {
            destination = JMSUtils.lookupDestination(ctx, destinationName, JMSConstants.DESTINATION_TYPE_QUEUE);
        } else if (this.destinationType.equals(JMSConstants.JMSDestinationType.TOPIC)) {
            destination = JMSUtils.lookupDestination(ctx, destinationName, JMSConstants.DESTINATION_TYPE_TOPIC);
        }
    } catch (NameNotFoundException e) {
        if (logger.isDebugEnabled()) {
            logger.debug("Could not find destination '" + destinationName + "' on connection factory for '"
                    + this.connectionFactoryString + "'. " + e.getMessage());
            logger.debug("Creating destination '" + destinationName + "' on connection factory for '"
                    + this.connectionFactoryString + ".");
        }
        try {
            if (this.destinationType.equals(JMSConstants.JMSDestinationType.QUEUE)) {
                destination = (Queue) session.createQueue(destinationName);
            } else if (this.destinationType.equals(JMSConstants.JMSDestinationType.TOPIC)) {
                destination = (Topic) session.createTopic(destinationName);
            }
            if (logger.isDebugEnabled()) {
                logger.debug("Created '" + destinationName + "' on connection factory for '"
                        + this.connectionFactoryString + "'.");
            }
        } catch (JMSException e1) {
            logger.error("Could not find nor create '" + destinationName + "' on connection factory for '"
                    + this.connectionFactoryString + "'. " + e1.getMessage(), e1);
        }

    } catch (NamingException e) {
        logger.error("Naming exception while obtaining connection factory for '" + this.connectionFactoryString
                + "' " + e.getMessage(), e);
    }

    return destination;
}