I just modified the amqp sample as folllows...
Code:
MessageChannel controlBus = context.getBean("controlBus", MessageChannel.class);
controlBus.send(new GenericMessage<String>("@rabbitAdapter.start()"));
Thread.sleep(6000);
controlBus.send(new GenericMessage<String>("@rabbitAdapter.stop()"));
Code:
<!-- From RabbitMQ To STDOUT -->
<int:channel id="controlBus" />
<int:control-bus input-channel="controlBus"/>
<int-amqp:inbound-channel-adapter channel="fromRabbit" id="rabbitAdapter"
queue-names="si.test.queue" auto-startup="false"
connection-factory="connectionFactory" />
And all worked fine...
Code:
2012-05-24 12:52:11,243 INFO | main | o.s.integration.amqp.inbound.AmqpInboundChannelAdapter | started rabbitAdapter
xxx
2012-05-24 12:52:16,140 INFO | SimpleAsyncTaskExecutor-1 | org.springframework.integration.handler.LoggingHandler | [Payload=xxx][Headers={timestamp=1337878336139, id=9fdbf001-7b86-42aa-9f09-6e652e1c4858, amqp_receivedRoutingKey=si.test.binding, amqp_deliveryMode=PERSISTENT, amqp_contentType=text/plain, amqp_receivedExchange=si.test.exchange, amqp_contentEncoding=UTF-8, amqp_redelivered=false, amqp_deliveryTag=1}]
xxx
2012-05-24 12:52:17,245 INFO | main | o.s.amqp.rabbit.listener.SimpleMessageListenerContainer | Waiting for workers to finish.
2012-05-24 12:52:18,144 INFO | main | o.s.amqp.rabbit.listener.SimpleMessageListenerContainer | Successfully waited for workers to finish.
2012-05-24 12:52:18,144 INFO | main | o.s.integration.amqp.inbound.AmqpInboundChannelAdapter | stopped rabbitAdapter
Notice auto-startup="false" to prevent the adapter from immediately starting.