Product: OpenFusion Notification Service
Version: ALL
Description:
How to create a channel with a specific ID?
Resolution:
The Notification Service specification does not provide a method to create a channel with a predefined number.
The create_channel() method is the only method used to create an event channel and it automatically assigns a numeric identifier to the channel.
For example:
factory = EventChannelFactoryHelper.narrow(obj);
try
{
channel = factory.get_event_channel(3);
}
catch (ChannelNotFound ex)
{
// Create a channel with no QoS or admin properties.
Property[] qosProp = new Property[0];
Property[] admProp = new Property[0];
org.omg.CORBA.IntHolder id = new org.omg.CORBA.IntHolder ();
try
{
channel = factory.create_channel (qosProp, admProp, id);
}
catch (UnsupportedQoS exc)
{ }
catch (UnsupportedAdmin exc)
{ }
}
This code tries to get channel number 3. The first time the code is run channel 3 does not exist so the ChannelNotFound exception is thrown.
The create_channel() method will create channel 0 as this is the first available number for it to use.
The next time the code is run channel 3 still does not exist so the create_channel() method will create channel number 1.
This will continue until channel 3 is created. As soon as channel 3 exists then every time you run the code the get_event_channel() method will find channel 3 and the exception will not be thrown.
#KnowledgeDocs
#OpenFusion