Setting/Getting Parameters
Use
A key feature of messages is the ability to set message parameters.
There are two types of parameters:
-
Predefined Parameters: A set of parameters for which the RTMFMessage class provides getters and setters. Some predefined parameters are automatically set in some cases.
-
Customer Parameters: A parameter that you can create for the RTMFMessage object.
Predefined Parameters
A message contains the following predefined parameters:
-
Action
-
Event
The event parameter is automatically set when the publishEvent() method is called. The value is the name of the event that was triggered.
-
From
-
Destination
The destination parameter is automatically set when a message is sent to an RTMF service, for example, by calling publishToTopic() or sendToQueue() . The value is the name of the service.
The RTMFMessage class defines setters and getters for these parameters. You cannot retrieve the values of predefined parameters by calling getParamValue() .
An RTMF service that registers to receive messages sent to another service can use only predefined parameters to create a filter. For more information, see Registering for Messages Sent to Another Service .
Custom Parameters
You can add custom parameters to the message, as follows:
RTMFMessage message = RTMFMessageFactory.getMessage(RTMFMessageType.RTMFMessageType);
message.putParam("param","value");
You can retrieve parameters as follows:
String myParam = message.getParamValue("param");
Adding a List of Values
In addition to a String , you can define a List of values, and add this as a single parameter, as follows:
RTMFMessage message = RTMFMessageFactory.getMessage(RTMFMessageType.RTMFMessageType);
List myValueList = new Vector();
myValueList.add("value1");
myValueList.add("value2");
message.putParam("paramWithValueList", myValueList);
The following retrieves a parameter that is a List :
List myParamValues = message.getParamValues("paramWithValueList");