O'Reilly logo

RabbitMQ Cookbook by Sigismondo Boschi, Gabriele Santomaggio

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using message properties

In this example we will show how an AMQP message is divided, and how to use message properties.

You can find the source at Chapter01/Recipe11/Java_11/.

Getting ready

To use this recipe you will need to set up the Java development environment as indicated in the Introduction section.

How to do it…

In order to access the message properties you need to perform the following steps:

  1. Declare a queue:
    channel.queueDeclare(MyQueue, false, false, false,null);
  2. Create a BasicProperties class:
    Map<String,Object>headerMap = new HashMap<String, Object>(); headerMap.put("key1", "value1"); headerMap.put("key2", new Integer(50) ); headerMap.put("key3", new Boolean(false)); headerMap.put("key4", "value4"); BasicProperties messageProperties = new ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required