java中的轻量级发布/订阅框架 [英] lightweight publish/subscribe framework in java

查看:909
本文介绍了java中的轻量级发布/订阅框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个提供发布/订阅模式的java的轻量级框架?

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

一些理想的功能


  • 对泛型的支持

  • 向发布者注册多个订阅者

  • API主要是接口和一些有用的实现

  • 完全不需要内存,持久性和事务保证。

  • Support for generics
  • Registration of multiple subscribers to a publisher
  • API primarily interfaces and some useful implementations
  • purely in-memory, persistence and transaction guarantees not required.

我知道JMS但是对我的需求来说太过分了。发布/订阅数据是扫描文件系统的结果,扫描结果被送到另一个组件进行处理,然后在被送到另一个组件之前进行处理,依此类推。

I know about JMS but that is overkill for my need. The publish/subscribed data are the result of scans of a file system, with scan results being fed to another component for processing, which are then processed before being fed to another and so on.

编辑:
所有这些都在同一个过程中。来自beans的PropertyChangeListener并没有完全削减它,因为它报告了属性的变化,而不是发布特定的项目。我可以通过拥有最后发布的对象属性以及已发布的对象来使用工作模式来使用ProprtyChangeListener。 PropertyChangeListeners不支持泛型,并且在属性更改语义中是根深蒂固的,而不是纯粹的发布/订阅。 java.util Observer / Observable模式会很好,但是Oberver是一个具体的类。

All within the same process. PropertyChangeListener from beans doesn't quite cut it, since it's reporting changes on properties, rather than publishing specific items. I could shoehorn ProprtyChangeListener to work by having a "last published object" property, and so published objects. PropertyChangeListeners don't support generics, and are entrenched in property change semantics, rather than pure publish/subscribe. The java.util Observer/Observable pattern would be good, but Oberver is a concrete class.

推荐答案

JMS轻或重在配置它时。我们在一个具有内存队列的项目中使用 HornetQ 。它易于设置,不需要任何基于JNDI的配置,并且非常易于使用。

JMS is as light or heavy as you configure it. We use for example HornetQ in one project with an in memory queue. It is easy to setup, doesn't need any JNDI based configuration and is really easy to use.

我相信JMS作为Message Pub / Sub的API是很容易。 (并不容易;)

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

这篇关于java中的轻量级发布/订阅框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆