org.qi4j.library.eventsourcing.domain.source.helper
Class EventRouter<T extends Throwable>
java.lang.Object
org.qi4j.library.eventsourcing.domain.source.helper.EventRouter<T>
- All Implemented Interfaces:
- Output<DomainEventValue,T>, Receiver<UnitOfWorkDomainEventsValue,T>
public class EventRouter<T extends Throwable>
- extends Object
- implements Output<DomainEventValue,T>, Receiver<UnitOfWorkDomainEventsValue,T>
Event handling router. Add specification->receiver routes. When an event comes in
the router will ask each specification if it matches, and if so, delegate to the
receiver and return whether it successfully handled it or not. If no routes match,
delegate to the default receiver
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
EventRouter
public EventRouter()
route
public EventRouter route(Specification<DomainEventValue> specification,
Receiver<DomainEventValue,T> receiver)
defaultReceiver
public EventRouter defaultReceiver(Receiver<DomainEventValue,T> defaultReceiver)
receiveFrom
public <SenderThrowableType extends Throwable> void receiveFrom(Sender<? extends DomainEventValue,SenderThrowableType> sender)
throws T extends Throwable,
SenderThrowableType extends Throwable
- Description copied from interface:
Output
- This initiates a transfer from an Input. Implementations should open any resources to be written to
and then call sender.sendTo() when it is ready to receive data. When sendTo() returns the resource should be
closed properly. Make sure to handle any exceptions from sendTo.
- Specified by:
receiveFrom
in interface Output<DomainEventValue,T extends Throwable>
- Type Parameters:
SenderThrowableType
- the exception that sendTo can throw- Parameters:
sender
- the sender of data to this output
- Throws:
SenderThrowableType
- the exception that the sender can throw
T extends Throwable
receive
public void receive(UnitOfWorkDomainEventsValue item)
throws T extends Throwable
- Description copied from interface:
Receiver
- Receive a single item of the given type. The receiver should process it
and optionally throw an exception if it fails.
- Specified by:
receive
in interface Receiver<UnitOfWorkDomainEventsValue,T extends Throwable>
- Throws:
T extends Throwable