Reputation: 2335
I have a J2EE application that receives and process messages (events). These messages contain various blocks of data. Different types of processing can be triggered depending of the type of data contained in a message.
I would like to have a simple internal event/message bus that can be used by the main processing thread to invoke different post-processors dependent on message content. For example, if a message is received of type A, I would like to be able to send an internal event to all post-processors that have subscribed to events of type A. The post-processors can then work their magic in their own time/thread. It would be nice (though not required) if the post-processors could be added/removed from the application via some sort of plugin-framework.
I understand that there are various message buses available. I am really seeking advice on an appropriate (lightweight) choice or perhaps a design pattern/example to cook my own.
Thanks in anticipation
Upvotes: 2
Views: 1999
Reputation: 2122
You can also check out MBassador https://github.com/bennidi/mbassador.
It is annotation driven, very light-weight and uses weak references (thus easy to integrate in environments where objects lifecycle management is done by a framework like spring or guice or somethign). It provides an object filtering mechanism and synchronous or asynchronous dispatch/message handling. And it's very fast!
EDIT: I created a performance and feature comparison for a selection of available event bus implementations including Guava, MBassador and some more. The results are quite interesting. Check it out here http://codeblock.engio.net/?p=37
Upvotes: 2
Reputation: 8109
Guava has and nice EventBus implementation. See the documentation.
Upvotes: 3