Interface GenMessagingClient
-
- All Superinterfaces:
java.lang.AutoCloseable
,java.io.Closeable
public interface GenMessagingClient extends java.io.Closeable
Defines the interface of a messaging client.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description io.vavr.control.Either<java.lang.Throwable,Message>
readSync(java.lang.String readCmdMessageTopic, Message readCmdMessage, java.lang.String inMessageTopic, MessageFilterHandler messageFilterHandler, long timeoutMs)
Subscribes to a topic and returns a completable future that provides the next message from the given topic.java.util.concurrent.CompletableFuture<io.vavr.control.Either<java.lang.Throwable,java.lang.Void>>
sendAsynch(java.lang.String topic, Message message)
Sends a message asynchronously to a given topic.void
sendSync(java.lang.String topic, Message message)
This method publishes a message to the given topic.void
subscribe(java.lang.String topic, MessageFilterHandler messageFilterHandler, java.util.function.Consumer<io.vavr.control.Either<java.lang.Throwable,Message>> callback)
Subscribes to a topic for receiving a stream of messages.void
unsubscribe(java.lang.String topic)
Unsubscribes message handlers from a topic.
-
-
-
Method Detail
-
sendSync
void sendSync(java.lang.String topic, Message message)
This method publishes a message to the given topic. The method is blocking until the message is acknowledged by the message broker.- Parameters:
topic
- The topic to send the message tomessage
- The message to send
-
readSync
io.vavr.control.Either<java.lang.Throwable,Message> readSync(java.lang.String readCmdMessageTopic, Message readCmdMessage, java.lang.String inMessageTopic, MessageFilterHandler messageFilterHandler, long timeoutMs)
Subscribes to a topic and returns a completable future that provides the next message from the given topic. Used to receive the response message of a read-value message/command.- Parameters:
readCmdMessageTopic
- The topic to issue a read command that triggers a response messagereadCmdMessage
- The read command message that triggers the response messageinMessageTopic
- The topic that receives the response messagemessageFilterHandler
- An optional filter that filters messages received on theinMessageTopic
timeoutMs
- A message timeout, in ms- Returns:
- Either the message received or a Throwable if an error occurred.
-
sendAsynch
java.util.concurrent.CompletableFuture<io.vavr.control.Either<java.lang.Throwable,java.lang.Void>> sendAsynch(java.lang.String topic, Message message)
Sends a message asynchronously to a given topic. The method does not block and returns immediately without checking the ACK for the message to be sent. However, you could await the ACK when waiting for the completable future that is returned.- Parameters:
topic
- The topic to send the message tomessage
- The message- Returns:
- A completable future to (optionally) wait for the broker ACK that the message has been sent.
-
subscribe
void subscribe(java.lang.String topic, MessageFilterHandler messageFilterHandler, java.util.function.Consumer<io.vavr.control.Either<java.lang.Throwable,Message>> callback) throws GenDriverException
Subscribes to a topic for receiving a stream of messages.- Parameters:
topic
- The topic to subscribe tomessageFilterHandler
- An optional filter to filter messages received on thetopic
callback
- The callback method that handles the incoming messages- Throws:
GenDriverException
- when an error occurred
-
unsubscribe
void unsubscribe(java.lang.String topic) throws GenDriverException
Unsubscribes message handlers from a topic.- Parameters:
topic
- The topic to unsubscribe from- Throws:
GenDriverException
- when an error occurred
-
-