title: Spring How to Limit number of retry in Message listener
body: <p>I am using spring DefaultJmsListenerContainerFactory and annotation @JmsListener(destination="test.dev.1") to listen the message on a queue. I have set acknowledge mode to Session.CLIENT_ACKNOWLEDGE so if any exception occurs during message processing then message is redelivered. However i want to limit the number of times message is redelivered (retry)? how can i do that?</p>
  
  <p>Here is my code for DefaultJmsListenerContainerFactory:</p>
  
  <pre><code>    @Bean
  public DefaultJmsListenerContainerFactory jmsListenerContainerFactory () {
      DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
      factory.setConnectionFactory(jmsConnectionFactory());
      factory.setConcurrency("1");
      factory.setSessionAcknowledgeMode(Session.CLIENT_ACKNOWLEDGE);
  
      return factory;
  }
  </code></pre>