org.apache.qpid.protocol
Interface AMQMethodListener


public interface AMQMethodListener

AMQMethodListener is a listener that receives notifications of AMQP methods. The methods are packaged as events in AMQMethodEvent.

An event listener may be associated with a particular context, usually an AMQP channel, and in addition to receiving method events will be notified of errors on that context. This enables listeners to perform any clean up that they need to do before the context is closed or retried.

CRC Card
Responsibilities
Accept notification of AMQP method events. AMQMethodEvent
Accept notification of errors on the event context.

Todo:
Document why the exception is passed to the error method. Is it so that the exception can be passed from the event handling thread to another thread and rethown from there? It is unusual to pass exceptions as method arguments, because they have their own mechanism for propagating through the call stack, so some explanation ought to be provided.

Method Summary
 void error(Exception e)
          Notifies the listener of an error on the event context to which it is listening.
<B extends AMQMethodBody>
boolean
methodReceived(AMQMethodEvent<B> evt)
          Notifies the listener that an AMQP method event has occurred.
 

Method Detail

methodReceived

<B extends AMQMethodBody> boolean methodReceived(AMQMethodEvent<B> evt)
                       throws AMQException
Notifies the listener that an AMQP method event has occurred.

Parameters:
evt - The AMQP method event (contains the method and channel).
Returns:
true if the handler processes the method frame, false otherwise. Note that this does not prohibit the method event being delivered to subsequent listeners but can be used to determine if nobody has dealt with an incoming method frame.
Throws:
Exception - if an error has occurred. This exception may be delivered to all registered listeners using the error() method (see below) allowing them to perform cleanup if necessary.
AMQException
Todo:
Consider narrowing the exception.

error

void error(Exception e)
Notifies the listener of an error on the event context to which it is listening. The listener should perform any necessary clean-up for the context.

Parameters:
e - The underlying exception that is the source of the error.


Licensed to the Apache Software Foundation