DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations

Event-Driven Development With Mycila Event

Mathieu Carbou user avatar by
Mathieu Carbou
·
Feb. 26, 10 · Interview
Like (0)
Save
Tweet
Share
6.81K Views

Join the DZone community and get the full member experience.

Join For Free

I am working on the backend of a high performance clustered system involving JGroups, JMS, and other very cool technologies. To achieve best performance, the application is totally event-driven, by using a very cool library i Open-Sourced: Mycila Event. I needed an intra-process Event Dispatching System capable of handling million events in a few second, while having a totally customizable threading model. In this application, this event system is internally bridged with JMS and JGroups to provide access to both messaging systems from Mycila Event.

I firstly considered using Event-Bus, a well known intra-process event library largely used in Swing applications. But it miss a lot of things we needed: a very good annotation support, a pluggable API, threading model customization and better topic matching strategies. I also really considered using Esper. Esper is a very good CEP engine capable of processing events (aggregate, filter, ...) in addition to being a very good event dispatching system. But what we needed is to depend on a high level Event Dispatching API with a very good annotation support, with the possibility to plug any Event Dispacthing library. We also didn't need the processing features of Esper, but instead we needed a very high performance dispatcher, only working in-memory.

Thus, Mycila-Event stands between Event-Bus and Esper. It brings you a common Event Dispatching API with a very good annotation support, plus provides you with a default implementation with several threading models, and you can create your own ones. Its goal is not to be an event-processor system (event if it actually could be integrated with Esper with the common API we designed). Instead, its goal is to be the best customizable dispatching system.

Here are some of the features Mycila Event brings:

  • High level Event API with Annotation support, compatible with any event dispacther (event-bus, Esper, ...)
  • High performance event dispatcher
  • Customizable dispatching strategies (control how dispatching is done)
  • Customizable threading model (provide your own Executors)
  • Asynchronous mode (publishing/subscribing)
  • Synchronous mode (requesting/replying) with timeout support
  • Mixed mode: requesting with asynchronous replies
  • Topic matchers and composition functions (i.e. subscribe to all topics app/events/system/**)
  • Exception handling is made possible to react upon subscriber errors
  • Automatic generation of publishers
  • Very good integration with Google Guice
  • Possible integration with Spring, Esper, Camel, JMS, ...

Everybody knows the publisher subscriber pattern. But here is a sample how to write a request/reply which goes through the event dispatcher:

static abstract class DU {
@Request(topic = "system/mult")
abstract int mult(int p1, int p2);

@Answers(topics = "system/mult")
int multRequest(int p1, int p2) {
return p1 * p2;
}
}

Dispatcher dispatcher = Dispatchers.synchronousSafe(ErrorHandlers.rethrow());
AnnotationProcessor processor = AnnotationProcessors.create(dispatcher);
Du du = processor.proxy(DU.class);
assertEquals(30, du.mult(5, 6))

Without annotations, you can publish a message like this:

Dispatcher dispatcher = Dispatchers.synchronousUnsafe(ErrorHandlers.rethrow());
TopicMatcher matcher = only("app/events/swing/button").or(matching("app/events/swing/fields/**"));

dispatcher.subscribe(matcher, String.class, new Subscriber<String>() {
public void onEvent(Event<String> event) throws Exception {
System.out.println("Received: " + event.getSource());
}
});

dispatcher.publish(topic("app/events/swing/button"), "Hello !");

You can read the full documentation and download Mycila Event from project page at:

http://code.mycila.com/wiki/MycilaEvent

Math'

Event

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Integrate AWS Secrets Manager in Spring Boot Application
  • Seamless Integration of Azure Functions With SQL Server: A Developer's Perspective
  • Chaos Engineering Tutorial: Comprehensive Guide With Best Practices
  • Old School or Still Cool? Top Reasons To Choose ETL Over ELT

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: