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 ...

Get RabbitMQ Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.