This documentation is for WSO2 Enterprise Integrator version 6.0.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()); 		

...