LibraryToggle FramesPrintFeedback

Example 20.14 shows code for inspecting some of the JMS properties using the response context.

Example 20.14. Reading the JMS Header Properties

// JMSMessageHeadersType messageHdr retrieved previously
1System.out.println("Correlation ID: "+messageHdr.getJMSCorrelationID());
2System.out.println("Message Priority: "+messageHdr.getJMSPriority());
3System.out.println("Redelivered: "+messageHdr.getRedelivered());
  
JMSPropertyType prop = null;
4List<JMSPropertyType> optProps = messageHdr.getProperty();
5Iterator<JMSPropertyType> iter = optProps.iterator();
6while (iter.hasNext())
{
  prop = iter.next();
   System.out.println("Property name: "+prop.getName());
   System.out.println("Property value: "+prop.getValue());
}

The code in Example 20.14 does the following:

1

Prints the value of the message's correlation ID.

2

Prints the value of the message's priority property.

3

Prints the value of the message's redelivered property.

4

Gets the list of the message's optional header properties.

5

Gets an Iterator to traverse the list of properties.

6

Iterates through the list of optional properties and prints their name and value.

Comments powered by Disqus
loading table of contents...