List of usage examples for org.springframework.jms UncategorizedJmsException UncategorizedJmsException
public UncategorizedJmsException(Throwable cause)
From source file:fr.xebia.springframework.jms.ManagedDefaultMessageListenerContainer.java
public ObjectName getObjectName() throws MalformedObjectNameException { if (objectName == null) { String destinationName = getDestinationName(); Destination destination = getDestination(); if (destinationName == null && destination != null) { try { if (destination instanceof Queue) { Queue queue = (Queue) destination; destinationName = queue.getQueueName(); } else if (destination instanceof Topic) { Topic topic = (Topic) destination; destinationName = topic.getTopicName(); }// w w w . j av a2s.c o m } catch (JMSException e) { throw new UncategorizedJmsException(e); } } objectName = ObjectName.getInstance("javax.jms:type=MessageListenerContainer,name=" + ObjectName.quote(getBeanName()) + ",destination=" + destinationName); } return objectName; }
From source file:org.apache.flink.streaming.connectors.jms.JmsQueueSink.java
@Override public void invoke(final T object) throws Exception { try {//from w ww. jav a 2 s .co m producer.send(destination, convert(object, session), Message.DEFAULT_DELIVERY_MODE, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE); } catch (JMSException e) { logger.error("Error sending message to [{}]: {}", destination.getQueueName(), e.getLocalizedMessage()); throw new UncategorizedJmsException(e); } }
From source file:org.apache.flink.streaming.connectors.jms.JmsTopicSink.java
@Override public void invoke(final T object) throws Exception { try {/*from w w w .ja va 2 s. co m*/ producer.publish(destination, convert(object, session), Message.DEFAULT_DELIVERY_MODE, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE); } catch (JMSException e) { logger.error("Error sending message to [{}]: {}", destination.getTopicName(), e.getLocalizedMessage(), e); throw new UncategorizedJmsException(e); } }
From source file:org.apache.flink.streaming.connectors.jms.JmsTopicSource.java
@Override public void run(final SourceContext<T> context) throws Exception { TopicSession session = null;//from w ww . j a v a 2 s. c om TopicSubscriber consumer = null; try { session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); consumer = session.createSubscriber(destination, messageSelector, false); connection.start(); while (isRunning) { context.collect(convert(consumer.receive())); } } catch (JMSException e) { logger.error("Error receiving message from [{}]: {}", destination.getTopicName(), e.getLocalizedMessage()); throw new UncategorizedJmsException(e); } finally { JmsUtils.closeMessageConsumer(consumer); JmsUtils.closeSession(session); } }
From source file:org.apache.flink.streaming.connectors.jms.JmsQueueSource.java
@Override public void run(final SourceContext<T> context) throws Exception { QueueSession session = null;// w w w . j ava 2s. co m QueueReceiver consumer = null; try { session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); consumer = session.createReceiver(destination, messageSelector); connection.start(); while (isRunning) { context.collect(convert(consumer.receive())); } } catch (JMSException e) { logger.error("Error receiving message from [{}]: {}", destination.getQueueName(), e.getLocalizedMessage()); throw new UncategorizedJmsException(e); } finally { JmsUtils.closeMessageConsumer(consumer); JmsUtils.closeSession(session); } }
From source file:org.apache.servicemix.jms.endpoints.JmsProviderEndpoint.java
/** * Process an InOnly or RobustInOnly exchange. * This method uses the JMS template to create a session and call the * {@link #processInOnlyInSession(javax.jbi.messaging.MessageExchange, javax.jbi.messaging.NormalizedMessage, javax.jms.Session)} * method.//from w ww . j av a2s .c o m * * @param exchange * @param in * @throws Exception */ protected void processInOnly(final MessageExchange exchange, final NormalizedMessage in) throws Exception { SessionCallback callback = new SessionCallback() { public Object doInJms(Session session) throws JMSException { try { processInOnlyInSession(exchange, in, session); return null; } catch (JMSException e) { throw e; } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new UncategorizedJmsException(e); } } }; template.execute(callback, true); }
From source file:org.apache.servicemix.jms.endpoints.JmsProviderEndpoint.java
/** * Process an InOut or InOptionalOut exchange. * This method uses the JMS template to create a session and call the * {@link #processInOutInSession(javax.jbi.messaging.MessageExchange, javax.jbi.messaging.NormalizedMessage, javax.jms.Session)} * method.//from ww w . java2 s . c o m * * @param exchange * @param in * @throws Exception */ protected void processInOut(final MessageExchange exchange, final NormalizedMessage in) throws Exception { SessionCallback callback = new SessionCallback() { public Object doInJms(Session session) throws JMSException { try { processInOutInSession(exchange, in, session); return null; } catch (JMSException e) { throw e; } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new UncategorizedJmsException(e); } } }; template.execute(callback, true); }
From source file:org.springframework.jms.support.JmsUtils.java
/** * Convert the specified checked {@link javax.jms.JMSException JMSException} to a * Spring runtime {@link org.springframework.jms.JmsException JmsException} equivalent. * @param ex the original checked JMSException to convert * @return the Spring runtime JmsException wrapping the given exception *///from ww w . ja v a 2s .co m public static JmsException convertJmsAccessException(JMSException ex) { Assert.notNull(ex, "JMSException must not be null"); if (ex instanceof javax.jms.IllegalStateException) { return new org.springframework.jms.IllegalStateException((javax.jms.IllegalStateException) ex); } if (ex instanceof javax.jms.InvalidClientIDException) { return new InvalidClientIDException((javax.jms.InvalidClientIDException) ex); } if (ex instanceof javax.jms.InvalidDestinationException) { return new InvalidDestinationException((javax.jms.InvalidDestinationException) ex); } if (ex instanceof javax.jms.InvalidSelectorException) { return new InvalidSelectorException((javax.jms.InvalidSelectorException) ex); } if (ex instanceof javax.jms.JMSSecurityException) { return new JmsSecurityException((javax.jms.JMSSecurityException) ex); } if (ex instanceof javax.jms.MessageEOFException) { return new MessageEOFException((javax.jms.MessageEOFException) ex); } if (ex instanceof javax.jms.MessageFormatException) { return new MessageFormatException((javax.jms.MessageFormatException) ex); } if (ex instanceof javax.jms.MessageNotReadableException) { return new MessageNotReadableException((javax.jms.MessageNotReadableException) ex); } if (ex instanceof javax.jms.MessageNotWriteableException) { return new MessageNotWriteableException((javax.jms.MessageNotWriteableException) ex); } if (ex instanceof javax.jms.ResourceAllocationException) { return new ResourceAllocationException((javax.jms.ResourceAllocationException) ex); } if (ex instanceof javax.jms.TransactionInProgressException) { return new TransactionInProgressException((javax.jms.TransactionInProgressException) ex); } if (ex instanceof javax.jms.TransactionRolledBackException) { return new TransactionRolledBackException((javax.jms.TransactionRolledBackException) ex); } // fallback return new UncategorizedJmsException(ex); }