org.apache.qpid.management.domain.services
Class BrokerMessageListener

java.lang.Object
  extended by org.apache.qpid.management.domain.services.BrokerMessageListener
All Implemented Interfaces:
org.apache.qpid.nclient.util.MessageListener

 class BrokerMessageListener
extends Object
implements org.apache.qpid.nclient.util.MessageListener

Message listener used for processing incoming messages. So it is installed as a consumer on a specific channel and when a new message arrives: 1) Performs a sanity check on the message (magic number, sequence number) 2) Extracts the opcode and looks for one message handler associated with that opcode. 3) If a message handler is found the delegates the message processing; otherwise a log message is written to indicate that the message will be skipped.


Field Summary
(package private)  Map<Character,IMessageHandler> _handlers
           
 
Constructor Summary
BrokerMessageListener(DomainModel model)
          Builds a new message listener with the given broker domain model.
 
Method Summary
 void onMessage(org.apache.qpid.api.Message compoundMessage)
          When a new message arrives this method is called.
(package private)  void setHandlers(Map<Character,IMessageHandler> handlers)
          Configures a new handler with this listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_handlers

Map<Character,IMessageHandler> _handlers
Constructor Detail

BrokerMessageListener

BrokerMessageListener(DomainModel model)
Builds a new message listener with the given broker domain model.

Parameters:
model - the managed broker domain model.
Method Detail

onMessage

public void onMessage(org.apache.qpid.api.Message compoundMessage)
When a new message arrives this method is called. 1) Performs a sanity check on the message (magic number, sequence number) 2) Extracts the opcode and looks for one message handler associated with that opcode. 3) If a message handler is found the delegates the message processing; otherwise a log message is written to indicate that the message will be skipped.

Specified by:
onMessage in interface org.apache.qpid.nclient.util.MessageListener
Parameters:
message - the incoming message.

setHandlers

void setHandlers(Map<Character,IMessageHandler> handlers)
Configures a new handler with this listener. After that, each time a message arrives with the specified opcode, this handler will be responsible for processing. Note that calling this method will switch this listener to a WORKING state.

Parameters:
opcode - the operation code.
handler - the message handler.


Licensed to the Apache Software Foundation