|
setData
DescriptionAdds
the gateway-specific data, including any message contents, as a
Java Map to the CFEvent object
CategoryEvent
Gateway Development
Syntaxvoid setData(Map data)
Parameters
Parameter
|
Description
|
data
|
The incoming message and any additional
gateway-specific event data.
|
UsageThe number
of fields and their contents depend on the event gateway type. The Map
keys must be strings.
Because ColdFusion is not case sensitive,
it converts the Map passed in the setData method
to a case insensitive Map. As a result, do not create entries in the
data with names that differ only in case.
ExampleThe
following code shows the routine from the example JMS gateway that handles
incoming messages. It puts the JMS message ID and contents in a
data HashMap, and uses it in the setData method:
public void handleMessage(String msg, String topicName, String msgID) {
coldfusion.eventgateway.Logger log = getGatewayServices().getLogger();
Map data = new HashMap();
CFEvent cfMsg = new CFEvent(getGatewayID());
data.put("msg", msg);
data.put("id", msgID);
cfMsg.setData(data);
cfMsg.setOriginatorID(topicName);
cfMsg.setGatewayType("JMS");
if (sendMessage(cfMsg)) {
log.info("Added message '" + msgID + "' to queue.");
} else {
log.error("Failed to add message '" + msgID + "' to queue.");
}
}
|