Domain-Eventing implements the Domain Events concept from Eric Evans' Domain Driven Design. Enables simple messaging for domain models within a single JVM, or using a distributed event bus, message across a cluster of JVMs.
This simple Java library provides a Singleton interface (see DomainEvents class) to create event bus(ses) and to publish events (which are just POJOs) throughout the domain layer (POJOs must be Serializable for a distributed event bus).
Event handlers simply implement the EventHandler interface, which has two methods, handle(Object) and handles(Class). The handle() method is the implementation for processing the domain event and handles() returns a boolean indicating whether that particular EventHandler can process the given event.
Messaging systems or ESB (Enterprise Service Bus) are very heavy and resource intensive. Small, quick, inter-application messages don't usually need to be broadcast enterprise wide. For instance, within an eventual-consistency database model, cascade deletes may occur asynchronously, outside of the request. This is a great candidate for inter-application eventing instead of leveraging full-up JMS or other messaging system.
The domain eventing model supported is publish/subscribe (pub/sub)--sending messages to all subsribers that can process it. There is no concept within this library of point-to-point or single consumer for a message and is, therefore, left as an exercise for the reader... :-)
In this model, published events stay within the current Java virtual machine (JVM). This is the simplest and fastest option. However, as published events are in an in-memory queue, it is possible to lose messages if the JVM goes down unexpectedly.
Stable:
<dependency>
<groupId>com.strategicgains.domain-eventing</groupId>
<artifactId>domain-eventing-core</artifactId>
<version>1.0</version>
</dependency>
OR (for Akka-based eventing):
<dependency>
<groupId>com.strategicgains.domain-eventing</groupId>
<artifactId>domain-eventing-akka</artifactId>
<version>1.0</version>
</dependency>
Development:
<dependency>
<groupId>com.strategicgains.domain-eventing</groupId>
<artifactId>domain-eventing-core</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
OR (for Akka-based eventing):
<dependency>
<groupId>com.strategicgains.domain-eventing</groupId>
<artifactId>domain-eventing-akka</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
Or download the jar directly from: http://search.maven.org/#search%7Cga%7C1%7C%22domain-eventing%22
Note that to use the SNAPSHOT version, you must enable snapshots and a repository in your pom file as follows:
<profiles>
<profile>
<id>allow-snapshots</id>
<activation><activeByDefault>true</activeByDefault></activation>
<repositories>
<repository>
<id>snapshots-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
</profile>
</profiles>
- Introduced domain-eventing-kafka supporting Kafka-based eventing.
- Upgraded to Hazelcast version 3.6.2
- Upgraded version akka-actor_2.11 version 2.3.15
- Added domain-eventing-akka, supporting Akka-based eventing. Hazelcast eventing support will no longer be maintained unless somebody hollers.
- Requires Java 1.8 (due to Akka support).
- Fixed misspelling of method LocalEventBusBuilder.addPublishableEventType().
- Upgraded to Hazelcast 3.3 EA
- Updated Hazelcast from 2.4 to 2.5
- Introduced DomainEvents.publish(String, EventBus) to enable publishing to a specific, named EventBus implementation.
- Changed internal Map, handlersByEvent, to a ConcurrentHashMap instead of a HashMap, since it does get manipulated during execution.
- Removed Ant build-related files
- Ensured Java 1.6 compatible artifact is released.
- Introduced Maven build
- Released to Maven Central repository
- Introduced HazelCast for seamless intra-cluster (cross-node, multi-JVM) domain eventing.
- Removed constraint of having to implement DomainEvent marker interface in event messages.
- Introduced EventQueue, allowing multiple EventMonitor threads to be processing events from the queue simultaneously.
- Initial release.