public class MessageFeedbackProcessorClient extends Object
This client relies on a persistent amqp/amqp_ws connection to IoT Hub that may break due to network instability.
While optional to monitor, users are highly encouraged to utilize the errorProcessorHandler defined in the
MessageFeedbackProcessorClientOptions
when constructing this client in order to monitor the connection state and to re-open
the connection when needed. See the message feedback processor client sample in this repo for best practices for
monitoring and handling disconnection events.
Constructor and Description |
---|
MessageFeedbackProcessorClient(String hostName,
com.azure.core.credential.AzureSasCredential azureSasCredential,
IotHubServiceClientProtocol protocol,
Function<FeedbackBatch,AcknowledgementType> feedbackMessageProcessor)
Construct a MessageFeedbackProcessorClient using a
AzureSasCredential instance for authentication. |
MessageFeedbackProcessorClient(String hostName,
com.azure.core.credential.AzureSasCredential azureSasCredential,
IotHubServiceClientProtocol protocol,
Function<FeedbackBatch,AcknowledgementType> feedbackMessageProcessor,
MessageFeedbackProcessorClientOptions options)
Construct a MessageFeedbackProcessorClient using a
AzureSasCredential instance for authentication. |
MessageFeedbackProcessorClient(String connectionString,
IotHubServiceClientProtocol protocol,
Function<FeedbackBatch,AcknowledgementType> feedbackMessageProcessor)
Construct a MessageFeedbackProcessorClient from the provided connection string.
|
MessageFeedbackProcessorClient(String connectionString,
IotHubServiceClientProtocol protocol,
Function<FeedbackBatch,AcknowledgementType> feedbackMessageProcessor,
MessageFeedbackProcessorClientOptions options)
Construct a MessageFeedbackProcessorClient from the provided connection string.
|
MessageFeedbackProcessorClient(String hostName,
com.azure.core.credential.TokenCredential credential,
IotHubServiceClientProtocol protocol,
Function<FeedbackBatch,AcknowledgementType> feedbackMessageProcessor)
Construct a MessageFeedbackProcessorClient using a
TokenCredential instance for authentication. |
MessageFeedbackProcessorClient(String hostName,
com.azure.core.credential.TokenCredential credential,
IotHubServiceClientProtocol protocol,
Function<FeedbackBatch,AcknowledgementType> feedbackMessageProcessor,
MessageFeedbackProcessorClientOptions options)
Construct a MessageFeedbackProcessorClient using a
TokenCredential instance for authentication. |
Modifier and Type | Method and Description |
---|---|
boolean |
isRunning()
Returns true if this client's underlying amqp connection is currently open and false otherwise.
|
void |
start()
Open this client so that it can begin processing message feedback.
|
void |
start(int timeoutMilliseconds)
Open this client so that it can begin processing message feedback.
|
void |
stop()
Stops this client from processing any more message feedback and releases all network resources tied to it.
|
void |
stop(int timeoutMilliseconds)
Stops this client from processing any more message feedback and releases all network resources tied to it.
|
public MessageFeedbackProcessorClient(String hostName, com.azure.core.credential.TokenCredential credential, IotHubServiceClientProtocol protocol, Function<FeedbackBatch,AcknowledgementType> feedbackMessageProcessor)
TokenCredential
instance for authentication.hostName
- The hostname of your IoT Hub instance (For instance, "your-iot-hub.azure-devices.net")credential
- The custom TokenCredential
that will provide authentication tokens to
this library when they are needed. The provided tokens must be Json Web Tokens.protocol
- The protocol that the client will communicate to IoT Hub over.feedbackMessageProcessor
- The callback to be executed each time message feedback is received from the service. May not be null.public MessageFeedbackProcessorClient(String hostName, com.azure.core.credential.TokenCredential credential, IotHubServiceClientProtocol protocol, Function<FeedbackBatch,AcknowledgementType> feedbackMessageProcessor, MessageFeedbackProcessorClientOptions options)
TokenCredential
instance for authentication.hostName
- The hostname of your IoT Hub instance (For instance, "your-iot-hub.azure-devices.net")credential
- The custom TokenCredential
that will provide authentication tokens to
this library when they are needed. The provided tokens must be Json Web Tokens.protocol
- The protocol that the client will communicate to IoT Hub over.feedbackMessageProcessor
- The callback to be executed each time message feedback is received from the service. May not be null.options
- The connection options to use when connecting to the service. May not be null.public MessageFeedbackProcessorClient(String hostName, com.azure.core.credential.AzureSasCredential azureSasCredential, IotHubServiceClientProtocol protocol, Function<FeedbackBatch,AcknowledgementType> feedbackMessageProcessor)
AzureSasCredential
instance for authentication.hostName
- The hostname of your IoT Hub instance (For instance, "your-iot-hub.azure-devices.net")azureSasCredential
- The SAS token provider that will be used for authentication.protocol
- The protocol that the client will communicate to IoT Hub over.feedbackMessageProcessor
- The callback to be executed each time message feedback is received from the service. May not be null.public MessageFeedbackProcessorClient(String hostName, com.azure.core.credential.AzureSasCredential azureSasCredential, IotHubServiceClientProtocol protocol, Function<FeedbackBatch,AcknowledgementType> feedbackMessageProcessor, MessageFeedbackProcessorClientOptions options)
AzureSasCredential
instance for authentication.hostName
- The hostname of your IoT Hub instance (For instance, "your-iot-hub.azure-devices.net")azureSasCredential
- The SAS token provider that will be used for authentication.protocol
- The protocol that the client will communicate to IoT Hub over.feedbackMessageProcessor
- The callback to be executed each time message feedback is received from the service. May not be null.options
- The connection options to use when connecting to the service. May not be null.public MessageFeedbackProcessorClient(String connectionString, IotHubServiceClientProtocol protocol, Function<FeedbackBatch,AcknowledgementType> feedbackMessageProcessor)
connectionString
- The connection string for the Iot Hub.protocol
- The protocol that the client will communicate to IoT Hub over.feedbackMessageProcessor
- The callback to be executed each time message feedback is received from the service. May not be null.public MessageFeedbackProcessorClient(String connectionString, IotHubServiceClientProtocol protocol, Function<FeedbackBatch,AcknowledgementType> feedbackMessageProcessor, MessageFeedbackProcessorClientOptions options)
connectionString
- The connection string for the Iot Hub.protocol
- The protocol that the client will communicate to IoT Hub over.feedbackMessageProcessor
- The callback to be executed each time message feedback is received from the service. May not be null.options
- The connection options to use when connecting to the service. May not be null.public void start() throws IotHubException, IOException, InterruptedException, TimeoutException
stop()
to free up network resources. If this
client is already started, then this function will do nothing.IotHubException
- If any IoT Hub level exceptions occur such as an IotHubUnauthorizedException
.IOException
- If any network level exceptions occur such as the connection timing out.InterruptedException
- If this thread is interrupted while waiting for the connection to the service to open.TimeoutException
- If the connection is not established before the default timeout.public void start(int timeoutMilliseconds) throws IotHubException, IOException, InterruptedException, TimeoutException
stop()
to free up network resources. If this
client is already started, then this function will do nothing.timeoutMilliseconds
- the maximum number of milliseconds to wait for the underlying amqp connection to open.
If this value is 0, it will have an infinite timeout.IotHubException
- If any IoT Hub level exceptions occur such as an IotHubUnauthorizedException
.IOException
- If any network level exceptions occur such as the connection timing out.InterruptedException
- If this thread is interrupted while waiting for the connection to the service to open.TimeoutException
- If the connection is not established before the provided timeout.public void stop() throws InterruptedException
start()
. If this client is already closed,
this function will do nothing.InterruptedException
- if this function is interrupted while waiting for the connection to close down all
network resources.public void stop(int timeoutMilliseconds) throws InterruptedException
start()
. If this client has already been stopped,
this function will do nothing.timeoutMilliseconds
- the maximum number of milliseconds to wait for the underlying amqp connection to close.
If this value is 0, it will have an infinite timeout. If the provided timeout has passed and the connection has
not closed gracefully, then the connection will be forcefully closed and no exception will be thrown.InterruptedException
- if this function is interrupted while waiting for the connection to close down all
network resources.public boolean isRunning()
MessageFeedbackProcessorClientOptions
will provide the context on when connection loss events occur, and why they occurred.Copyright © 2023. All rights reserved.