Lightweight publish / subscribe structure in java

Is there a good lightweight framework for java that provides a publish / subscribe template?

Some perfect features

  • Generic Support
  • Registering multiple subscribers to a publisher
  • APIs are primarily interfaces and some useful implementations
  • purely in mind, perseverance and transaction guarantees are not required.

I know about JMS, but it's too complicated for my need. Published / signed data is the result of a file system scan, and the scan results are sent to another component for processing, which are then processed before being submitted to another and so on.

EDIT: All in one process. The beans PropertyChangeListener property does not completely abbreviate it, because it reports property changes rather than publishing specific elements. I could train ProprtyChangeListener to work, having the property "last published object" and so published objects. PropertyChangeListeners do not support generics and are rooted in the semantics of property changes, and not in pure publication / subscription. The Observer / Observable java.util template would be nice, but Oberver is a concrete class.

+43
java frameworks publish-subscribe
Jun 13 '10 at 15:48
source share
6 answers

JMS is as light or heavy as you configure it. We use, for example, HornetQ in the same project with a queue in memory. It is easy to configure, does not require any JNDI configuration and is really easy to use.

I believe that the JMS as an API for Message Pub / Sub is as simple as it gets. (And not easier;)

+13
Jun 13 '10 at 16:11
source share

This seems to meet the requirements of:

EventBus from the Google Guava Library - “Publish-style subscription between components without requiring the components to explicitly register with each other”, It can also be an AsyncEventBus that will send events to another stream.

Some additional options to consider:

  • If you can use the Observer pattern in this process. Subscribers can add listeners and receive event notifications. Observable is already part of the Java API.

  • FFMQ is a complete Java implementation, a lightweight implementation of Fast JMS 1.1 Queue.

+24
Mar 25 '12 at 11:11
source share

Since you are using Spring, I do not know if you know that Spring has its own lightweight event environment . It is used mainly within the structure itself, but is great for application code.

By default, this is synchronous pub / sub, but you can make it asynchronous with ApplicationEventMulticaster .

+6
Jun 13 '10 at 17:11
source share

I think Camel is also a good candidate. Especially with the publication-signature of the template

A camel can be built-in and lightweight. It offers enterprise integration patterns — many useful tools for integration, within an application or even with other participants (hence, “integration”).

It compares with Spring Integration , but a more complete IMO.

+1
May 6 '13 at 12:32
source share

If you cross the boundaries of the process, then some degree of “weight” arises. Why are you saying JMS is a heavyweight? Is the API pretty simple? There are supposedly easy implementations, such as link text . Heavier costs, such as persistence and transactional ability, are optional.

What do you need is easier than that?

0
Jun 13 '10 at 16:03
source share

Bob Lee has a QueueFile class at http://snipt.org/GWm/ which may seem interesting to you. This is a simple constant queue and can be used by several consumers. You don't seem to need perseverance, but since it's all so easy, it can still be useful.

0
Dec 29 '10 at 2:39 on
source share



All Articles