PurposeSends a message to a RabbitMQ broker.
// Send a string message to the default direct exchange. It will be routed to any // queues that are bound to the default exchange with the key '' (an empty string). rabbitSend "Some message"// Send a map message to the default direct exchange. The message will be routed to // the queue with the name 'myQueue'. rabbitSend "myQueue", [cmd: "addBook", title: "The Shining", author: "Stephen King"]// Send a string message to a 'prices' exchange with a routing key of 'shares.NYSE.GE'. rabbitSend "prices", "shares.NYSE.GE", "$354.23"
rabbitSend()method is basically a convenience over the Spring AMQP convertAndSend() method. It has three basic forms:
rabbitSend message rabbitSend routingKey, message rabbitSend exchangeName, routingKey, message
routingKeyis left out, it defaults to a value of '', i.e. the empty string. The same goes for
exchangeName, in which case the message is routed to the queue with the same name as the routing key (if specified).The message can be any serializable type, although if you want to interoperate with non-Java clients, it's best to stick to string and byte array messages.For complex requirements, you can even pass in an object that processes the message after construction. See the Spring AMQP guide for more information on that.