Show TOC

Background documentationSetting/Getting Parameters Locate this document in the navigation structure

 

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:

Syntax Syntax

  1. RTMFMessage message = RTMFMessageFactory.getMessage(RTMFMessageType.RTMFMessageType);
    
    
  2. message.putParam("param","value");
End of the code.

You can retrieve parameters as follows:

Syntax Syntax

  1. String myParam = message.getParamValue("param");
End of the code.
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:

Syntax Syntax

  1. RTMFMessage message = RTMFMessageFactory.getMessage(RTMFMessageType.RTMFMessageType);
    
    
    
  2. List myValueList = new Vector();
  3. myValueList.add("value1");
  4. myValueList.add("value2");
    
    
  5. message.putParam("paramWithValueList", myValueList);
End of the code.

The following retrieves a parameter that is a List:

Syntax Syntax

  1. List myParamValues = message.getParamValues("paramWithValueList");
End of the code.

Note Note

If you retrieve a String parameter as a List, a List with a single string is returned.

If you retrieve a List as a String, the first string in the List is returned.

End of the note.