Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Maven Central javadoc jooby-eventbus website

EventBus

EventBus is an open-source library for Java using the publisher/subscriber pattern for loose coupling. EventBus enables central communication to decoupled classes with just a few lines of code – simplifying the code, removing dependencies, and speeding up app development.

exports

  • An EventBus

dependency

<dependency>
 <groupId>org.jooby</groupId>
 <artifactId>jooby-eventbus</artifactId>
 <version>1.5.0</version>
</dependency>

usage

{
  use(new EventBusby()
    .register(new MySubscriber())
  );

  post("/message", req -> {
    EventBus bus = require(EventBus.class);
    MessageEvent event = req.body(MessageEvent.class);
    bus.post(event);
  });
}

guice subscribers

EventBus module supports Guice subscribers:

{
  use(new EventBusby()
    .register(MySubscriber.class)
  );

}

Here the MySubscriber class will be provisioned by Guice.

custom EventBus

Jooby uses the default EventBus: EventBus.getDefault(), you can provide a custom EventBus at creation time:

{
  use(new EventBusby(() -> {
    return EventBus.builder()
      .logNoSubscriberMessages(false)
      .sendNoSubscriberEvent(false)
      .build();
  }));

}

That's all! Happy coding!!