Sun Java System Message Queue 4.1 릴리스 노트

이벤트 수신기 만들기

다음 코드 예는 연결 이벤트 수신기를 설정하는 방법을 나타냅니다. 연결 이벤트가 발생할 때마다 클라이언트 런타임에 의해 이벤트 수신기의 onEvent 메소드가 호출됩니다.

//create an MQ connection factory.

com.sun.messaging.ConnectionFactory factory =
        new com.sun.messaging.ConnectionFactory();

//create an MQ connection.

com.sun.messaging.jms.Connection connection = 
       (com.sun.messaging.jms.Connection )factory.createConnection();

//construct an MQ event listener.  The listener implements 
//com.sun.messaging.jms.notification.EventListener interface.

com.sun.messaging.jms.notification.EventListener eListener = 
       new ApplicationEventListener();

//set event listener to the MQ connection.

connection.setEventListener ( eListener );