PDA

View Full Version : Using Custom Exchanges?



jamescarr99
Feb 20th, 2011, 08:38 AM
Hey All,

I'm playing around with some ideas using the custom exchanges that can be added onto RabbitMQ, specifically https://github.com/tonyg/script-exchange. Currently I am unable to find anywhere in the documentation that allows for publishing to Custom exchange types. Does spring-amqp expose this functionality?


Thanks,
James

Mark Fisher
Feb 20th, 2011, 08:41 AM
In Spring AMQP, you only need to provide the Exchange name, either as a property of the RabbitTemplate, or as a method-argument if you need to make the decision at runtime. The Exchange can be defined on the broker by any means.

HTH,
Mark

jamescarr99
Feb 20th, 2011, 08:58 AM
Thanks Mark... I'm actually giving a try now. One area of confusion though is that it seems that binding it might be difficult as the Binding class only supports the 4 base exchange types in the constructors.

However I'm about to test the behavior out, so we'll see what happens. ;)

Mark Fisher
Feb 20th, 2011, 09:20 AM
Think of the Spring AMQP Binding object as just a convenience, and one that only supports the known Exchange types. You can just as easily do the binding separately. It could be done directly against the broker, or you could use this lower level method of the Spring AMQP RabbitTemplate:


execute(ChannelCallback<T> action)


That callback's method will hand you a com.rabbitmq.client.Channel instance, and then you can call any of its available methods, e.g. queueBind(..)