Work with non-routing path fields in a message header
We can work with fields in a message header that identify and affect the behavior of messages.
In addition to the routing fields (see Set routing addresses in a message header), there are a number of fields in the message header that we can work with. These fields affect important qualities and characteristics of the message, such as priority and reliability, identity, and so on. See Message header information for information about the equivalence of the header fields to JMS message header fields, and the methods available to work with them.
- Locate the point in the mediation handler where you insert the functional mediation code, in the method handle (MessageContext context). The interface is MessageContext, and you should cast this to SIMessageContext unless you are only interested in the methods provided by MessageContext.
- Get the SIMessage from the MessageContext object. For example, SIMessage message = ((SIMessageContext)context).getSIMessage();
- Build the mediation header function in a similar way to these examples, and using the reference information in Message header information to help:
- Set the reliability of the message. For instance, siMessage.setReliability(Reliability.ASSURED_PERSISTENT);. In this case, the quality of service is set to the highest level.
- Set the time to live for a message - that is, the time, in milliseconds, that the message is allowed to remain on a queue before it is removed if it is not processed. For example, siMessage.setRemainingTimeToLive(1000000); will set the remaining time before the message should expire to 1000 seconds.
Subtopics
- Message header information
The non-routing SIMessage header fields, and the methods available to work with them, can be mapped to JMS message header fields.