Runtime tools : Service components : Host Access Manager : Connection Event
  
Connection Event
The application can listen to the event of the connection to get notification when the connection is open, closed, in error or has produced a message.
The following is the interface of the HostConnectionEventListener, where the application implements the listener and registers the listener to the connection to get the event notification.
public interface HostConnectionEventListener {
  public abstract void connectionOpened(HostConnectionEvent arg0);
  public abstract void MessageReceived(HostConnectionEvent arg0);
  public abstract void connectionClosed(HostConnectionEvent arg0);
  public abstract void connectionErrorOccurred(HostConnectionEvent arg0);
  public abstract void connectionTerminated(HostConnectionEvent arg0);
}
Asynchronous message
Asynchronous message means that the host actively sends a message, and the sending time is not fixed. On the other hand, synchronous message processing means that the client sends the message first, and the host replies to the message accordingly. The client waits a timeout to receive the synchronous message.
To process the asynchronous message, the application implements the MessageReceived method of HostConnectionEventListener or overrides the MessageReceived method of HostConnectionEventHandler as shown in following example:
public class IncomingMessageListener extends HostConnectionEventHandler {
   @Override
   public void MessageReceived(HostConnectionEvent arg0) {
     message= (String) arg0.getSource();
     System.out.println ("@ IncomingMessageListener MessageReceived "+      message);
   messagSemaphore.signalOn();
   }
}
The application needs to register the implemented listener after getting the connection from connection factory.
connection.addHostConnectionListener(new IncomingMessageListener());
Note For the UDTT built-in Host MQ connector and Host LU62 connector, to handle asynchronous message, the property synchronousMode must be disabled.
Go up to
Host Access Manager