title: Spring Integration IBM MQ JMS client
body: <p>I have written code to send/read message from IBM MQ using Spring Integration JMS-message-driven-channel-adapter but not able to parse the JMS text response message...below is my integration xml</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;beans xmlns="http://www.springframework.org/schema/beans"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:int="http://www.springframework.org/schema/integration"
          xmlns:int-jms="http://www.springframework.org/schema/integration/jms"
          xmlns:context="http://www.springframework.org/schema/context"
          xsi:schemaLocation="
              http://www.springframework.org/schema/beans
              http://www.springframework.org/schema/beans/spring-beans.xsd
              http://www.springframework.org/schema/context
              http://www.springframework.org/schema/context/spring-context.xsd
              http://www.springframework.org/schema/integration
              http://www.springframework.org/schema/integration/spring-integration.xsd
              http://www.springframework.org/schema/integration/jms
              http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd"&gt;
  
          &lt;context:annotation-config /&gt;
          &lt;context:component-scan base-package="com.*****" /&gt;
  
          &lt;!-- Factory Defintions --&gt;
          &lt;bean id="connectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory"&gt;
              &lt;property name="transportType" value="1" /&gt;
              &lt;property name="queueManager" value="****" /&gt;
              &lt;property name="hostName" value="******" /&gt;
              &lt;property name="port" value="****" /&gt;
              &lt;property name="channel" value="******" /&gt;
          &lt;/bean&gt;
  
          &lt;!-- Queue Definition --&gt;
          &lt;bean id="inQueue" class="com.ibm.mq.jms.MQQueue" depends-on="connectionFactory"&gt;
              &lt;constructor-arg index="0" value="****" /&gt;
              &lt;constructor-arg index="1" value="*****" /&gt;
          &lt;/bean&gt;
  
          &lt;bean id="outQueue" class="com.ibm.mq.jms.MQQueue" depends-on="connectionFactory"&gt;
              &lt;constructor-arg index="0" value="*****" /&gt;
              &lt;constructor-arg index="1" value="******" /&gt;
          &lt;/bean&gt;
  
          &lt;bean id="messageListener" class="com.***.MessageListener"/&gt;
          &lt;bean id="messagePublisher" class="com.*****.MessagePublisher"/&gt;
  
          &lt;!-- OUTBOUND settings --&gt;
  
          &lt;int:channel id="senderChannel" /&gt;
  
          &lt;int-jms:outbound-channel-adapter id="jmsOut" destination="outQueue" channel="senderChannel"/&gt;
  
         &lt;!--  &lt;int:service-activator output-channel="senderChannel" ref="messagePublisher" method="processMessage" /&gt; --&gt;
  
          &lt;!-- INBOUND settings --&gt;
  
          &lt;int:channel id="recieverChannel" /&gt;    
  
          &lt;int-jms:message-driven-channel-adapter id="jmsIn" destination="inQueue" channel="recieverChannel" extract-payload="false" /&gt;
  
          &lt;int:service-activator input-channel="recieverChannel" ref="messageListener" method="processMessage" /&gt;
  
      &lt;/beans&gt;
  </code></pre>
  
  <p>The process intends to send a message over MQ to external server and they may(or may not respond) with an ack.</p>
  
  <p>Publisher code:</p>
  
  <pre><code>import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.integration.support.MessageBuilder;
      import org.springframework.messaging.MessageChannel;
  
      public class MessagePublisher {
  
          @Autowired
          private MessageChannel senderChannel;
  
          public void processMessage(String message) {
              System.out.println("MessagePublisher::::::Sent message: " + message);
  
              senderChannel.send(MessageBuilder.withPayload(message).build());
          }
      }
  </code></pre>
  
  <p>Currently in my listener I try to print the ack as :</p>
  
  <pre><code>    import javax.jms.JMSException;
      import javax.jms.Message;
      import javax.jms.TextMessage;
  
      public class MessageListener {
  
          public void processMessage(Message message) {
  
              if (message instanceof TextMessage) {
                  TextMessage txtmsg = (TextMessage) message;
  
                  try {
  
                      System.out.println("MessageListener::::::Received message: "
                              + txtmsg.getText());
                  } catch (JMSException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
              }
          }
  </code></pre>
  
  <p>The problem is when I get the message back the body contains encoded string as:</p>
  
  <p>MessageListener::::::Received message: [prints encoded special chars here]</p>
  
  <p>How can I parse the complete response text in a proper format? I checked the instance of response object seems to be JMS text message only, but when printed on console I only see encoded string message.</p>