Guava: Event Bus Ordering of Listeners

Created on 31 Oct 2014  路  9Comments  路  Source: google/guava

_Original issue created by adrianwkirk on 2011-12-24 at 03:04 PM_


It would be extremely to be able to assign a priority to listeners so that high priority listeners get served before the lower priority listeners. Why is this useful? An example would be a trading engine. Market data comes in, you would want to serve your calculators first before feeding your trade decision object before feeding your publishers.

package=eventbus status=research type=enhancement

Most helpful comment

_Original comment posted by b.diedrichsen on 2012-11-17 at 11:32 AM_


I recently added support for handler ordering by priority to my own event bus implementation (MBassador). It also uses weak references and supports event filtering, synchronous and asynchronous dispatch and more.

It is also quite fast. 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

All 9 comments

_Original comment posted by wasserman.louis on 2011-12-25 at 11:16 AM_


I'm going to classify this under the general heading of "make EventBus extensible." Then you could e.g. add your own annotation specifying a priority, or something.


Status: Triaged

_Original comment posted by wasserman.louis on 2012-01-05 at 08:46 PM_


_(No comment entered for this change.)_


Labels: Type-Enhancement, Package-EventBus

_Original comment posted by [email protected] on 2012-01-31 at 07:49 PM_


Are you suggesting that "feeding your publishers" is dependent on data that's generated by "your calculators?" If so, have the calculators post a new event and have the other party subscribe to that?

_Original comment posted by adrianwkirk on 2012-02-02 at 01:57 PM_


Hi,

No not dependent on the data. Most of the high performance trading systems I have worked on have a similar concept to the event bus (hence my interest) with added the added feature of high to low priority listeners. Listeners are given the event in order of their priority.

Filtering is also another feature on the in house versions of this concept, but I think you already have this on your to do list.

In general I am really liking the guava library.

Adrian

_Original comment posted by [email protected] on 2012-02-16 at 07:17 PM_


_(No comment entered for this change.)_


Status: Acknowledged

_Original comment posted by [email protected] on 2012-06-22 at 06:16 PM_


_(No comment entered for this change.)_


Status: Research

_Original comment posted by b.diedrichsen on 2012-11-17 at 11:32 AM_


I recently added support for handler ordering by priority to my own event bus implementation (MBassador). It also uses weak references and supports event filtering, synchronous and asynchronous dispatch and more.

It is also quite fast. 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

I have a similar requirement. However, simply respecting the order in which subscribers are added to the bus would be sufficient for my needs. At first blush, it would appear to be as simple as using a LinkedHashMultimap for subscribersByType instead of HashMultimap.

We are not actively working on EventBus anymore. There are modern alternatives, including RxJava, that are more actively maintained.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Hanmac picture Hanmac  路  3Comments

cowwoc picture cowwoc  路  3Comments

gissuebot picture gissuebot  路  3Comments

Lysergid picture Lysergid  路  4Comments

gissuebot picture gissuebot  路  5Comments