How to send message to a remote gateway from module

Hi,

From a previous post (August 26, 2016) where you give the following code to send a message from a module, I tried to use the same thing to send a message to a remote gateway but it seems that the remoteServers property doesn’t exist on the filter properties available in the SDK. Is it possible or I miss something?

Thanks

Code:
MessageDispatchManager mdm = gatewayContext.getMessageDispatchManager();

PyDictionary payload = new PyDictionary(new PyObject[] {
new PyString(“Source”), new PyString(“Gateway”),
new PyString(“Message”), new PyString(“testMessage”)
});

// Limit to Gateway scope
Properties filterParams = new Properties();
filterParams.setProperty(MessageDispatchManager.KEY_SCOPE, MessageDispatchManager.SCOPE_GATEWAY_ONLY);

// You must specify a project, as message handlers are configured in projects.
mdm.dispatch(“MyProject”,
“MyMessageHandler”,
payload,
filterParams);

Note that the remote servers function was added in 7.8.2, so make sure you are using a recent 7.8 version. That being said, give this a try:

// Convert the list of servers into a single comma-delimited String
StringBuffer buffer = new StringBuffer();
for(String server: remoteServers){
    if(buffer.length() != 0){
        buffer.append(",");
    }
    buffer.append(server);
}
String remoteServersStr = buffer.toString();

// Limit to Gateway scope
Properties filterParams = new Properties();
filterParams.setProperty(MessageDispatchManager.KEY_SCOPE, MessageDispatchManager.SCOPE_GATEWAY_ONLY);

// Add the remote servers String
filterParams.setProperty(MessageDispatchManager.KEY_REMOTE_SERVERS, remoteServersStr);