Universal Messaging 9.10 | Universal Messaging Developer Guide | Enterprise APIs | Enterprise Developer's Guide for Java | General Features | Creating a Session
 
Creating a Session
To interact with a Universal Messaging Server, the first thing to do is create a Universal Messaging Session nSession object, which is effectively your logical and physical connection to a Universal Messaging Realm. The steps below describe session creation.
1. Create a nSessionAttributes object with the RNAME value of your choice

String[] RNAME={"nsp://127.0.0.1:9000"};
nSessionAttributes nsa=new nSessionAttributes(RNAME);
2. Call the create method on nSessionFactory to create your session

Session mySession=nSessionFactory.create(nsa)
Alternatively, if you require the use of a session reconnect handler (nReconnectHandler) to intercept the automatic reconnection attempts, pass an instance of that class too in the create method:

public class myReconnectHandler implements nReconnectHandler{
//implement tasks associated with reconnection
}

myReconnectHandler rhandler=new myReconnectHandler();
nSession mySession=nSessionFactory.create(nsa, rhandler);
3. Initialise the session object to open the connection to the Universal Messaging Realm

mySession.init();
To enable the use of DataGroups and to create an nDataStream , you should pass an instance of nDataStreamListener to the init call.

public void SimpleStreamListener implements nDataStreamListener{
//implement onMessage callback for nDataStreamListener callbacks
}

nDataStreamListener myListener = new SimpleStreamListener();
nDataStream myStream = mySession.init(myListener);
After initialising your Universal Messaging session, you will be connected to the Universal Messaging Realm. From that point, all functionality is subject to a Realm ACL check. If you call a method that requires a permission your credential does not have, you will receive an nSecurityException.

Copyright © 2013-2019 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.