This documentation is for WSO2 Enterprise Integrator version 6.1.1 . View documentation for the latest release in the 6.x.x family and the latest release in the 7.x.x family.

All docs This doc

Versions Compared

Key

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

...

Executing the sample

  • Use the following java Java client to publish a request to the RabbitMQ broker.

    Code Block
    languagejava
    ConnectionFactory factory = new ConnectionFactory();
    factory.setHost("localhost");
    factory.setUsername("guest");
    factory.setPassword("guest");
    factory.setPort(5672);
    Channel channel = null;
    Connection connection = factory.newConnection();
    channel = connection.createChannel();
    channel.queueDeclare("queue", false, false, false, null);
    channel.exchangeDeclare("exchange", "direct", true);
    channel.queueBind("queue", "exchange", "route");
    
    // The message to be sent
    String message = "<m:placeOrder xmlns:m=\"http://services.samples\">" +
                    "<m:order>" +
                    "<m:price>100</m:price>" +
                    "<m:quantity>20</m:quantity>" +
                    "<m:symbol>RMQ</m:symbol>" +
                    "</m:order>" +
                    "</m:placeOrder>";
    
    // Populate the AMQP message properties
    AMQP.BasicProperties.Builder builder = new AMQP.BasicProperties().builder();
    builder.contentType("application/xml");
    
    // Publish the message to exchange
    channel.basicPublish("exchange", "queue", builder.build(), message.getBytes());

...