List of usage examples for javax.jms JMSException getMessage
public String getMessage()
From source file:org.wso2.carbon.inbound.endpoint.protocol.jms.factory.CachedJMSConnectionFactory.java
public Connection getConnection(String userName, String password) { Connection connection;// ww w. ja v a 2s .c o m if (cachedConnection == null) { connection = createConnection(userName, password); } else { connection = cachedConnection; } if (connection == null) { return null; } try { connection.start(); } catch (JMSException e) { logger.error("JMS Exception while starting connection for factory '" + this.connectionFactoryString + "' " + e.getMessage()); resetCache(); } return connection; }
From source file:com.cws.esolutions.agent.AgentDaemon.java
public void start() { final String methodName = AgentDaemon.CNAME + "#start()"; if (DEBUG) {/*w ww .j a v a 2s.c om*/ DEBUGGER.debug(methodName); } try { this.connFactory = new ActiveMQConnectionFactory( AgentDaemon.agentBean.getConfigData().getServerConfig().getConnectionName()); if (DEBUG) { DEBUGGER.debug("ConnectionFactory: {}", this.connFactory); } this.conn = this.connFactory.createConnection( AgentDaemon.agentBean.getConfigData().getServerConfig().getUsername(), PasswordUtils.decryptText(AgentDaemon.agentBean.getConfigData().getServerConfig().getPassword(), AgentDaemon.agentBean.getConfigData().getServerConfig().getSalt(), AgentDaemon.agentBean.getConfigData().getServerConfig().getEncryptionAlgorithm(), AgentDaemon.agentBean.getConfigData().getServerConfig().getIterations(), AgentDaemon.agentBean.getConfigData().getServerConfig().getKeyBits(), AgentDaemon.agentBean.getConfigData().getServerConfig().getEncryptionAlgorithm(), AgentDaemon.agentBean.getConfigData().getServerConfig().getEncryptionInstance(), AgentDaemon.agentBean.getConfigData().getServerConfig().getEncoding())); this.conn.setExceptionListener(new MQExceptionHandler()); this.conn.setClientID(AgentDaemon.agentBean.getConfigData().getServerConfig().getClientId()); this.conn.start(); if (DEBUG) { DEBUGGER.debug("Connection: {}", this.conn); } this.session = this.conn.createSession(false, Session.AUTO_ACKNOWLEDGE); if (DEBUG) { DEBUGGER.debug("Session: {}", this.session); } this.request = this.session .createTopic(AgentDaemon.agentBean.getConfigData().getServerConfig().getRequestQueue()); this.response = this.session .createQueue(AgentDaemon.agentBean.getConfigData().getServerConfig().getResponseQueue()); if (DEBUG) { DEBUGGER.debug("Destination: {}", this.request); DEBUGGER.debug("Destination: {}", this.response); } this.consumer = this.session.createConsumer(this.request, "targetHost='" + AgentDaemon.agentBean.getHostName() + "'"); this.consumer.setMessageListener(new MQMessageHandler()); if (DEBUG) { DEBUGGER.debug("MessageConsumer: {}", this.consumer); } this.producer = this.session.createProducer(this.response); if (DEBUG) { DEBUGGER.debug("MessageProducer: {}", this.producer); } AgentDaemon.agentBean.setResponseQueue(this.response); AgentDaemon.agentBean.setSession(this.session); AgentDaemon.agentBean.setProducer(this.producer); } catch (SecurityException sx) { ERROR_RECORDER.error(sx.getMessage(), sx); this.exitCode = 1; stop(); } catch (JMSException jx) { ERROR_RECORDER.error(jx.getMessage(), jx); this.exitCode = 1; stop(); } }
From source file:org.wso2.carbon.event.core.internal.delivery.jms.JMSDeliveryManager.java
public void publish(Message message, String topicName, int deliveryMode) throws EventBrokerException { if (isDeactivated()) { return;/* www . j a v a2 s . c o m*/ } try { String userName = getLoggedInUserName(); if ((userName == null) || (userName.equals(""))) { // use the system user name userName = CarbonConstants.REGISTRY_SYSTEM_USERNAME; } TopicConnection topicConnection = getTopicConnection(userName); TopicSession topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); String tenantDomain = EventBrokerHolder.getInstance().getTenantDomain(); if (tenantDomain != null && (!tenantDomain.equals(org.wso2.carbon.base.MultitenantConstants.SUPER_TENANT_DOMAIN_NAME))) { if (!topicName.startsWith("/")) { topicName = getTopicName(tenantDomain + "/" + topicName); } else { topicName = getTopicName(tenantDomain + topicName); } } else { topicName = getTopicName(topicName); } Topic topic = topicSession.createTopic(topicName); //Some times we are not getting the proper topic with the required syntax, if it is not //appropriate we need to check and add the BURL syntax to fix the issue https://wso2.org/jira/browse/MB-185 if (!topic.toString().startsWith("topic://amq.topic")) { topic = topicSession.createTopic("BURL:" + topicName); } TopicPublisher topicPublisher = topicSession.createPublisher(topic); topicPublisher.setDeliveryMode(deliveryMode); TextMessage textMessage = topicSession.createTextMessage(message.getMessage().toString()); Map<String, String> properties = message.getProperties(); for (String key : properties.keySet()) { textMessage.setStringProperty(key, properties.get(key)); } // saving the domain to be used send with the soap header if (CarbonContext.getThreadLocalCarbonContext().getTenantDomain() != null) { textMessage.setStringProperty(MultitenantConstants.TENANT_DOMAIN_HEADER_NAME, CarbonContext.getThreadLocalCarbonContext().getTenantDomain()); } topicPublisher.publish(textMessage); topicPublisher.close(); topicSession.close(); topicConnection.stop(); topicConnection.close(); } catch (JMSException e) { throw new EventBrokerException("Can not publish to topic " + topicName + " " + e.getMessage(), e); } }
From source file:be.fedict.trust.service.bean.DownloaderMDB.java
public void onMessage(Message message) { LOG.debug("onMessage"); DownloadMessage downloadMessage = null; ColdStartMessage coldStartMessage = null; try {/*from ww w .ja v a 2s .c o m*/ String messageType = message.getStringProperty(JMSMessage.MESSAGE_TYPE_PROPERTY); if (messageType.equals(DownloadMessage.class.getSimpleName())) { downloadMessage = new DownloadMessage(message); } else if (messageType.equals(ColdStartMessage.class.getSimpleName())) { coldStartMessage = new ColdStartMessage(message); } } catch (JMSException e) { LOG.error("JMS error: " + e.getMessage(), e); return; } processDownloadMessage(downloadMessage); processColdStartMessage(coldStartMessage); }
From source file:org.wso2.carbon.event.output.adapter.jms.internal.util.JMSMessageSender.java
/** * Perform actual send of JMS message to the Destination selected *//*from ww w . j a v a 2 s .com*/ public void send(Object message, JMSEventAdapter.PublisherDetails publisherDetails, String jmsHeaders) { Map<String, String> messageProperties = publisherDetails.getMessageConfig(); Boolean jtaCommit = getBooleanProperty(messageProperties, BaseConstants.JTA_COMMIT_AFTER_SEND); Boolean rollbackOnly = getBooleanProperty(messageProperties, BaseConstants.SET_ROLLBACK_ONLY); Boolean persistent = getBooleanProperty(messageProperties, JMSConstants.JMS_DELIVERY_MODE); Integer priority = getIntegerProperty(messageProperties, JMSConstants.JMS_PRIORITY); Integer timeToLive = getIntegerProperty(messageProperties, JMSConstants.JMS_TIME_TO_LIVE); MessageProducer producer = null; Destination destination = null; Session session = null; boolean sendingSuccessful = false; JMSConnectionFactory.JMSPooledConnectionHolder pooledConnection = null; try { pooledConnection = jmsConnectionFactory.getConnectionFromPool(); producer = pooledConnection.getProducer(); session = pooledConnection.getSession(); Message jmsMessage = convertToJMSMessage(message, publisherDetails.getMessageConfig(), session); setJMSTransportHeaders(jmsMessage, jmsHeaders); // Do not commit, if message is marked for rollback if (rollbackOnly != null && rollbackOnly) { jtaCommit = Boolean.FALSE; } if (persistent != null) { try { producer.setDeliveryMode(DeliveryMode.PERSISTENT); } catch (JMSException e) { handleConnectionException("Error setting JMS Producer for PERSISTENT delivery", e); } } if (priority != null) { try { producer.setPriority(priority); } catch (JMSException e) { handleConnectionException("Error setting JMS Producer priority to : " + priority, e); } } if (timeToLive != null) { try { producer.setTimeToLive(timeToLive); } catch (JMSException e) { handleConnectionException("Error setting JMS Producer TTL to : " + timeToLive, e); } } // perform actual message sending // try { if (jmsSpec11 || isQueue == null) { producer.send(jmsMessage); } else { if (isQueue) { ((QueueSender) producer).send(jmsMessage); } else { ((TopicPublisher) producer).publish(jmsMessage); } } sendingSuccessful = true; if (log.isDebugEnabled()) { // // set the actual MessageID to the message context for use by any others down the line String msgId = null; try { msgId = jmsMessage.getJMSMessageID(); } catch (JMSException jmse) { log.error(jmse.getMessage(), jmse); } log.debug(" with JMS Message ID : " + msgId + " to destination : " + producer.getDestination()); } } catch (JMSException e) { handleConnectionException("Error sending message to destination : " + destination, e); } catch (Exception e) { log.error(e.getMessage(), e); } finally { if (jtaCommit != null) { try { if (session.getTransacted()) { if (sendingSuccessful && (rollbackOnly == null || !rollbackOnly)) { session.commit(); } else { session.rollback(); } } if (log.isDebugEnabled()) { log.debug((sendingSuccessful ? "Committed" : "Rolled back") + " local (JMS Session) Transaction"); } } catch (Exception e) { handleConnectionException("Error committing/rolling back local (i.e. session) " + "transaction after sending of message "//with MessageContext ID : " + + " to destination : " + destination, e); } } if (pooledConnection != null) { jmsConnectionFactory.returnPooledConnection(pooledConnection); } } }
From source file:com.npower.dm.multiplexor.Multiplexor.java
public void onMessage(Message jmsMsg) { try {/*from w w w . j a v a 2 s .c om*/ String from = jmsMsg.getStringProperty(JmsSmsReceiverImpl.PROPERTY_DEVICE_MSISDN_NAME); String to = jmsMsg.getStringProperty(JmsSmsReceiverImpl.PROPERTY_DEVICE_SERVICE_CODE); String msgText = jmsMsg.getStringProperty(JmsSmsReceiverImpl.PROPERTY_TEXT_MESSAGE); byte[] msgBytes = HelperUtil .hexStringToBytes(jmsMsg.getStringProperty(JmsSmsReceiverImpl.PROPERTY_RAW_MESSAGE)); if (log.isDebugEnabled()) { log.debug("Incoming msg, [from: " + from + ", to: " + to + ", text=" + msgText + "]"); } this.dispatch(from, to, msgBytes, msgText); } catch (JMSException e) { log.error("Failure to dispatch a incoming message.", e); } catch (TargetQueueNotFoundException e) { log.error(e.getMessage()); log.info("Could not found target queue, message has been discarded!"); } catch (Exception e) { log.error("Failure to dispatch a incoming message.", e); } }
From source file:org.logicblaze.lingo.cache.impl.JmsClusteredCacheManagerFactory.java
public JmsProxyFactoryBean getFactoryBean() { if (factoryBean == null) { factoryBean = createFactoryBean(); try {/* ww w . ja v a 2 s . c o m*/ factoryBean.afterPropertiesSet(); } catch (JMSException e) { throw new RemoteProxyFailureException("Failed to create JmsProxyFactoryBean: " + e.getMessage(), e); } } return factoryBean; }
From source file:be.fedict.trust.service.bean.HarvesterMDB.java
@SNMP(oid = SnmpConstants.CACHE_REFRESH) public void onMessage(Message message) { LOG.debug("onMessage"); HarvestMessage harvestMessage = null; RemoveCAMessage removeCAMessage = null; try {// www .j ava2 s . c o m String messageType = message.getStringProperty(JMSMessage.MESSAGE_TYPE_PROPERTY); if (messageType.equals(HarvestMessage.class.getSimpleName())) { harvestMessage = new HarvestMessage(message); } else if (messageType.equals(RemoveCAMessage.class.getSimpleName())) { removeCAMessage = new RemoveCAMessage(message); } } catch (JMSException e) { LOG.error("JMS error: " + e.getMessage(), e); return; } processHarvestMessage(harvestMessage); processRemoveCAMessage(removeCAMessage); }
From source file:Vendor.java
public void run() { ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(user, password, url); Session session = null;//w w w . j av a2 s . c o m Destination orderQueue; Destination monitorOrderQueue; Destination storageOrderQueue; TemporaryQueue vendorConfirmQueue; MessageConsumer orderConsumer = null; MessageProducer monitorProducer = null; MessageProducer storageProducer = null; try { Connection connection = connectionFactory.createConnection(); session = connection.createSession(true, Session.SESSION_TRANSACTED); orderQueue = session.createQueue("VendorOrderQueue"); monitorOrderQueue = session.createQueue("MonitorOrderQueue"); storageOrderQueue = session.createQueue("StorageOrderQueue"); orderConsumer = session.createConsumer(orderQueue); monitorProducer = session.createProducer(monitorOrderQueue); storageProducer = session.createProducer(storageOrderQueue); Connection asyncconnection = connectionFactory.createConnection(); asyncSession = asyncconnection.createSession(true, Session.SESSION_TRANSACTED); vendorConfirmQueue = asyncSession.createTemporaryQueue(); MessageConsumer confirmConsumer = asyncSession.createConsumer(vendorConfirmQueue); confirmConsumer.setMessageListener(this); asyncconnection.start(); connection.start(); while (true) { Order order = null; try { Message inMessage = orderConsumer.receive(); MapMessage message; if (inMessage instanceof MapMessage) { message = (MapMessage) inMessage; } else { // end of stream Message outMessage = session.createMessage(); outMessage.setJMSReplyTo(vendorConfirmQueue); monitorProducer.send(outMessage); storageProducer.send(outMessage); session.commit(); break; } // Randomly throw an exception in here to simulate a Database error // and trigger a rollback of the transaction if (new Random().nextInt(3) == 0) { throw new JMSException("Simulated Database Error."); } order = new Order(message); MapMessage orderMessage = session.createMapMessage(); orderMessage.setJMSReplyTo(vendorConfirmQueue); orderMessage.setInt("VendorOrderNumber", order.getOrderNumber()); int quantity = message.getInt("Quantity"); System.out.println("Vendor: Retailer ordered " + quantity + " " + message.getString("Item")); orderMessage.setInt("Quantity", quantity); orderMessage.setString("Item", "Monitor"); monitorProducer.send(orderMessage); System.out.println("Vendor: ordered " + quantity + " Monitor(s)"); orderMessage.setString("Item", "HardDrive"); storageProducer.send(orderMessage); System.out.println("Vendor: ordered " + quantity + " Hard Drive(s)"); session.commit(); System.out.println("Vendor: Comitted Transaction 1"); } catch (JMSException e) { System.out.println("Vendor: JMSException Occured: " + e.getMessage()); e.printStackTrace(); session.rollback(); System.out.println("Vendor: Rolled Back Transaction."); } } synchronized (supplierLock) { while (numSuppliers > 0) { try { supplierLock.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } } connection.close(); asyncconnection.close(); } catch (JMSException e) { e.printStackTrace(); } }
From source file:org.wso2.carbon.event.core.internal.delivery.jms.JMSDeliveryManager.java
public void subscribe(Subscription subscription) throws EventBrokerException { if (isDeactivated()) { return;//www .j a va 2s . c o m } // in a multi tenant envirionment deployment synchronizer may creates subscriptions before // the event observer get activated. if (this.subscriptionIDSessionDetailsMap.containsKey(subscription.getId())) { log.warn( "There is an subscription already exists for the subscription with id " + subscription.getId()); return; } JMSMessageListener jmsMessageListener = new JMSMessageListener(this.notificationManager, subscription); try { TopicConnection topicConnection = getTopicConnection(subscription.getOwner()); TopicSession topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); String topicName = ""; if (subscription.getTenantDomain() != null && (!subscription.getTenantDomain() .equals(org.wso2.carbon.base.MultitenantConstants.SUPER_TENANT_DOMAIN_NAME))) { if (!subscription.getTopicName().startsWith("/")) { topicName = getTopicName(subscription.getTenantDomain() + "/" + subscription.getTopicName()); } else { topicName = getTopicName(subscription.getTenantDomain() + subscription.getTopicName()); } } else { topicName = getTopicName(subscription.getTopicName()); } Topic topic = topicSession.createTopic(topicName); //Some times we are not getting the proper topic with the required syntax, if it is not //appropriate we need to check and add the BURL syntax to fix the issue https://wso2.org/jira/browse/MB-185 if (!topic.toString().startsWith("topic://amq.topic")) { topic = topicSession.createTopic("BURL:" + topicName); } TopicSubscriber topicSubscriber = topicSession.createDurableSubscriber(topic, subscription.getId()); topicSubscriber.setMessageListener(jmsMessageListener); this.subscriptionIDSessionDetailsMap.put(subscription.getId(), new JMSSubscriptionDetails(topicSubscriber, topicSession, topicConnection)); } catch (JMSException e) { throw new EventBrokerException( "Can not subscribe to topic " + subscription.getTopicName() + " " + e.getMessage(), e); } }