Interface UseCaseBus


  • public interface UseCaseBus
    The use case bus invokes use cases as defined by UseCaseInvocationBuilder. Requests are serialized using the defined Serializer. All methods wait until a fitting response was received and can optionally deserialized with the defined Deserializer.
    • Method Detail

      • invokeAndWait

        <P,​E> PayloadAndErrorPayload<P,​E> invokeAndWait​(EventType eventType,
                                                                    Object data,
                                                                    Class<P> payloadClass,
                                                                    Class<E> errorPayloadClass,
                                                                    long timeout,
                                                                    TimeUnit unit)
                                                             throws InterruptedException,
                                                                    ExecutionException,
                                                                    TimeoutException
        Invokes the correct use case based on the EventType with the send data, which is serialized before sending it. The method waits until a response is received, an exception occurred or the timeout expired. The response is deserialized based on the given classes.
        Type Parameters:
        P - the type to serialize the response payload to
        E - the type to serialize the error response payload to
        Parameters:
        eventType - the EventType to send the request on
        data - the request data
        payloadClass - the class to serialize the response payload to
        errorPayloadClass - the class to serialize the error response payload to
        timeout - the interval to wait
        unit - the unit to define the interval
        Returns:
        the deserialized response
        Throws:
        InterruptedException - if the waiting Thread was interrupted
        ExecutionException - if an exception occurred
        TimeoutException - if the timeout expires