title: Spring RabbitMQ - using manual channel acknowledgement on a service with @RabbitListener configuration
body: <p>How to acknowledge the messages manually without using auto acknowledgement. 
  Is there a way to use this along with the <code>@RabbitListener</code> and <code>@EnableRabbit</code> style of configuration. 
  Most of the documentation tells us to use <code>SimpleMessageListenerContainer</code> along with <code>ChannelAwareMessageListener</code>. 
  However using that we lose the flexibility that is provided with the annotations. 
  I have configured my service as below :</p>
  
  <pre><code>@Service
  public class EventReceiver {
  
  @Autowired
  private MessageSender messageSender;
  
  @RabbitListener(queues = "${eventqueue}")
  public void receiveMessage(Order order) throws Exception {
  
    // code for processing order
  }
  </code></pre>
  
  <hr>
  
  <h2>My RabbitConfiguration is as below</h2>
  
  <pre><code>@EnableRabbit
  public class RabbitApplication implements RabbitListenerConfigurer {
  
  public static void main(String[] args) {
      SpringApplication.run(RabbitApplication.class, args);
  }
  
  @Bean
  
  
  public MappingJackson2MessageConverter jackson2Converter() {
          MappingJackson2MessageConverter converter = new  MappingJackson2MessageConverter();
          return converter;
      @Bean
  public SimpleRabbitListenerContainerFactory myRabbitListenerContainerFactory() {
        SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
        factory.setConnectionFactory(rabbitConnectionFactory());
        factory.setMaxConcurrentConsumers(5);
        factory.setMessageConverter((MessageConverter) jackson2Converter());
        factory.setAcknowledgeMode(AcknowledgeMode.MANUAL);
        return factory;
      }
  
  @Bean
  public ConnectionFactory rabbitConnectionFactory() {
      CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
      connectionFactory.setHost("localhost");
      return connectionFactory;
  }
  
  @Override
  public void configureRabbitListeners(RabbitListenerEndpointRegistrar registrar) {
      registrar.setContainerFactory(myRabbitListenerContainerFactory());
  }
  
  @Autowired
  private EventReceiver receiver;
  }
  }
  </code></pre>
  
  <p>Any help will be appreciated on how to adapt manual channel acknowledgement along with the above style of configuration.
  If we implement the ChannelAwareMessageListener then the onMessage signature will change. 
  Can we implement ChannelAwareMessageListener on a service ?</p>