Results 1 to 3 of 3

Thread: AMQP inbound channel adapter won't start when queue doesn't already exist

  1. #1
    Join Date
    Nov 2009
    Location
    Montreal, Quebec
    Posts
    398

    Default AMQP inbound channel adapter won't start when queue doesn't already exist

    In my application, I have an AMQP inbound channel adapter that listens to a single queue on a RabbitMQ server. The queue gets data from a different system all together. When RabbitMQ is restarted, the queue is destroyed, which is fine. The problem is that my application doesn't automatically declare the queue upon startup. I assumed having declared the queue using the rabbit namespace in my config, the queue would get created during startup, but that doesn't seem to be the case.

    The other system that publishes data to the queue doesn't use Spring at all. It just uses a basic RabbitMQ client setup which declares the queue in code. As soon as I publish something to the queue from that remote system, then my consuming application works fine. I just need to be able to have the queue created (if possible) by my consuming application if it doesn't already exist.

    This is my Spring Integration config.
    Code:
    <int-amqp:inbound-channel-adapter
    	channel="queuedDocketNumberChannel"
    	queue-names="${amqp.getCompanyQueue}"
    	error-channel="errorChannel"/>
    	
    <service-activator input-channel="queuedDocketNumberChannel" ref="queuedDocketNumberServiceActivator"/>
    	
    <rabbit:connection-factory id="rabbitConnectionFactory" host="${amqp.host}"/>
    	
    <rabbit:queue name="${amqp.getCompanyQueue}"/>
    Thanks.

  2. #2
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,150

    Default

    You need a <rabbit:admin/> element to auto-declare queues, exchanges etc. Refer to the reference docs.

    For example...

    Code:
    <rabbit:admin connection-factory="connectionFactory" />
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  3. #3
    Join Date
    Nov 2009
    Location
    Montreal, Quebec
    Posts
    398

    Default

    Thanks Gary! That is indeed all I needed. It's my first time using AMQP and I jumped right into the Spring Integration AMQP support, so I was looking for the rabbit namespace documentation there, rather than in the Spring AMQP documentation.

    Thanks again

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •