Sample Apps Question
I am a little confused by the samples applications, it seems impossible to use xml to configure a rabbitmq connection.
The examples are all configured in java because they need to declare queues etc with the amqpAdmin class which is calling directly to the server while you are still configuring. This doesnt feel right to me.
Or am i missing something?
You can use XML to create a RabbitConnectionFactory, and you could use XML to create a RabbitAdmin instance as well. We did originally put the Exchange, Queue, and Binding declaration code into the top-level class for the Java-based configuration style, but since then we have decided to move it into RabbitAdmin so that it will be available functionality for both XML and Java-based configuration.
See this issue for the details (and please vote for it):
Do you need to have Queue and Exchange objects declared at application startup time?... or will they be administered separately?
Thanks for the quick reply,
I am very new to amqp and comming from a jms world, so i am probably missing some details here.
What i want is to have objects automatically wired on startup, to listen for messages coming from the server. So really i want the bindings, exchanges and queues already setup at startup.
The bit that seems odd to me is if i want to wire a MessageListener to trigger an onMessage, i need to pass it a Queue? To create this queue at configuration time i need to make a method call, which calls the server.
The Queue objects that we have defined in the Spring AMQP project are simply data objects to represent that name along with the other queue properties (durable, exclusive, auto-delete, etc.). All of those properties are required if you are actually *declaring* a queue on the broker.
As long as the Queue has been declared already, the MessageListener container really should only need the queue's name. Behind the scenes, it's calling a method to register a Consumer with the queue on the broker, and that method call only passes the name. In fact, we are most likely going to update the SimpleMessageListenerContainer to only work with names and not Queue objects (even though it might be common to pass in the name taken from a Queue instance in the same context). That would be consistent with the approach in AmqpTemplate where you can pass the queue name (but not a Queue instance) to the synchronous receive() operations.
In JMS terms, it would be similar to passing the destination name as a String rather than an actual javax.jms.Destination instance. The difference in Spring AMQP is that the Queue instance really is just a data object (a "JavaBean" basically), so you can create an instance of Queue that is never explicitly *declared* on the broker as long as the Queue has been declared previously. As with JMS, it's common to handle the administration of Exchanges and Queues on the broker outside of application code. Then, application code only deals with the names.
Please let me know if I can clarify anything I've mentioned here.
Thank you, you have been a great help