Creating a Channel
Channels can be created programmatically as detailed below, or they can be created using the Enterprise Manager.
In order to create a channel, first of all you must create an nSession object, which is effectively your logical and physical connection to a Universal Messaging realm. This is achieved by using an RNAME for your Universal Messaging realm when constructing the nSessionAttributes object, as shown below:
String[] RNAME={"nsp://127.0.0.1:9000"};
nSessionAttributes nsa=new nSessionAttributes(RNAME);
nSession mySession=nSessionFactory.create(nsa);
mySession.init();
Once the nSession.init() method is successfully called, your connection to the realm will be established.
Using the nSession objects instance 'mySession', we can then begin creating the channel object. Channels have an associated set of attributes, that define their behaviour within the Universal Messaging Realm Server. As well as the name of the channel, the attributes determine the availability of the events published to a channel to any subscribers wishing to consume them,
To create a channel, we do the following:
nChannelAttributes cattrib = new nChannelAttributes();
cattrib.setMaxEvents(0);
cattrib.setTTL(0);
cattrib.setType(nChannelAttributes.PERSISTENT_TYPE);
cattrib.setName("mychannel");
nChannel myChannel=mySession.createChannel(cattrib);
Now we have a reference to a Universal Messaging channel within the realm.
Note:
The set of permissible characters you can use to name a channel is described in the section
Creating Channels in the Enterprise Manager section of the
Administration Guide.