EventAsyncApp.java

The asynchronous-specific calls in this asynchronous event application (AsyncEventApp.java) are illustrated in this code sample. Between the eventSession.start and the eventSession.stop method calls, you would normally solicit user input or wait for some type of intervention to let the class know that event delivery needs to stop.

import com.jdedwards.system.connector.dynamic.Connector;
import com.jdedwards.system.connector.dynamic.newevents.AsyncEventSession;
import com.jdedwards.system.connector.dynamic.newevents.EventService;
import com.jdedwards.system.connector.dynamic.newevents.EventSession;

Sample Java Connector Asynchronous Event application

public class EventAsyncApp {

    public static void main(String[] args) {
        
		try {
		    

Instantiate a Connector object.

            Connector con = Connector.getInstance();

Login through the Connector to JD Edwards EnterpriseOne.

            int sessionID = con.login("username", "password", 
"environment", "role");

Instantiate an EventService object

            EventService service = EventService.getInstance();

Create a synchronous event session in CLIENT_ACKNOWLEDGE mode.

            AsyncEventSession eventSession = service.getAsyncEventSession
(sessionID, EventSession.CLIENT_ACKNOWLEDGE);

Register a listener object which you have created

            eventSession.registerListener(new MyListener());

Start the delivery of events to the listener.

            eventSession.start();

Stop the delivery of events to the listener. Note that you can continuously alternate between calls to start() and stop() as long as you do not call the close() method.

            eventSession.stop();

Close the event session. No other operations on the event session are possible at this point.

            eventSession.close();

Logoff the user from JD Edwards EnterpriseOne.

            con.logoff(sessionID);

Shut the Connector down.

            con.shutDown();
            
        } catch (Exception e) {
            
            e.printStackTrace();
            System.exit(-1);
            
        }
        
        System.exit(0);
	   }
}