This documentation is for WSO2 Enterprise Service Bus version 4.9.0 . View documentation for the latest release.

All docs This doc

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
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.

...