Scrap some boilerplate. Introduce MessageMatchingChain which tries to process messages. ActionMessageHandler knows how to unwrap action and handle it. Chain might have default message handler if none of the previous handlers processed message. Otherwise message is left unprocessed.