Source:
public void start() { simpleMessageListenerContainer = createListenerContainer(RECEIVE, new MessageListener() { @Override public void onMessage(Message message) { LOGGER.trace("JMS-message recieved. Checking if the type is supported"); if (!(message instanceof TextMessage)) { LOGGER.debug("Received JMS-message is not type of text message."); return; } LOGGER.trace("Received a text message and start parsing"); TextMessage textMessage = (TextMessage) message; String textContent = extractTextFromMessage(textMessage); HashMap<String, Object> metadata = new HashMap<String, Object>(); String result = null; try { LOGGER.debug("starting filterchain for incoming message"); result = (String) getFilterChainToUse().filter(textContent, metadata); } catch (Exception e) { LOGGER.error("an error occured when processing the filterchain", e); result = ExceptionUtils.getStackTrace(e); } Destination replyQueue; final String correlationID; try { correlationID = message.getJMSCorrelationID(); replyQueue = message.getJMSReplyTo(); } catch (JMSException e) { LOGGER.error("error when getting destination queue or correlationid from client message: {}", e); return; } if (replyQueue == null) { LOGGER.error("no replyTo destination specifyed could not send response"); return; } new JmsTemplate(connectionFactory).convertAndSend(replyQueue, result, new MessagePostProcessor() { @Override public Message postProcessMessage(Message message) throws JMSException { message.setJMSCorrelationID(correlationID); return message; } }); } private String extractTextFromMessage(TextMessage textMessage) { try { return textMessage.getText(); } catch (JMSException e) { throw new IllegalStateException("Couldn't extract text from jms message", e); } } }); simpleMessageListenerContainer.start(); }

Target:
public void start() { simpleMessageListenerContainer = createListenerContainer(receive, new MessageListener() { @Override public void onMessage(Message message) { LOGGER.trace("JMS-message recieved. Checking if the type is supported"); if (!(message instanceof TextMessage)) { LOGGER.debug("Received JMS-message is not type of text message."); return; } LOGGER.trace("Received a text message and start parsing"); TextMessage textMessage = (TextMessage) message; String textContent = extractTextFromMessage(textMessage); HashMap<String, Object> metadata = new HashMap<String, Object>(); String result = null; try { LOGGER.debug("starting filterchain for incoming message"); result = (String) getFilterChainToUse().filter(textContent, metadata); } catch (Exception e) { LOGGER.error("an error occured when processing the filterchain", e); result = ExceptionUtils.getStackTrace(e); } Destination replyQueue; final String correlationID; try { if (message.getJMSCorrelationID() == null) { correlationID = message.getJMSMessageID(); } else { correlationID = message.getJMSCorrelationID(); } replyQueue = message.getJMSReplyTo(); } catch (JMSException e) { LOGGER.warn("error when getting destination queue or correlationid from client message: {}", e); return; } if (replyQueue == null) { LOGGER.warn("no replyTo destination specifyed could not send response"); return; } new JmsTemplate(connectionFactory).convertAndSend(replyQueue, result, new MessagePostProcessor() { @Override public Message postProcessMessage(Message message) throws JMSException { message.setJMSCorrelationID(correlationID); return message; } }); } private String extractTextFromMessage(TextMessage textMessage) { try { return textMessage.getText(); } catch (JMSException e) { throw new IllegalStateException("Couldn't extract text from jms message", e); } } }); simpleMessageListenerContainer.start(); }