Difference to Guava Event Bus und CDI events?

757 views
Skip to first unread message

Oleg Varaksin

unread,
Dec 4, 2013, 9:50:31 AM12/4/13
to reactor-...@googlegroups.com
Hi,

What is the main difference of the Spring Reactor framework to the Guava Event Bus? What is the difference to CDI events? Events based communication with CDI looks better for me because you don't need to register something at all (no reactor.on(....)). If you have a web app with beans (e.g. JSF), a manually registration needs to be done in @PostConstruct method or similar. This is an extra effort! Event based communication in CDI doesn't need this. The communication over events is really loose coupled. I've blogged a couple of time ago about this

http://ovaraksin.blogspot.de/2012/07/event-based-communication-in-jsf-old.html
http://ovaraksin.blogspot.de/2012/07/event-based-communication-in-jsf-new.html

The second blog post is about Guava Event Bus and CDI events. At the moment, I can not see any advantage of the Spring Reactor over these technologies. Guava event communication can be either synchron oder asynchron, by the way. Not sure about CDI.

Regards.

Oleg.

Stephane Maldini

unread,
Dec 4, 2013, 10:49:12 AM12/4/13
to Oleg Varaksin, reactor-framework
Hi Oleg,

Guava is an interesting framework but AFAIK doesn't focus on solving reactive programming matters. It has Completable Futures and the Event bus compares to Reactor somehow, although I'm tempted to say they are a load range of frameworks addressing the event bus pattern in Java only.

Where Reactor shines is more on its asynchronous toolkit available to you with little dependencies (can be qualified as 'lightweight' for your application).
Reactor is about: Promise, Stream, Event Bus (Reactor), TCP, Functional Programming and all of that based on a flexible Dispatcher mechanism (can be seen as a super ExecutorService, with adequate optimized mechanisms to create/poll/run tasks super fast, like LMAX Disruptor). 

Others tools for modern application development are prand smart logic handling are provided, including Buffer, Registry, Codecs, Selectors (an awesome feature IMO compared to a limited String based topic routing). 

As a poorly inspired image look at it this way:
 You can choose to go to an Asian Restaurant and eat Salmon Sushis and that would work for you, or you can go to a Japanese Restaurant and choose homemade salmon Sushis, chicken Katsu, fantastic Ramen and all the wide variety of the amazing Japanese cuisine. I think we don't target the same use.

As for CDI, CDI event bus is pretty limited and only addresses one world, be aware that Reactor doesn't even depend on Spring. Nevertheless, just by pulling reactor-spring, you will get similar annotation driven event bus and more. The Jon https://github.com/jbrisbin/reactor-simple sample is a good example of that, not only he does use the @EventBus but also make wonderful use of Promise. I would be tempted to say that JDK8+CDI might help achieving the same thing, but that combo hasn't proven being quite adopted yet. The message passing bit (LMAX Disruptor) remains unique, the patterns such as Actor dispatching, EventLoop based dispatching and so on remain unique and I can't see them in CDI or JDK8 yet.

So TLDR version is: If you intend to introduce your application to the wonders of Reactive architectures, pick one of the specialized weapons, amid them you find Reactor.
If you want to just add a flavor of event-driven architecture, CDI or Guava are just fine, you miss some Reactive tools but you work on something familiar and that's your call.


--
You received this message because you are subscribed to the Google Groups "reactor-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reactor-framew...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Stephane Maldini | Technical Architect, EMEA | Pivotal 
goPivotal.com | T: @smaldini

Reply all
Reply to author
Forward
0 new messages