Sdílet prostřednictvím


ServiceBusClientBuilder.ServiceBusSessionReceiverClientBuilder Class

  • java.lang.Object
    • com.azure.messaging.servicebus.ServiceBusClientBuilder.ServiceBusSessionReceiverClientBuilder

public final class ServiceBusClientBuilder.ServiceBusSessionReceiverClientBuilder

Builder for creating ServiceBusReceiverClient and ServiceBusReceiverAsyncClient to consume messages from a session aware Service Bus entity.

Method Summary

Modifier and Type Method and Description
ServiceBusSessionReceiverAsyncClient buildAsyncClient()

Creates an asynchronous, session-aware Service Bus receiver responsible for reading ServiceBusMessage from a specific queue or subscription.

ServiceBusSessionReceiverClient buildClient()

Creates a synchronous, session-aware Service Bus receiver responsible for reading ServiceBusMessage from a specific queue or subscription.

ServiceBusSessionReceiverClientBuilder disableAutoComplete()

Disables auto-complete and auto-abandon of received messages.

ServiceBusSessionReceiverClientBuilder maxAutoLockRenewDuration(Duration maxAutoLockRenewDuration)

Sets the amount of time to continue auto-renewing the session lock.

ServiceBusSessionReceiverClientBuilder prefetchCount(int prefetchCount)

Sets the prefetch count of the receiver.

ServiceBusSessionReceiverClientBuilder queueName(String queueName)

Sets the name of the queue to create a receiver for.

ServiceBusSessionReceiverClientBuilder receiveMode(ServiceBusReceiveMode receiveMode)

Sets the receive mode for the receiver.

ServiceBusSessionReceiverClientBuilder subQueue(SubQueue subQueue)

Sets the type of the SubQueue to connect to.

ServiceBusSessionReceiverClientBuilder subscriptionName(String subscriptionName)

Sets the name of the subscription in the topic to listen to.

ServiceBusSessionReceiverClientBuilder topicName(String topicName)

Sets the name of the topic.

Methods inherited from java.lang.Object

Method Details

buildAsyncClient

public ServiceBusSessionReceiverAsyncClient buildAsyncClient()

Creates an asynchronous, session-aware Service Bus receiver responsible for reading ServiceBusMessage from a specific queue or subscription.

Returns:

An new ServiceBusSessionReceiverAsyncClient that receives messages from a queue or subscription.

buildClient

public ServiceBusSessionReceiverClient buildClient()

Creates a synchronous, session-aware Service Bus receiver responsible for reading ServiceBusMessage from a specific queue or subscription.

Returns:

An new ServiceBusReceiverClient that receives messages from a queue or subscription.

disableAutoComplete

public ServiceBusClientBuilder.ServiceBusSessionReceiverClientBuilder disableAutoComplete()

Disables auto-complete and auto-abandon of received messages. By default, a successfully processed message is complete(ServiceBusReceivedMessage message). If an error happens when the message is processed, it is abandon(ServiceBusReceivedMessage message).

Returns:

The modified ServiceBusSessionReceiverClientBuilder object.

maxAutoLockRenewDuration

public ServiceBusClientBuilder.ServiceBusSessionReceiverClientBuilder maxAutoLockRenewDuration(Duration maxAutoLockRenewDuration)

Sets the amount of time to continue auto-renewing the session lock. Setting Duration#ZERO or null disables auto-renewal. For RECEIVE_AND_DELETE mode, auto-renewal is disabled.

A Service Bus queue or subscription in a topic will have a lock duration set at the resource level. When the receiver client connect to a session in the resource, the broker will apply an initial lock to the session. This initial lock lasts for the lock duration set at the resource level. If the client does not renew the initial lock before it expires then the session will be released and become available for other receivers. Each time the client renews the lock, the broker will extend the lock for the lock duration set at the resource level. To keep the session locked, the client will have to continuously renew the session lock before its expiration. maxAutoLockRenewDuration controls how long the background renewal task runs. So, it is possible that the previous renewed lock can be valid after the renewal task is disposed

By default, the session lock renewal task will run for 5 minutes.

Parameters:

maxAutoLockRenewDuration - the amount of time to continue auto-renewing the session lock. Duration#ZERO or null indicates that auto-renewal is disabled.

Returns:

The updated ServiceBusSessionReceiverClientBuilder object.

prefetchCount

public ServiceBusClientBuilder.ServiceBusSessionReceiverClientBuilder prefetchCount(int prefetchCount)

Sets the prefetch count of the receiver. For both PEEK_LOCK and RECEIVE_AND_DELETE modes the default value is 1. Prefetch speeds up the message flow by aiming to have a message readily available for local retrieval when and before the application asks for one using receiveMessages(). Setting a non-zero value will prefetch that number of messages. Setting the value to zero turns prefetch off.

Parameters:

prefetchCount - The prefetch count.

Returns:

The modified ServiceBusSessionReceiverClientBuilder object.

queueName

public ServiceBusClientBuilder.ServiceBusSessionReceiverClientBuilder queueName(String queueName)

Sets the name of the queue to create a receiver for.

Parameters:

queueName - Name of the queue.

Returns:

The modified ServiceBusSessionReceiverClientBuilder object.

receiveMode

public ServiceBusClientBuilder.ServiceBusSessionReceiverClientBuilder receiveMode(ServiceBusReceiveMode receiveMode)

Sets the receive mode for the receiver.

Parameters:

receiveMode - Mode for receiving messages.

Returns:

The modified ServiceBusSessionReceiverClientBuilder object.

subQueue

public ServiceBusClientBuilder.ServiceBusSessionReceiverClientBuilder subQueue(SubQueue subQueue)

Sets the type of the SubQueue to connect to. Azure Service Bus queues and subscriptions provide a secondary sub-queue, called a dead-letter queue (DLQ).

Parameters:

subQueue - The type of the sub queue.

Returns:

The modified ServiceBusSessionReceiverClientBuilder object.

subscriptionName

public ServiceBusClientBuilder.ServiceBusSessionReceiverClientBuilder subscriptionName(String subscriptionName)

Sets the name of the subscription in the topic to listen to. topicName(String topicName) must also be set.

Parameters:

subscriptionName - Name of the subscription.

Returns:

The modified ServiceBusSessionReceiverClientBuilder object.

topicName

public ServiceBusClientBuilder.ServiceBusSessionReceiverClientBuilder topicName(String topicName)

Sets the name of the topic. subscriptionName(String subscriptionName) must also be set.

Parameters:

topicName - Name of the topic.

Returns:

The modified ServiceBusSessionReceiverClientBuilder object.

Applies to