title: How to configure dynamic reply topic in Spring JMS
body: <p>I'm using JmsMessageSender inside WebServiceTemplate for Spring-WS communication over JMS. I have to work on topics, so I used <a href="http://docs.spring.io/spring/docs/2.5.x/javadoc-api/org/springframework/jms/support/destination/JmsDestinationAccessor.html?is-external=true#setPubSubDomain(boolean)" rel="nofollow noreferrer">setPubSubDomain</a> method of JmsMessageSender's superclass, and the messages go correctly on target topic. However, the for handling response, a temporary queue is created, <strong>not topic</strong>. How can I setup spring beans to have temporary topic for the response, not queue?</p>
  
  <p>To add one hint, there is a <a href="http://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/jms/listener/AbstractMessageListenerContainer.html#setReplyPubSubDomain-boolean-" rel="nofollow noreferrer">setReplyPubSubDomain</a> method of AbstractMessageListenerContainer class, which looks exactly what I need, but I have never used this listener container and I'm not sure how could I wrap it into my beans.</p>
  
  <p>My configuration below:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Bean
  public WebServiceTemplate webServiceTemplate() {
      WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
      webServiceTemplate.setMessageFactory(messageFactory());
      webServiceTemplate.setMessageSender(messageSender());
      webServiceTemplate.setDefaultUri("jms:topicname.topicname.topicname?priority=3&amp;deliveryMode=NON_PERSISTENT&amp;messageType=TEXT_MESSAGE");
      return webServiceTemplate;
  }
  
  @Bean
  public JmsMessageSender messageSender() {
      JmsMessageSender messageSender = new JmsMessageSender();
      messageSender.setConnectionFactory(connectionFactory());
      messageSender.setPubSubDomain(true);
      return messageSender;
  }
  </code></pre>