List of usage examples for javax.jms JMSException getLocalizedMessage
public String getLocalizedMessage()
From source file:org.apache.synapse.message.store.impl.jms.JmsConsumer.java
public MessageContext receive() { boolean error; JMSException exception; if (!checkConnection()) { if (!reconnect()) { if (logger.isDebugEnabled()) { logger.debug(getId() + " cannot receive message from store. Cannot reconnect."); }// w w w .j a v a 2 s .c om return null; } else { logger.info(getId() + " reconnected to store."); isReceiveError = false; } } if (!checkConnection()) { if (logger.isDebugEnabled()) { logger.debug(getId() + " cannot receive message from store."); } return null; } try { Message message = consumer.receive(1); if (message == null) { return null; } if (!(message instanceof ObjectMessage)) { logger.warn(getId() + ". Did not receive a javax.jms.ObjectMessage"); message.acknowledge(); // TODO: return null; } ObjectMessage msg = (ObjectMessage) message; String messageId = msg.getStringProperty(Constants.OriginalMessageID); if (!(msg.getObject() instanceof StorableMessage)) { logger.warn(getId() + ". Did not receive a valid message."); message.acknowledge(); return null; } StorableMessage storableMessage = (StorableMessage) msg.getObject(); org.apache.axis2.context.MessageContext axis2Mc = store.newAxis2Mc(); MessageContext synapseMc = store.newSynapseMc(axis2Mc); synapseMc = MessageConverter.toMessageContext(storableMessage, axis2Mc, synapseMc); updateCache(message, synapseMc, messageId, false); if (logger.isDebugEnabled()) { logger.debug( getId() + " Received MessageId:" + messageId + " priority:" + message.getJMSPriority()); } return synapseMc; } catch (JMSException e) { error = true; exception = e; } if (error) { if (!isReceiveError) { logger.error( getId() + " cannot receive message from store. Error:" + exception.getLocalizedMessage());//, exception); } updateCache(null, null, "", true); cleanup(); return null; } return null; }
From source file:org.apache.synapse.message.store.impl.jms.JmsProducer.java
private void setJmsProducerProperties(javax.jms.MessageProducer producer, MessageContext synCtx) { Object prop = synCtx.getProperty(JMS_PROD_TIME_TO_LIVE); long ttl = Message.DEFAULT_TIME_TO_LIVE; if (prop instanceof String) { ttl = Long.parseLong((String) prop); } else if (prop instanceof Long || prop instanceof Integer) { ttl = Long.parseLong(prop.toString()); }//ww w . j a v a 2 s .c om prop = synCtx.getProperty(JMS_PROD_DISABLE_MSG_TIMESTAMP); boolean disableMessageTimestamp = false; if (prop instanceof String) { disableMessageTimestamp = Boolean.parseBoolean((String) prop); } else if (prop instanceof Boolean) { disableMessageTimestamp = (Boolean) prop; } prop = synCtx.getProperty(JMS_PROD_DELIVERY_MODE); int deliveryMode = Message.DEFAULT_DELIVERY_MODE; if (prop instanceof Integer) { deliveryMode = (Integer) prop; } else if (prop instanceof String) { deliveryMode = Integer.parseInt((String) prop); } prop = synCtx.getProperty(JMS_PROD_DISABLE_MSG_ID); boolean disableMessageId = false; if (prop instanceof String) { disableMessageId = Boolean.parseBoolean((String) prop); } else if (prop instanceof Boolean) { disableMessageId = (Boolean) prop; } prop = synCtx.getProperty(JMS_PROD_PRIORITY); int priority = Message.DEFAULT_PRIORITY; if (prop instanceof Integer) { priority = (Integer) prop; } else if (prop instanceof String) { priority = Integer.parseInt((String) prop); } try { producer.setTimeToLive(ttl); producer.setDisableMessageTimestamp(disableMessageTimestamp); producer.setDeliveryMode(deliveryMode); producer.setDisableMessageID(disableMessageId); producer.setPriority(priority); } catch (JMSException e) { if (logger.isDebugEnabled()) { logger.debug("Could not save Producer property: " + e.getLocalizedMessage()); } } }
From source file:org.apache.synapse.message.store.impl.jms.JmsProducer.java
private void setJmsMessageProperties(Message message, MessageContext synCtx) { Set<String> properties = synCtx.getPropertyKeySet(); for (String prop : properties) { if (prop.startsWith(JMS_MSG_P)) { Object value = synCtx.getProperty(prop); String key = prop.substring(JMS_MSG_P.length()); try { if (value instanceof String) { message.setStringProperty(key, (String) value); } else if (value instanceof Long) { message.setLongProperty(key, (Long) value); } else if (value instanceof Integer) { message.setIntProperty(key, (Integer) value); } else if (value instanceof Boolean) { message.setBooleanProperty(key, (Boolean) value); } else if (value instanceof Double) { message.setDoubleProperty(key, (Double) value); } else if (value instanceof Float) { message.setFloatProperty(key, (Float) value); } else if (value instanceof Short) { message.setShortProperty(key, (Short) value); }//from w w w .jav a 2s.c om } catch (JMSException e) { if (logger.isDebugEnabled()) { logger.debug("Could not save Message property: " + e.getLocalizedMessage()); } } } } }
From source file:org.apache.synapse.message.store.impl.jms.JmsProducer.java
private void setTransportHeaders(Message message, MessageContext synCtx) { //Set transport headers to the message Map<?, ?> headerMap = (Map<?, ?>) ((Axis2MessageContext) synCtx).getAxis2MessageContext() .getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS); if (headerMap != null) { for (Object headerName : headerMap.keySet()) { String name = (String) headerName; Object value = headerMap.get(name); try { if (value instanceof String) { message.setStringProperty(name, (String) value); } else if (value instanceof Boolean) { message.setBooleanProperty(name, (Boolean) value); } else if (value instanceof Integer) { message.setIntProperty(name, (Integer) value); } else if (value instanceof Long) { message.setLongProperty(name, (Long) value); } else if (value instanceof Double) { message.setDoubleProperty(name, (Double) value); } else if (value instanceof Float) { message.setFloatProperty(name, (Float) value); }//from w w w .ja v a 2s.co m } catch (JMSException ex) { if (logger.isDebugEnabled()) { logger.debug("Could not save Message property: " + ex.getLocalizedMessage()); } } } } }
From source file:org.apache.synapse.message.store.impl.jms.JmsStore.java
/** * Creates a new JMS Message producer connection. * * @return true if new producer connection was successfully created, <br/> * false otherwise.//from w w w. j ava 2 s . co m */ public boolean newWriteConnection() { synchronized (producerLock) { if (producerConnection != null) { if (!closeConnection(producerConnection)) { return false; } } try { producerConnection = newConnection(); } catch (JMSException e) { logger.error(nameString() + " cannot create connection to the broker. Error:" + e.getLocalizedMessage() + ". Initial Context Factory:[" + parameters.get(NAMING_FACTORY_INITIAL) + "]; Provider URL:[" + parameters.get(PROVIDER_URL) + "]; Connection Factory:[" + connectionFactory + "]."); producerConnection = null; } } return producerConnection != null; }