The JMS specification allows for the placing of custom properties into a message's header. These custom properties are specified as a set of name/value pairs that can store both simple types and Java objects. The properties can be used for a number of tasks including message selection.
When using the Fuse ESB JMS binding component, you define the custom properties added to the reply messages as property map. This is done using the Spring map
element. You can configure one static map that will be applied to every reply message generated by the consumer.
You can configure a consumer to add custom properties to reply messages in one of two ways:
The property map containing the custom properties you want added to the reply messages is stored in a java.util.Map
object. You define that map object using the Spring util:map
element.
The util:map
element is defined in the http://www.springframework.org/schema/util
namespace. In order to use the element you will need to add the following namespace alias to your beans
element:
xmlns:util="http://www.springframework.org/schema/util"
The entries in the map are defined by adding entry
child element's to the util:map
element. Each entry
element takes two attributes. The key
entry is the map key and corresponds to the properties name. The value
attribute is the value of the property.
![]() | Tip |
---|---|
If you want the value of a property to be complex type that is stored in a Java object, you can use the |
Example 3.13 shows an example of a SOAP consumer whose reply messages have a set of custom properties added to their header.
Example 3.13. Adding Custom Properties to a Reply Message
<beans xmlns:jms="http://servicemix.apache.org/jms/1.0" xmlns:util="http://www.springframework.org/schema/util" ... > ... <jms:consumer service="my:widgetService" endpoint="jbiWidget" destinationName="my.widgetQueue" connectionFactory="#connectionFactory" replyDestination="#widgetReplyQueue" replyProperties="#jmsProps" /> ... <util:map id="jmsProps"> <entry key="location" value="San Jose"/> <entry key="orig_code" value="sjwf"/> <entry key="client_code" value="widget010"/> </util:map> ... </beans>