高吞吐量的Java事件总线:MBassador

栏目: Java · 发布时间: 7年前

内容简介:高吞吐量的Java事件总线:MBassador

MBassador是一款在多线程环境中为高吞吐量而优化的功能丰富的 java 事件总线。注解驱动、同步/异步事件发布,强/弱引用,动态事件过滤。

MBassador是实现发布/订阅模式的轻量,高性能的事件总线。它主要为了能易于使用的丰富的和可扩展的功能,同时保持资源效率和性能。

MBassador的高性能核心是一种专门的数据结构,可提供无阻塞的读写器,并最大限度地减少写入者的锁争用,从而将读/写并发访问性能的损耗降低到最小化。

MBassador的代码是生产就绪的:86%的指令覆盖率,82%的分支覆盖率,高度随机和同时运行的测试集,在过去18个月中没有报告严重的错误。在不彻底测试代码的情况下,不会对内核进行任何修改。

使用很简单,bus = new MBassador()创建单例,配置消息处理器使用@[author][author][author]Handler[/author][/author]注解[/author],然后将其注册到总线中bus.subscribe(aListener),这样就可以开始发送消息bus.post(message).now() 或bus.post(message).asynchronously().


// Define your handlers

@ Listener(references = References.Strong)
class SimpleFileListener{

@ Handler
public void handle(File file){
// do something with the file
}

@ Handler(delivery = Invoke.Asynchronously)
public void expensiveOperation(File file){
// do something with the file
}

@ Handler(condition =
"msg.size >= 10000")
@ Enveloped(messages = {HashMap.class, LinkedList.class})
public void handleLarge(MessageEnvelope envelope) {
// handle objects without common super type
}

}

// somewhere else in your code

MBassador bus = new MBassador();
bus.subscribe (new SimpleFileListener());
bus.post(new File(
"/tmp/smallfile.csv")).now();
bus.post(new File(
"/tmp/bigfile.csv")).asynchronously();

性能测试:[该贴被banq于2017-06-13 22:23修改过]


以上所述就是小编给大家介绍的《高吞吐量的Java事件总线:MBassador》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Compilers

Compilers

Alfred V. Aho、Monica S. Lam、Ravi Sethi、Jeffrey D. Ullman / Addison Wesley / 2006-9-10 / USD 186.80

This book provides the foundation for understanding the theory and pracitce of compilers. Revised and updated, it reflects the current state of compilation. Every chapter has been completely revised ......一起来看看 《Compilers》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

在线进制转换器
在线进制转换器

各进制数互转换器

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码