@ProviderType public interface PersistentMessageReceiver extends MessageReceiver, ReceiverFlowControl, ReceiverSubscriptions, AsyncReceiverSubscriptions, AcknowledgementSupport
WARNING:
Co-usage of async and blocking message receiving methods on a single instance of receiver can have some not intended side effects and should be avoided.
'Async' methods should NOT be called multiple times or in combination with blocking message receiving method on a same instance of a MessageReceiver to avoid any not intended side effects.
MessageReceiver.FailedReceiveEvent, MessageReceiver.InboundMessageSupplier, MessageReceiver.MessageHandler, MessageReceiver.ReceiveFailureListenerLifecycleControl.TerminationEvent, LifecycleControl.TerminationNotificationListenerManageableReceiver.DirectReceiverInfo, ManageableReceiver.PersistentReceiverInfoAsyncReceiverSubscriptions.SubscriptionChangeListener| Modifier and Type | Method and Description |
|---|---|
void |
receiveAsync(MessageReceiver.MessageHandler messageHandler)
Request to register an async message handler.
|
void |
receiveAsync(MessageReceiver.MessageHandler messageHandler,
ExecutorService executorService)
Request to register an async message handler using own thread executor for callbacks.
|
InboundMessage |
receiveMessage()
Blocking request to receive a next message.
|
InboundMessage |
receiveMessage(long timeOut)
Temporarily blocking request to receive a next message;
|
InboundMessage |
receiveOrElse(MessageReceiver.InboundMessageSupplier supplierOfAlternativeResponse)
Request to receive a next message, when no message available, given supplier is used to
generate a response, this method is nonblocking.
|
ManageableReceiver.PersistentReceiverInfo |
receiverInfo()
Provides access to the receiver information.
|
PersistentMessageReceiver |
start()
Enables service regular duties.
|
<PersistentMessageReceiver> |
startAsync()
Asynchronously starts service for consuming/publishing operations.
|
<PersistentMessageReceiver> |
startAsync(CompletionListener<PersistentMessageReceiver> startListener)
Asynchronously starts service for consuming/publishing operations using a callback for
completion notification.
|
setReceiveFailureListenerisRunning, isTerminated, isTerminating, setTerminationNotificationListener, terminateterminateAsync, terminateAsyncpause, resumeaddSubscription, removeSubscriptionaddSubscriptionAsync, removeSubscriptionAsyncack, settlevoid receiveAsync(MessageReceiver.MessageHandler messageHandler) throws PubSubPlusClientException
This method represents push- based non blocking interface. Callback method of a message handler will be executed on an internal API thread.
If enabled, auto-ack is going to be performed when message processing callback method is finished without an error, do not use another thread to process message within a callback method, auto ack not going to be accurate in this case.
Note: usage of receiveAsync method is CURRENTLY mutually exclusive with a non async
methods receiveMessage and can be used once only
messageHandler - handler which is used to process each message asynchronously, not
expected to be nullPubSubPlusClientException - is thrown when messages handler can't be registeredvoid receiveAsync(MessageReceiver.MessageHandler messageHandler, ExecutorService executorService) throws PubSubPlusClientException
If enabled auto-ack is going to be performed performed when message processing callback method is finished without an error, do not use another thread to process message within a callback method, auto ack not going to be accurate in this case.
Note: usage of receiveAsync method is CURRENTLY mutually exclusive with a non async
OR sync methods and can be used once only
messageHandler - message handler, to handle sequence of inbound messagesexecutorService - user provided instance of thread executor for message scheduling and *
MessageReceiver.MessageHandler.onMessage(InboundMessage)
execution.
IMPORTANT NOTE: Shutdown of the Executor service or any another maintenance work is responsibility of the developer.
IMPORTANT NOTE: when message order needs to be preserved, a SINGLE thread based executor is required.
PubSubPlusClientException - for any of listed below reasonsInboundMessage receiveMessage() throws PubSubPlusClientException, PubSubPlusClientException.RequestInterruptedException
Acknowledgement can be performed using a this.ack(inboundMessage) where this refers to the current instance of PersistentMessageReceiver
This method can be used individually or usually in a while loop.
Usage of this method is CURRENTLY mutually exclusive with async methods
PubSubPlusClientException - when message could not be receivedPubSubPlusClientException.RequestInterruptedException - when thread was interrupted while waiting for a next
message. An interrupted flag is expected to be set on a
thread in this caseInboundMessage receiveMessage(long timeOut) throws PubSubPlusClientException, PubSubPlusClientException.RequestInterruptedException
Acknowledgement can be performed using a this.ack(inboundMessage) where this refers to the current instance of PersistentMessageReceiver
This method can be used individually or usually in a while loop.
Usage of this method is CURRENTLY mutually exclusive with async methods
timeOut - time out in milliseconds after that blocking receive exits, values >
0 are expected, use receiveOrElse (..) method when immediate response is
requirednull, when no new message could be received be received
and a timeout occurredPubSubPlusClientException - when message could not be receivedPubSubPlusClientException.RequestInterruptedException - when thread was interrupted while waiting for a next
message. An interrupted flag is expected to be set on aInboundMessage receiveOrElse(MessageReceiver.InboundMessageSupplier supplierOfAlternativeResponse)
supplierOfAlternativeResponse - supplies alternative response if no new message is
availableManageableReceiver.PersistentReceiverInfo receiverInfo()
ManageableReceiverreceiverInfo in interface ManageableReceiverReceiverInfo object that represents message receiver manageability.PersistentMessageReceiver start() throws PubSubPlusClientException
LifecycleControlstart in interface LifecycleControlstart in interface MessageReceiverPubSubPlusClientException - if the instance fails to start for some internal reason<PersistentMessageReceiver> CompletableFuture<PersistentMessageReceiver> startAsync()
AsyncLifecycleControlThis method is an idempotent operation when no another connect/disconnect operation is ongoing.
startAsync in interface AsyncLifecycleControlstartAsync in interface MessageReceiver<PersistentMessageReceiver> void startAsync(CompletionListener<PersistentMessageReceiver> startListener) throws PubSubPlusClientException, IllegalStateException
AsyncLifecycleControlstartAsync in interface AsyncLifecycleControlPersistentMessageReceiver - the type of response returned on a successful start operationstartListener - the callback for future notifications about the completion of the start
processPubSubPlusClientException - if the messaging service will not start in the futureIllegalStateException - if the method has been invoked at an illegal or inappropriate
timeCopyright 2019-2025 Solace Corporation. All rights reserved.