title: Could not refresh JMS Connection for destination
body: <p>I have a web application which runs on apache/PHP. In PHP, I have an activeMQ producer which writes some data into the queue. I'm using stomp client for this. For consumer, I'm using JMS + spring. I'm able to write the messages in PHP (i.e from producer). But while reading from my JMS consumer, I'm getting <code>Could not refresh JMS Connection for destination - retrying in 5000 ms. Cause: Wire format negotiation timeout: peer did not send his wire format</code>.</p>
  
  <p>Here is my applicationContext.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:tx="http://www.springframework.org/schema/tx"
     xmlns:p="http://www.springframework.org/schema/p"
     xmlns:context="http://www.springframework.org/schema/context"
     xmlns:jms="http://www.springframework.org/schema/jms"
     xmlns:amq="http://activemq.apache.org/schema/core"
     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
     http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd
     http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"&gt;
  
  &lt;context:annotation-config/&gt;
  &lt;context:component-scan base-package="test"/&gt;
  
  &lt;amq:connectionFactory id="jmsFactory" brokerURL="tcp://localhost:61613" /&gt;
  
  &lt;bean id="jmsConsumerConnectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory"
    p:targetConnectionFactory-ref="jmsFactory"/&gt;
  
  &lt;jms:listener-container container-type="default" 
                          connection-factory="jmsConsumerConnectionFactory&gt;
      &lt;jms:listener destination="/topic/event" ref="jmsMessageListener" /&gt;
  &lt;/jms:listener-container&gt;
  
  &lt;amq:queue id="destination" physicalName="/topic/event"/&gt; 
  &lt;/beans&gt;
  </code></pre>
  
  <p>Here is my message listener:</p>
  
  <pre><code>package test;
  
  import javax.jms.Message;
  import javax.jms.MessageListener;
  import org.springframework.stereotype.Component;
  
  @Component
  public class JmsMessageListener implements MessageListener {
  
    @Override
    public void onMessage(Message message) {
      System.out.println("msg recvd!");
    }
  
  }
  </code></pre>
  
  <p>There was an example java program that came as part of apache activemq stomp examples which works fine. Here is the example:</p>
  
  <pre><code>package example;
  
  import org.fusesource.stomp.jms.*;
  import javax.jms.*;
  
  class Listener {
  
      public static void main(String []args) throws JMSException {
  
          String user = env("ACTIVEMQ_USER", "admin");
          String password = env("ACTIVEMQ_PASSWORD", "password");
          String host = env("ACTIVEMQ_HOST", "localhost");
          int port = Integer.parseInt(env("ACTIVEMQ_PORT", "61613"));
          String destination = arg(args, 0, "/topic/event");
  
          StompJmsConnectionFactory factory = new StompJmsConnectionFactory();
          factory.setBrokerURI("tcp://" + host + ":" + port);
  
          Connection connection = factory.createConnection(user, password);
          connection.start();
          Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
          Destination dest = new StompJmsDestination(destination);
  
          MessageConsumer consumer = session.createConsumer(dest);
          long start = System.currentTimeMillis();
          long count = 1;
          System.out.println("Waiting for messages...");
      }
  }
  </code></pre>
  
  <p>I read it in a forum that it it may happen when producer writes to a topic instead of a queue. If so, how do I handle it in spring?</p>