...
Code Block | ||
---|---|---|
| ||
ConnectionFactoryfactory =newConnectionFactorynew ConnectionFactory(); factory.setHost(“localhost”"localhost"); factory.setUsername(“guest”"guest"); factory.setPassword(“guest”"guest"); factory.setPort(5672); Connectionconnection =factory.newConnection(); Channelchannel =connection.createChannel(); channel.queueDeclare(“queue”"queue",false,false,false,null); channel.exchangeDeclare(“exchange”"exchange","direct",true); channel.queueBind(“queue”,“exchange”,“route”"queue","exchange","route"); //Themessagetobesent Stringmessage ="<m:placeOrder xmlns:m=\"http://services.samples\">" + +"<m:order>" +"<m:price>100</m:price>\n" +"<m:quantity>20</m:quantity>" +"<m:symbol>RMQ</m:symbol>" +"</m:order>" +"</m:placeOrder>"; //PopulatetheAMQPmessageproperties AMQP.BasicProperties.Builderbuilder =newAMQPnew AMQP.BasicProperties().builder(); builder.contentType("text/xml"); builder.contentEncoding(contentEncoding); //Publishthemessagetoexchange channel.basicPublish(“exchange”,“queue”"exchange","queue",builder.build(),message.getBytes()); |
Analyzing the output
The direct exchange is bound to the queue with route-key queue
that is consumed by the ESB RabbitMQ transport receiver. From there the message will be sent to the AMQPProxy and it will be forwarded to the given http url.
...