List of usage examples for javax.jms JMSException getMessage
public String getMessage()
From source file:com.oneops.inductor.MessagePublisher.java
public void init() { try {/*from w w w . j a v a2 s .c o m*/ connection = connectionFactory.createConnection(); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination queue = session.createQueue(topic); regularProducer = session.createProducer(queue); priorityProducer = session.createProducer(queue); priorityProducer.setPriority(6); if (persistent) { regularProducer.setDeliveryMode(DeliveryMode.PERSISTENT); priorityProducer.setDeliveryMode(DeliveryMode.PERSISTENT); } else { regularProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); priorityProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); } if (timeToLive != 0) { regularProducer.setTimeToLive(timeToLive); priorityProducer.setTimeToLive(timeToLive); } } catch (JMSException e) { logger.error(e.getMessage()); logger.error(e.getMessage(), e); } super.init(); }
From source file:be.fedict.eid.dss.model.bean.TaskMDB.java
public void onMessage(Message message) { LOG.debug("onMessage"); String taskName;/*w w w . j a v a2 s. co m*/ try { taskName = message.getStringProperty(MailManagerBean.TASK_NAME_PROPERTY); } catch (JMSException e) { throw new RuntimeException("JMS error: " + e.getMessage(), e); } if (MailSignedDocumentTaskMessage.TASK_NAME.equals(taskName)) { MailSignedDocumentTaskMessage mailSignedDocumentTaskMessage = new MailSignedDocumentTaskMessage( message); processMailSignedDocumentTask(mailSignedDocumentTaskMessage); } else { LOG.error("unknown task: " + taskName); } }
From source file:com.cws.esolutions.agent.mq.MQMessageHandler.java
public void onMessage(final Message message) { final String methodName = MQMessageHandler.CNAME + "#onMessage(final Message message)"; if (DEBUG) {/* w w w . ja v a2 s.c o m*/ DEBUGGER.debug(methodName); DEBUGGER.debug("Message: {}", message); } final Session session = agentBean.getSession(); final MessageProducer producer = agentBean.getProducer(); final Destination destination = MQMessageHandler.agentBean.getResponseQueue(); if (DEBUG) { DEBUGGER.debug("Session: {}", session); DEBUGGER.debug("MessageProducer: {}", producer); DEBUGGER.debug("Destination: {}", destination); } try { ObjectMessage mqMessage = (ObjectMessage) message; if (DEBUG) { DEBUGGER.debug("mqMessage: {}", mqMessage); } if ((StringUtils.equals(MQMessageHandler.serverConfig.getRequestQueue(), MQMessageHandler.serverConfig.getResponseQueue())) && (mqMessage.getObject() instanceof AgentResponse)) { return; } AgentRequest agentRequest = (AgentRequest) mqMessage.getObject(); if (DEBUG) { DEBUGGER.debug("agentRequest: {}", agentRequest); } mqMessage.acknowledge(); AgentResponse agentResponse = MQMessageHandler.processor.processRequest(agentRequest); if (DEBUG) { DEBUGGER.debug("AgentResponse: {}", agentResponse); } ObjectMessage oMessage = session.createObjectMessage(true); oMessage.setObject(agentResponse); oMessage.setJMSCorrelationID(message.getJMSCorrelationID()); if (DEBUG) { DEBUGGER.debug("ObjectMessage: {}", oMessage); } producer.send(destination, oMessage); } catch (JMSException jx) { ERROR_RECORDER.error(jx.getMessage(), jx); } catch (AgentException ax) { ERROR_RECORDER.error(ax.getMessage(), ax); } }
From source file:se.inera.intyg.intygstjanst.web.service.impl.HealthCheckServiceImpl.java
private boolean checkJmsConnection() { Connection connection = null; try {/*from w w w . j a va 2 s .c om*/ connection = connectionFactory.createConnection(); connection.close(); } catch (JMSException e) { LOGGER.error("checkJMS failed with exception: " + e.getMessage()); return false; } return true; }
From source file:jenkins.plugins.logstash.persistence.ActiveMqDao.java
@Override public void push(String data) throws IOException { TopicConnection connection = null;//from ww w . j av a 2 s . co m Session session = null; try { // Create a Connection connection = connectionFactory.createTopicConnection(); connection.start(); // Create a Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); // Create the destination Queue Destination destination = session.createTopic(key); // Create the MessageProducer from the Session to the Queue MessageProducer producer = session.createProducer(destination); producer.setDeliveryMode(DeliveryMode.PERSISTENT); // Create the message TextMessage message = session.createTextMessage(data); message.setJMSType("application/json"); // Tell the producer to send the message producer.send(message); //logger.log( Level.FINER, String.format("JMS message sent with ID [%s]", message.getJMSMessageID())); } catch (JMSException e) { logger.log(Level.SEVERE, null != e.getMessage() ? e.getMessage() : e.getClass().getName()); throw new IOException(e); } finally { // Clean up try { if (null != session) session.close(); } catch (JMSException e) { logger.log(Level.WARNING, null != e.getMessage() ? e.getMessage() : e.getClass().getName()); } try { if (null != connection) connection.close(); } catch (JMSException e) { logger.log(Level.WARNING, null != e.getMessage() ? e.getMessage() : e.getClass().getName()); } } }
From source file:org.wso2.carbon.integration.test.client.JMSConsumerClient.java
public void run() { // create topic connection TopicConnection topicConnection = null; try {/*from w ww.j a v a 2 s . com*/ 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) { messageCount++; 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)); } preservedEventList.add(map); log.info("Received Map Message : \n" + map + "\n"); } else if (message instanceof TextMessage) { String textMessage = ((TextMessage) message).getText(); preservedEventList.add(textMessage); log.info("Received Text Message : \n" + textMessage + "\n"); } else { preservedEventList.add(message.toString()); log.info("Received message : \n" + message.toString() + "\n"); } } } 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.hoteia.qalingo.core.jms.geoloc.listener.AddressGeolocQueueListener.java
/** * Implementation of <code>MessageListener</code>. *//* w ww.ja va2 s . com*/ public void onMessage(Message message) { try { if (message instanceof TextMessage) { TextMessage tm = (TextMessage) message; String valueJMSMessage = tm.getText(); if (StringUtils.isNotEmpty(valueJMSMessage)) { final AddressGeolocMessageJms documentMessageJms = xmlMapper.getXmlMapper() .readValue(valueJMSMessage, AddressGeolocMessageJms.class); String address = documentMessageJms.getAddress(); String postalCode = documentMessageJms.getPostalCode(); String city = documentMessageJms.getCity(); String countryCode = documentMessageJms.getCountryCode(); String formatedAddress = geolocService.encodeGoogleAddress(address, postalCode, city, countryCode); if ("Store".equals(documentMessageJms.getObjectType())) { final Store store = retailerService.getStoreById(documentMessageJms.getObjectId()); if (store != null && StringUtils.isEmpty(store.getLatitude())) { GeolocAddress geolocAddress = geolocService .getGeolocAddressByFormatedAddress(formatedAddress); if (geolocAddress != null && StringUtils.isNotEmpty(geolocAddress.getLatitude()) && StringUtils.isNotEmpty(geolocAddress.getLongitude())) { store.setLatitude(geolocAddress.getLatitude()); store.setLongitude(geolocAddress.getLongitude()); retailerService.saveOrUpdateStore(store); } else { // LATITUDE/LONGITUDE DOESN'T EXIST - WE USE GOOGLE GEOLOC TO FOUND IT geolocAddress = geolocService.geolocByAddress(address, postalCode, city, countryCode); if (geolocAddress != null && StringUtils.isNotEmpty(geolocAddress.getLatitude()) && StringUtils.isNotEmpty(geolocAddress.getLongitude())) { store.setLatitude(geolocAddress.getLatitude()); store.setLongitude(geolocAddress.getLongitude()); retailerService.saveOrUpdateStore(store); } } } } else if ("Retailer".equals(documentMessageJms.getObjectType())) { final Retailer retailer = retailerService.getRetailerById(documentMessageJms.getObjectId(), new FetchPlan(retailerFetchPlans)); RetailerAddress retailerAddress = retailer.getAddressByValue(address); if (retailer != null && retailerAddress != null && StringUtils.isEmpty(retailerAddress.getLatitude())) { GeolocAddress geolocAddress = geolocService .getGeolocAddressByFormatedAddress(formatedAddress); if (geolocAddress != null && StringUtils.isNotEmpty(geolocAddress.getLatitude()) && StringUtils.isNotEmpty(geolocAddress.getLongitude())) { retailerAddress.setLatitude(geolocAddress.getLatitude()); retailerAddress.setLongitude(geolocAddress.getLongitude()); retailerService.saveOrUpdateRetailer(retailer); } else { // LATITUDE/LONGITUDE DOESN'T EXIST - WE USE GOOGLE GEOLOC TO FOUND IT geolocAddress = geolocService.geolocByAddress(address, postalCode, city, countryCode); if (geolocAddress != null && StringUtils.isNotEmpty(geolocAddress.getLatitude()) && StringUtils.isNotEmpty(geolocAddress.getLongitude())) { retailerAddress.setLatitude(geolocAddress.getLatitude()); retailerAddress.setLongitude(geolocAddress.getLongitude()); retailerService.saveOrUpdateRetailer(retailer); } } } } if (logger.isDebugEnabled()) { logger.debug("Processed message, value: " + valueJMSMessage); } } else { logger.warn("Document generation: Jms Message is empty"); } } } catch (JMSException e) { logger.error(e.getMessage(), e); } catch (IOException e) { logger.error(e.getMessage(), e); } }
From source file:org.apache.qpid.multiconsumer.AMQTest.java
/** * @see javax.jms.ExceptionListener#onException(javax.jms.JMSException) *//*from ww w . j av a2 s. c o m*/ public void onException(JMSException e) { System.err.println(e.getMessage()); e.printStackTrace(System.err); }
From source file:org.apache.qpid.server.security.auth.manager.ExternalAuthenticationTest.java
/** * Tests that when EXTERNAL authentication is used on the SSL port, clients presenting certificates are able to connect. * Also, checks that default authentication manager PrincipalDatabaseAuthenticationManager is used on non SSL port. *//*from ww w . j a v a 2s .c om*/ public void testExternalAuthenticationManagerOnSSLPort() throws Exception { setCommonBrokerSSLProperties(true); getBrokerConfiguration().setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_SSL_PORT, Port.AUTHENTICATION_MANAGER, TestBrokerConfiguration.ENTRY_NAME_EXTERNAL_PROVIDER); super.setUp(); setClientKeystoreProperties(); setClientTrustoreProperties(); try { getExternalSSLConnection(false); } catch (JMSException e) { fail("Should be able to create a connection to the SSL port: " + e.getMessage()); } try { getConnection(); } catch (JMSException e) { fail("Should be able to create a connection with credentials to the standard port: " + e.getMessage()); } }
From source file:edu.biu.scapi.comm.twoPartyComm.QueueCommunicationSetup.java
@Override public void close() { try {/*from w ww. j a v a 2s. co m*/ //Close the JMS connection. connection.close(); } catch (JMSException e) { throw new edu.biu.scapi.exceptions.JMSException(e.getMessage()); } }