@ProviderType
public interface Consumer
Consumer objects are used to receive messages from the Solace Messaging Platform.
Note: Applications must cache this instance, and close it only when it is no longer required.
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the message consumer, rendering it unusable.
|
boolean |
isClosed()
Checks if message consumer is closed
|
BytesXMLMessage |
receive()
Receives the next available message, waiting until one is available.
|
BytesXMLMessage |
receive(int timeoutInMillis)
Receives the next available message.
|
BytesXMLMessage |
receiveNoWait()
Receives the next available message.
|
void |
start()
Enables receiving messages from an appliance.
|
void |
stop()
Disables receiving messages from an appliance.
|
void close()
Once closed, an application acquires a new instance in order to continue to receive messages.
New messages will not be processed and delivered after a call to
close() returns, although it is possible for a single asynchronous
message delivery to occur if it has already begun when
close() is called.
boolean isClosed()
true if message consumer is closed, false otherwisevoid start()
throws JCSMPException
JCSMPException - upon errorInvalidOperationException - when called on a closed consumer.void stop()
Note that there is no guarantee the effect of calling stop()
will be instantaneous: messages already in-flight or being processed by
the API may still be delivered after the call to stop()
returns.
BytesXMLMessage receive() throws JCSMPException
InvalidOperationException - If the consumer is not started, or a message listener is set.JCSMPTransportException - If the consumer was closed after the function was called, but
before any message was received.JCSMPExceptionBytesXMLMessage receive(int timeoutInMillis) throws JCSMPException
timeoutInMillis is reached. A timeout of zero never expires,
and the call blocks indefinitely.
timeoutInMillis - The timeout in milliseconds.InvalidOperationException - If the consumer is not started, or a message listener is set.JCSMPTransportException - If the consumer was closed after the method was called, but
before any message was received.JCSMPExceptionBytesXMLMessage receiveNoWait() throws JCSMPException
null immediately.InvalidOperationException - If the consumer is not started, or a message listener is set.JCSMPTransportException - If the consumer was closed after the function was called but
before any message was received.JCSMPExceptionCopyright 2004-2025 Solace Corporation. All rights reserved.