we use Universal Messaging v 9.12 and are about to create a small java application that would read events from a UM realm.
The java application would register a durable subscriber for a channel.
I’ve looked through the API and through the “Universal Messaging Developer Guide” and saw the following methods for doing this:
// First (from the Universal Messaging Developer Guide)
channel.addSubscriber(nEventListener, nNamedObject);
// Second (suggested by the Java IDE)
channel.addSubscriber(nEventListener, nDurable);
I understand how to use the first method: first create a named object using nChannel.createNamedObject() (or nChannel.createSharedNamedObject()) and then call the addSubscriber method with the parameter of type nNamedObject. But it is marked as deprecated. So I’d like to use the second variant.
Could anybody tell me how to create a nDurable instance? I could not find any method in nChannel that would return this type.
Here is a sample snippet that can help you in order to create nDurable object.
//create &init session
nSessionAttributes nsa = new nSessionAttributes(server.getDefaultAdapter());
nSession session = nSessionFactory.create(nsa);
session.init();
//get the Channel and Durable Manager
nChannelAttributes nca = new nChannelAttributes(CHANNEL_NAME);
nChannel channel = session.findChannel(nca);
nDurableManager durableManager = channel.getDurableManager();
//create nDurbale object
nDurableAttributes da = nDurableAttributes.create(nDurableAttributes.nDurableType.SharedQueued, name);
da.setClustered(isCluster);
da.setPersistent(true);
da.setSelector(selector);
nDurable durable = durableManager.add(da);
//use this object with Second API (suggested by the Java IDE)
channel.addSubscriber(nEventListener, durable );
More recent versions of the online docs contain articles on the usage of both the Java and C# flavours of the nDurable API - just search for nDurable in the latest doc set (unfortunately I’m not allowed to post links)
Just one more question: Should I check whether a durable with the desired name already exists before adding it? Or is it safe just to add it (possibly “overwriting”)? Or will it be an No-Op if the durable with the name already exists?