Class SerializedMessageBusImpl
- java.lang.Object
-
- de.quantummaid.eventmaid.serializedMessageBus.SerializedMessageBusImpl
-
- All Implemented Interfaces:
SerializedMessageBus
public class SerializedMessageBusImpl extends Object implements SerializedMessageBus
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PayloadAndErrorPayload<Object,Object>invokeAndWait(EventType eventType, Object data)Sends the data and waits for a matching response or an exception.PayloadAndErrorPayload<Object,Object>invokeAndWait(EventType eventType, Object data, long timeout, TimeUnit unit)Sends the data and waits for a matching response, an exception or the timeout to expire.<P,E>
PayloadAndErrorPayload<P,E>invokeAndWaitDeserialized(EventType eventType, Object data, Class<P> responseClass, Class<E> errorPayloadClass)Serializes and sends the data on theMessageBus.<P,E>
PayloadAndErrorPayload<P,E>invokeAndWaitDeserialized(EventType eventType, Object data, Class<P> responseClass, Class<E> errorPayloadClass, long timeout, TimeUnit unit)Serializes and sends the data on theMessageBus.PayloadAndErrorPayload<Object,Object>invokeAndWaitSerializedOnly(EventType eventType, Object data)Serializes the data before sending it and waiting for a matching response or an exception.PayloadAndErrorPayload<Object,Object>invokeAndWaitSerializedOnly(EventType eventType, Object data, long timeout, TimeUnit unit)Serializes the data before sending it and waiting for a matching response, an exception or the expiration of the timeout.MessageIdsend(EventType eventType, Object data)Sends the given data in form of aMapon theMessageBuswith theEventType.MessageIdsend(EventType eventType, Object data, CorrelationId correlationId)Sends the given data in form of aMapon theMessageBuswith theEventTypeandCorrelationIdset.MessageIdsend(EventType eventType, Object data, Object errorData)Sends the given data and error data both in form of aMapon theMessageBuswith theEventType.MessageIdsend(EventType eventType, Object data, Object errorData, CorrelationId correlationId)Sends the given data and error data both in form of aMapon theMessageBuswith theEventTypeandCorrelationId.MessageIdserializeAndSend(EventType eventType, Object data)MessageIdserializeAndSend(EventType eventType, Object data, CorrelationId correlationId)Serializes the data to aMapand then sends it with theEventTypeandCorrelationIdon theMessageBus.MessageIdserializeAndSend(EventType eventType, Object data, Object errorData)Serializes the data and error data to aMapand then sends both with theEventTypeon theMessageBus.MessageIdserializeAndSend(EventType eventType, Object data, Object errorData, CorrelationId correlationId)Serializes the data and error data to aMapand then sends both with theEventTypeandCorrelationIdon theMessageBus.SubscriptionIdsubscribe(CorrelationId correlationId, Subscriber<PayloadAndErrorPayload<Map<String,Object>,Map<String,Object>>> subscriber)Adds the givenSubscriberfor all not deserialized messages of the givenCorrelationId.SubscriptionIdsubscribe(EventType eventType, Subscriber<PayloadAndErrorPayload<Map<String,Object>,Map<String,Object>>> subscriber)Adds the givenSubscriberfor all not deserialized messages of the givenEventType.<P,E>
SubscriptionIdsubscribeDeserialized(CorrelationId correlationId, Subscriber<PayloadAndErrorPayload<P,E>> subscriber, Class<P> responseClass, Class<E> errorClass)Adds the givenSubscriberfor all messages of the givenEventType.<P,E>
SubscriptionIdsubscribeDeserialized(EventType eventType, Subscriber<PayloadAndErrorPayload<P,E>> subscriber, Class<P> responseClass, Class<E> errorClass)Adds the givenSubscriberfor all messages of the givenEventType.SubscriptionIdsubscribeRaw(EventType eventType, Subscriber<ProcessingContext<Map<String,Object>>> subscriber)Adds theSubscriberwith access to the rawProcessingContextfor all messages of theEventType.voidunsubscribe(SubscriptionId subscriptionId)Removes allSubscriberswith the givenSubscriptionId.
-
-
-
Method Detail
-
send
public MessageId send(EventType eventType, Object data)
Description copied from interface:SerializedMessageBusSends the given data in form of aMapon theMessageBuswith theEventType.- Specified by:
sendin interfaceSerializedMessageBus- Parameters:
eventType- theEventTypeto relate the message todata- the data to send- Returns:
- a unique
MessageIdfor the message
-
send
public MessageId send(EventType eventType, Object data, CorrelationId correlationId)
Description copied from interface:SerializedMessageBusSends the given data in form of aMapon theMessageBuswith theEventTypeandCorrelationIdset.- Specified by:
sendin interfaceSerializedMessageBus- Parameters:
eventType- theEventTypeto relate the message todata- the data to sendcorrelationId- theCorrelationIdrelating to a previousMessageId- Returns:
- a unique
MessageIdfor the message
-
send
public MessageId send(EventType eventType, Object data, Object errorData)
Description copied from interface:SerializedMessageBusSends the given data and error data both in form of aMapon theMessageBuswith theEventType.- Specified by:
sendin interfaceSerializedMessageBus- Parameters:
eventType- theEventTypeto relate the message todata- the data to senderrorData- the error data to send- Returns:
- a unique
MessageIdfor the message
-
send
public MessageId send(EventType eventType, Object data, Object errorData, CorrelationId correlationId)
Description copied from interface:SerializedMessageBusSends the given data and error data both in form of aMapon theMessageBuswith theEventTypeandCorrelationId.- Specified by:
sendin interfaceSerializedMessageBus- Parameters:
eventType- theEventTypeto relate the message todata- the data to senderrorData- the error data to sendcorrelationId- theCorrelationIdrelating to a previousMessageId- Returns:
- a unique
MessageIdfor the message
-
serializeAndSend
public MessageId serializeAndSend(EventType eventType, Object data)
Description copied from interface:SerializedMessageBus- Specified by:
serializeAndSendin interfaceSerializedMessageBus- Parameters:
eventType- theEventTypeto relate the message todata- the data to serialize and send- Returns:
- a unique
MessageIdfor the message
-
serializeAndSend
public MessageId serializeAndSend(EventType eventType, Object data, CorrelationId correlationId)
Description copied from interface:SerializedMessageBusSerializes the data to aMapand then sends it with theEventTypeandCorrelationIdon theMessageBus.- Specified by:
serializeAndSendin interfaceSerializedMessageBus- Parameters:
eventType- theEventTypeto relate the message todata- the data to serialize and sendcorrelationId- theCorrelationIdrelating to a previousMessageId- Returns:
- a unique
MessageIdfor the message
-
serializeAndSend
public MessageId serializeAndSend(EventType eventType, Object data, Object errorData)
Description copied from interface:SerializedMessageBusSerializes the data and error data to aMapand then sends both with theEventTypeon theMessageBus.- Specified by:
serializeAndSendin interfaceSerializedMessageBus- Parameters:
eventType- theEventTypeto relate the message todata- the data to serialize and senderrorData- the error data to send- Returns:
- a unique
MessageIdfor the message
-
serializeAndSend
public MessageId serializeAndSend(EventType eventType, Object data, Object errorData, CorrelationId correlationId)
Description copied from interface:SerializedMessageBusSerializes the data and error data to aMapand then sends both with theEventTypeandCorrelationIdon theMessageBus.- Specified by:
serializeAndSendin interfaceSerializedMessageBus- Parameters:
eventType- theEventTypeto relate the message todata- the data to serialize and senderrorData- the error data to sendcorrelationId- theCorrelationIdrelating to a previousMessageId- Returns:
- a unique
MessageIdfor the message
-
invokeAndWait
public PayloadAndErrorPayload<Object,Object> invokeAndWait(EventType eventType, Object data) throws ExecutionException, InterruptedException
Description copied from interface:SerializedMessageBusSends the data and waits for a matching response or an exception.- Specified by:
invokeAndWaitin interfaceSerializedMessageBus- Parameters:
eventType- theEventTypeto relate the message todata- the error data to send- Returns:
- the not deserialized normal and error payload
- Throws:
ExecutionException- if the message or response caused an exceptionInterruptedException- if the waitingThreadis interrupted
-
invokeAndWait
public PayloadAndErrorPayload<Object,Object> invokeAndWait(EventType eventType, Object data, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
Description copied from interface:SerializedMessageBusSends the data and waits for a matching response, an exception or the timeout to expire.- Specified by:
invokeAndWaitin interfaceSerializedMessageBus- Parameters:
eventType- theEventTypeto relate the message todata- the error data to sendtimeout- the timeout intervalunit- the unit to measure the interval in- Returns:
- the not deserialized normal and error payload
- Throws:
InterruptedException- if the waitingThreadis interruptedExecutionException- if the message or response caused an exceptionTimeoutException- if the timeout expired
-
invokeAndWaitSerializedOnly
public PayloadAndErrorPayload<Object,Object> invokeAndWaitSerializedOnly(EventType eventType, Object data) throws InterruptedException, ExecutionException
Description copied from interface:SerializedMessageBusSerializes the data before sending it and waiting for a matching response or an exception.- Specified by:
invokeAndWaitSerializedOnlyin interfaceSerializedMessageBus- Parameters:
eventType- theEventTypeto relate the message todata- the error data to send- Returns:
- the not deserialized normal and error payload
- Throws:
InterruptedException- if the waitingThreadis interruptedExecutionException- if the message or response caused an exception
-
invokeAndWaitSerializedOnly
public PayloadAndErrorPayload<Object,Object> invokeAndWaitSerializedOnly(EventType eventType, Object data, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
Description copied from interface:SerializedMessageBusSerializes the data before sending it and waiting for a matching response, an exception or the expiration of the timeout.- Specified by:
invokeAndWaitSerializedOnlyin interfaceSerializedMessageBus- Parameters:
eventType- theEventTypeto relate the message todata- the error data to sendtimeout- the timeout intervalunit- the unit to measure the interval in- Returns:
- the not deserialized normal and error payload
- Throws:
InterruptedException- if the waitingThreadis interruptedExecutionException- if the message or response caused an exceptionTimeoutException- if the timeout expired
-
invokeAndWaitDeserialized
public <P,E> PayloadAndErrorPayload<P,E> invokeAndWaitDeserialized(EventType eventType, Object data, Class<P> responseClass, Class<E> errorPayloadClass) throws InterruptedException, ExecutionException
Description copied from interface:SerializedMessageBusSerializes and sends the data on theMessageBus. Then the methods waits until a response is received or an exception occurred. The response is deserialized into the two given classes.- Specified by:
invokeAndWaitDeserializedin interfaceSerializedMessageBus- Type Parameters:
P- the type to deserialize the normal response toE- the type to deserialize the error response to- Parameters:
eventType- theEventTypeto relate the message todata- the error data to sendresponseClass- the class to deserialize the normal response toerrorPayloadClass- the class to deserialize the error response to- Returns:
- the deserialized normal and error payload
- Throws:
InterruptedException- if the waitingThreadis interruptedExecutionException- if the message or response caused an exception
-
invokeAndWaitDeserialized
public <P,E> PayloadAndErrorPayload<P,E> invokeAndWaitDeserialized(EventType eventType, Object data, Class<P> responseClass, Class<E> errorPayloadClass, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
Description copied from interface:SerializedMessageBusSerializes and sends the data on theMessageBus. Then the methods waits until a response is received, an exception occurred or the timeout expired. The response is deserialized into the two given classes.- Specified by:
invokeAndWaitDeserializedin interfaceSerializedMessageBus- Type Parameters:
P- the type to deserialize the normal response toE- the type to deserialize the error response to- Parameters:
eventType- theEventTypeto relate the message todata- the error data to sendresponseClass- the class to deserialize the normal response toerrorPayloadClass- the class to deserialize the error response totimeout- the timeout intervalunit- the unit to measure the interval in- Returns:
- the deserialized normal and error payload
- Throws:
InterruptedException- if the waitingThreadis interruptedExecutionException- if the message or response caused an exceptionTimeoutException- if the timeout expired
-
subscribe
public SubscriptionId subscribe(EventType eventType, Subscriber<PayloadAndErrorPayload<Map<String,Object>,Map<String,Object>>> subscriber)
Description copied from interface:SerializedMessageBusAdds the givenSubscriberfor all not deserialized messages of the givenEventType.- Specified by:
subscribein interfaceSerializedMessageBus- Parameters:
eventType- theEventTypeof the messages to receivesubscriber- theSubscriberto invoke- Returns:
- a
SubscriptionIdto identify theSubscriber
-
subscribe
public SubscriptionId subscribe(CorrelationId correlationId, Subscriber<PayloadAndErrorPayload<Map<String,Object>,Map<String,Object>>> subscriber)
Description copied from interface:SerializedMessageBusAdds the givenSubscriberfor all not deserialized messages of the givenCorrelationId.- Specified by:
subscribein interfaceSerializedMessageBus- Parameters:
correlationId- theCorrelationIdof the messages to receivesubscriber- theSubscriberto invoke- Returns:
- a
SubscriptionIdto identify theSubscriber
-
subscribeDeserialized
public <P,E> SubscriptionId subscribeDeserialized(EventType eventType, Subscriber<PayloadAndErrorPayload<P,E>> subscriber, Class<P> responseClass, Class<E> errorClass)
Description copied from interface:SerializedMessageBusAdds the givenSubscriberfor all messages of the givenEventType. The normal and error payload are deserialized into the to givenClasses.- Specified by:
subscribeDeserializedin interfaceSerializedMessageBus- Type Parameters:
P- the type to deserialize the normal payload intoE- the type to deserialize the error payload into- Parameters:
eventType- theEventTypeof the messages to receivesubscriber- theSubscriberto invokeresponseClass- theClassto deserialize the normal payload intoerrorClass- theClassto deserialize the error payload into- Returns:
- a
SubscriptionIdto identify theSubscriber
-
subscribeDeserialized
public <P,E> SubscriptionId subscribeDeserialized(CorrelationId correlationId, Subscriber<PayloadAndErrorPayload<P,E>> subscriber, Class<P> responseClass, Class<E> errorClass)
Description copied from interface:SerializedMessageBusAdds the givenSubscriberfor all messages of the givenEventType. The normal and error payload are deserialized into the to givenClasses.- Specified by:
subscribeDeserializedin interfaceSerializedMessageBus- Type Parameters:
P- the type to deserialize the normal payload intoE- the type to deserialize the error payload into- Parameters:
correlationId- theCorrelationIdof the messages to receivesubscriber- theSubscriberto invokeresponseClass- theClassto deserialize the normal payload intoerrorClass- theClassto deserialize the error payload into- Returns:
- a
SubscriptionIdto identify theSubscriber
-
subscribeRaw
public SubscriptionId subscribeRaw(EventType eventType, Subscriber<ProcessingContext<Map<String,Object>>> subscriber)
Description copied from interface:SerializedMessageBusAdds theSubscriberwith access to the rawProcessingContextfor all messages of theEventType.- Specified by:
subscribeRawin interfaceSerializedMessageBus- Parameters:
eventType- theEventTypeof the messages to receivesubscriber- theSubscriberto invoke- Returns:
- a
SubscriptionIdto identify theSubscriber
-
unsubscribe
public void unsubscribe(SubscriptionId subscriptionId)
Description copied from interface:SerializedMessageBusRemoves allSubscriberswith the givenSubscriptionId.- Specified by:
unsubscribein interfaceSerializedMessageBus- Parameters:
subscriptionId- theSubscriptionIdto remove
-
-