在此範例中,應用程式選擇事件偵聽程式將連線事件記錄到應用程式的記錄系統:
public class ApplicationEventListener implements
com.sun.messaging.jms.notification.EventListener {
public void onEvent ( com.sun.messaging.jms.notification.Event connEvent ) {
log (connEvent);
}
private void log ( com.sun.messaging.jms.notification.Event connEvent ) {
String eventCode = connEvent.getEventCode();
String eventMessage = connEvent.getEventMessage();
//write event information to the output stream.
}
}