title: How to start RabbitMQ listener after application boot?
body: <p>Hi there i am using RabbitMQ inside my Grails application and am looking for ways on how to delay the start of the listeners. They are now started before the entire wiring of my application is done, so i would like to start them after startup.. any suggestion on how this can be done?</p>
  
  <p>I am using the xml configuration for this..</p>
  
  <pre><code>&lt;rabbit:listener-container connection-factory="connectionFactory" message converter="jsonMessageConverter" acknowledge="auto"&gt;
      &lt;rabbit:listener queue-names="log.soap.in" ref="logSoapInListener" /&gt;
  &lt;/rabbit:listener-container&gt;
  </code></pre>
  
  <p>So when my grails application starts the context is started but it takes a while when all has been wired. So during the start of my application the listener is already called but is not able to handle the messages correctly.</p>
  
  <pre><code>class LogSoapListenerService implements MessageListener {
  
      LogSoapService logSoapService
  
      JsonMapper jsonMapper
  
      @Override
      void onMessage(Message message) {
          String body = new String(message.body, message.properties.contentEncoding ?: "UTF-8")
          logSoapService.process(body)
      }
  }
  </code></pre>