Multicast
A common way to add a multicast configuration is via the Enterprise Manager (see
Multicast Configuration) but you can also do this programmatically.
Creating the nMulticastConfiguration
In order to create an nMulticastConfiguration object you need to specify two parameters:
multicastAddress - Multicast IP address to use
adapter - Network adapter address of your multicast configuration
Java, C#:
String multicastAddress = "227.0.0.98";
String adapter = "10.150.12.1";
nMulticastConfiguration mConf = new nMulticastConfiguration(multicastAddress, adapter);
C++:
std::string multicastAddress = "227.0.0.98";
std::string adapter = "10.150.12.1";
nMulticastConfiguration* mConf = new nMulticastConfiguration(multicastAddress, adapter);
Enabling multicast for cluster communication
In order to use multicast for intra-cluster communication you need to set a flag on the nMulticastConfiguration:
Java, C#:
mConf.setUseForCluster(true);
C++:
mConf->setUseForCluster(true);
Enabling multicast on DataGroups
When you create a DataGroup you have the option to enable multicast delivery. However you also need to enable multicast for DataGroups on the multicast configuration:
Java, C#:
mConf.setUseForDataGroups(true);
C++:
mConf->setUseForDataGroups(true);
Then (after the configuration has been applied) when you create a DataGroup you need to set the enableMulticast flag to true:
Java, C#:
boolean enableMulticast = true;
String name = "newGroup";
mySession.createDataGroup(name,enableMulticast);
C++:
bool enableMulticast = true;
std::string name = "newGroup";
mySession->createDataGroup(name,enableMulticast);
Applying the multicast configuration
In order to register the new configuration on the server you will need to connect to a Universal Messaging Realm and establish an nRealmNode (see
nRealmNode). You can then get a reference to the nMulticastManager:
Java, C#:
nMulticastManager mMgr = realm.getMulticastManager();
C++:
nMulticastManager* mMgr = realm->getMulticastManager();
You can now use the nMulticastManager to send the new configuration to the server:
Java, C#:
mMgr.addMulticastConfiguration(mConf);
C++:
mMgr->addMulticastConfiguration(mConf);