{"id":44904202,"url":"https://github.com/dizitart/jbus","last_synced_at":"2026-02-17T22:08:52.364Z","repository":{"id":14579836,"uuid":"61626266","full_name":"dizitart/jbus","owner":"dizitart","description":"An Open Source Event Bus for Java 1.6+","archived":false,"fork":false,"pushed_at":"2023-03-10T18:56:47.000Z","size":147,"stargazers_count":10,"open_issues_count":7,"forks_count":2,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-07-07T17:45:16.079Z","etag":null,"topics":["event-bus","java","weak-references"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dizitart.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-06-21T10:47:05.000Z","updated_at":"2025-02-16T15:14:41.000Z","dependencies_parsed_at":"2023-09-29T08:50:28.990Z","dependency_job_id":null,"html_url":"https://github.com/dizitart/jbus","commit_stats":{"total_commits":82,"total_committers":3,"mean_commits":"27.333333333333332","dds":"0.30487804878048785","last_synced_commit":"590c1764a602c75cbba3d3fed26449ec3d0884b5"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/dizitart/jbus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dizitart%2Fjbus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dizitart%2Fjbus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dizitart%2Fjbus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dizitart%2Fjbus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dizitart","download_url":"https://codeload.github.com/dizitart/jbus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dizitart%2Fjbus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29559968,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T21:50:49.831Z","status":"ssl_error","status_checked_at":"2026-02-17T21:46:15.313Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["event-bus","java","weak-references"],"created_at":"2026-02-17T22:08:51.682Z","updated_at":"2026-02-17T22:08:52.359Z","avatar_url":"https://github.com/dizitart.png","language":"Java","funding_links":[],"categories":["进程间通信"],"sub_categories":["微服务框架"],"readme":"JBus\n=======\n\n[![Javadocs](https://www.javadoc.io/badge/org.dizitart/jbus.svg)](https://www.javadoc.io/doc/org.dizitart/jbus) \n![Build](https://github.com/dizitart/jbus/workflows/Build/badge.svg)\n[![codecov](https://codecov.io/gl/dizitart/jbus/branch/master/graph/badge.svg)](https://codecov.io/gl/dizitart/jbus)\n[![Code Triagers Badge](https://www.codetriage.com/dizitart/jbus/badges/users.svg)](https://www.codetriage.com/dizitart/jbus)\n\nAn event bus for java 1.6+. It dispatches event to registered listeners.\n\nIt is a simple but powerful publish-subscribe event system. It requires object to\nregister themselves with the event bus to receive events. This event bus is safe for\nconcurrent use.\n\nIt has the following features:\n\n * Light-weight but powerful\n * Annotation based API\n * Supports synchronous/asynchronous invocation of subscriber method\n * Handler chain interruption\n * Supports custom error handling\n * Supports strong/weak references of subscriber\n * Supports subscriber inheritance\n * Zero configuration\n * Optional JVM shutdown hook for graceful shutdown\n \nExample\n-------------------\n\n\u003ch5\u003eDefine events:\u003c/h5\u003e\n\n```java\n\n    public class UserEvent { \n        /* Additional fields if required */ \n    }\n    \n```\n\n\u003ch5\u003eCreate subscriber:\u003c/h5\u003e\n\n```java\n\n    public class Listener {\n        \n        @Subscribe\n        private void listen(UserEvent event) {\n            /* Your event handling code goes here */\n        }\n    }\n\n```\n \n\u003ch5\u003eRegister subscriber:\u003c/h5\u003e\n    \n```java\n    \n     JBus jbus = new JBus();\n     jbus.register(new Listener());   \n     // or to register with weak reference use jbus.registerWeak(new Listener());\n``` \n\n\u003ch5\u003ePost event:\u003c/h5\u003e\n\n```java\n\n    jbus.post(new UserEvent());\n\n```\n\nIt is that simple.\n\nInstallation\n-----------------------------\n\nJBus is available from the Maven Central Repository using the following coordinates:\n\n```xml\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.dizitart\u003c/groupId\u003e\n        \u003cartifactId\u003ejbus\u003c/artifactId\u003e\n        \u003cversion\u003e{latest.tag.release}\u003c/version\u003e\n    \u003c/dependency\u003e\n```\n\n\nDetails\n-----------------------------\n\nTo receive events from event bus, an object must:\n\n * register itself with the event bus via \u003ccode\u003ejbus.register(Object)\u003c/code\u003e or\n \u003ccode\u003ejbus.registerWeak(Object)\u003c/code\u003e method\n * have at least one method marked with \u003ccode\u003e@Subscribe\u003c/code\u003e annotation in its class hierarchy\n * subscribed method should accept \u003cb\u003eonly one parameter\u003c/b\u003e having the type of the event\n \nRegistration will scan the input object for any method which has been marked\nwith \u003ccode\u003e@Subscribe\u003c/code\u003e annotation and it will keep track of all such methods found. If the\nsubscribing method has more than one parameter, runtime will throw a \u003ccode\u003eJBusException\u003c/code\u003e\nduring registration. A subscriber method can have any access modifier. Registration will scan through\nfull class hierarchy of the input object including any super class and interfaces.\n\nUpon successful registration, the runtime will keep track of all subscriber methods\nfound along with a strong reference of the input object for future invocation. To store\na weak reference of the input object instead of a strong one, use the \u003ccode\u003ejbus.registerWeak(Object)\u003c/code\u003e\nvariant.\n\nA developer must use \u003ccode\u003ejbus.deregister(Object)\u003c/code\u003e for the object to stop receiving events. The\nbehavior of de-registration is not deterministic in the case of \u003cb\u003e\u003cem\u003eweak\nregistration\u003c/em\u003e\u003c/b\u003e of the object. As the runtime automatically cleans up any invalid weak\nreferences and any subscriber methods associated with it as it goes, so a call to\n\u003ccode\u003ejbus.deregister(Object)\u003c/code\u003e might not do anything if the object has already been garbage collected and \nthe event bus runtime has cleared up its records of subscriber methods already.\n\nTo post an event to the event bus, simply call jbus.post(Object) passing the event object. Event bus will\nautomatically route the event depending on its type to a handler chain. Handler chain is a collection of \nregistered subscribers of the event. By design, event bus does not support inheritance for the event object.\n\nIf an event implements \u003ccode\u003eHandlerChainAware\u003c/code\u003e interface then before each invocation, the runtime\nwill check if an interruption has been signalled from the subscriber code via \u003ccode\u003eHandlerChain.interrupt()\u003c/code\u003e\ncall. If interrupted, further invocation of the handler chain will be barred until the next \n\u003ccode\u003ejbus.post(Object)\u003c/code\u003e call for the event.\n\nSubscriber execution mode can be either \u003cem\u003esynchronous\u003c/em\u003e or \u003cem\u003easynchronous\u003c/em\u003e\ndepending on the \u003ccode\u003e@Subscribe\u003c/code\u003e annotation declaration.\n\nIn case of any error from subscriber code during invocation, the runtime will first search\nfor any \u003ccode\u003eExceptionEvent\u003c/code\u003e handler registered into the system and dispatch the error along with\nrelevant information in \u003ccode\u003eExceptionContext\u003c/code\u003e to the handler if found. If no such error handler\nis found, runtime will just log the error and move on.\n\n\nContribute\n--------------------------\nPlease feel free to contribute by creating a pull request.\nPlease make sure your pull request is small and provided with test code.\n\n\nLicense\n--------------------------\nThis project is distributed under the terms of the Apache License, Version 2.0.\nSee file \"LICENSE\" for further reference.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdizitart%2Fjbus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdizitart%2Fjbus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdizitart%2Fjbus/lists"}