@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.ReceiveFailureListener
LifecycleControl.TerminationEvent, LifecycleControl.TerminationNotificationListener
ManageableReceiver.DirectReceiverInfo, ManageableReceiver.PersistentReceiverInfo
AsyncReceiverSubscriptions.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.
|
setReceiveFailureListener
isRunning, isTerminated, isTerminating, setTerminationNotificationListener, terminate
terminateAsync, terminateAsync
pause, resume
addSubscription, removeSubscription
addSubscriptionAsync, removeSubscriptionAsync
ack, settle
void 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 null
PubSubPlusClientException
- 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()
ManageableReceiver
receiverInfo
in interface ManageableReceiver
ReceiverInfo
object that represents message receiver manageability.PersistentMessageReceiver start() throws PubSubPlusClientException
LifecycleControl
start
in interface LifecycleControl
start
in interface MessageReceiver
PubSubPlusClientException
- if the instance fails to start for some internal reason<PersistentMessageReceiver> CompletableFuture<PersistentMessageReceiver> startAsync()
AsyncLifecycleControl
This method is an idempotent operation when no another connect/disconnect operation is ongoing.
startAsync
in interface AsyncLifecycleControl
startAsync
in interface MessageReceiver
<PersistentMessageReceiver> void startAsync(CompletionListener<PersistentMessageReceiver> startListener) throws PubSubPlusClientException, IllegalStateException
AsyncLifecycleControl
startAsync
in interface AsyncLifecycleControl
PersistentMessageReceiver
- 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-2024 Solace Corporation. All rights reserved.