Apama 10.3 | Apama Capital Markets Foundation Documentation | Capital Markets Foundation | Session Management | Connecting to sessions | Sample code for using handler to connect
 
Sample code for using handler to connect
Alternatively, you can create a SessionHandler object without connecting to a session. You then use that session handler to connect to a session. For example:
monitor SessionExample2 {
 
context mainContext := context.current();
 
action onload() {
com.apama.session.SessionHandler sessionHandler :=
(new com.apama.session.SessionHandlerFactory).create(mainContext);
sessionHandler.connect("MySession", "MyTransport");
...
}
}
Typically, you obtain a session handler object without connecting when you want to set parameters, set callbacks, or override default error handling before you connect to a session. See Setting session callbacks, Setting session parameters, and Overriding default error handling for sessions.
Session handler objects must be initialized with a factory object before they can be used. For example, the following code does not work:
monitor IncorrectSessionExample {
 
context mainContext := context.current();
 
com.apama.session.SessionHandler sessionHandler;
 
action onload() {
// This will not work:
sessionHandler.connect(mainContext, "MySession", "MyTransport");
...
}
}

Copyright © 2013-2018 | 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.