User Guide
CFEvent class 995
setData
Description
Adds the gateway-specific data, including any message contents, as a Java Map to the CFEvent
object
Category
Event Gateway Development
Syntax
void setData(Map data)
See also
getData
, “CFML CFEvent structure” on page 1004, “CFEvent class” in Chapter 45, “Creating
Custom Event Gateways” in ColdFusion MX Developer’s Guide
Parameters
Usage
The 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.
Example
The 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.");
}
}
Parameter Description
data The incoming message and any additional gateway-specific event data.