title: Throw Exception if template.convertSendAndReceive consumer message handler throws exception?
body: <p>I am using spring batch and spring amqp. I am producing messages in my spring batch ItemWriter using </p>
  
  <pre><code>public class ImportItemWriter&lt;T&gt; implements ItemWriter&lt;T&gt; {
  
      private AmqpTemplate template;
  
      public AmqpTemplate getTemplate() {
          return template;
      }
  
      public void setTemplate(AmqpTemplate template) {
          this.template = template;
      }
  
      public void write(List&lt;? extends T&gt; items) throws Exception {
          for (T item : items) {
              template.convertSendAndReceive(item.toString());                
          }
      }
  
  }
  </code></pre>
  
  <p>and at consumer side, I am using POJO to handle messages using MessageListenerAdapter. </p>
  
  <pre><code>public class ImportMessageListener{
  
      @Override
      public String handle(String exchange) throws Exception {
          throw new Exception("Command Failed.");
      }
  
  }
  </code></pre>
  
  <p>I want template.convertSendAndReceive(item.toString());    to throw the same exception thrown by message handler so that spring batch can stop the batch , mark it as failed and log the exception?</p>
  
  <p>I had look at this but couldn't get how to achieve above use case ?</p>
  
  <p><a href="http://docs.spring.io/spring-amqp/docs/1.3.1.RELEASE/reference/html/amqp.html" rel="nofollow">http://docs.spring.io/spring-amqp/docs/1.3.1.RELEASE/reference/html/amqp.html</a></p>
  
  <p>How do I do this ?</p>