Class ServiceBusClientBuilder.ServiceBusReceiverClientBuilder
- Enclosing class:
ServiceBusClientBuilder
ServiceBusReceiverClient and ServiceBusReceiverAsyncClient to consume
messages from Service Bus.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionCreates an asynchronous Service Bus receiver responsible for readingmessagesfrom a specific queue or subscription.Creates synchronous Service Bus receiver responsible for readingmessagesfrom a specific queue or subscription.Disables auto-complete and auto-abandon of received messages.maxAutoLockRenewDuration(Duration maxAutoLockRenewDuration) Sets the amount of time to continue auto-renewing the lock.prefetchCount(int prefetchCount) Sets the prefetch count of the receiver.Sets the name of the queue to create a receiver for.receiveMode(ServiceBusReceiveMode receiveMode) Sets the receive mode for the receiver.Sets the type of theSubQueueto connect to.subscriptionName(String subscriptionName) Sets the name of the subscription in the topic to listen to.Sets the name of the topic.
-
Method Details
-
disableAutoComplete
Disables auto-complete and auto-abandon of received messages. By default, a successfully processed message iscompleted. If an error happens when the message is processed, it isabandoned.- Returns:
- The modified
ServiceBusClientBuilder.ServiceBusReceiverClientBuilderobject.
-
maxAutoLockRenewDuration
public ServiceBusClientBuilder.ServiceBusReceiverClientBuilder maxAutoLockRenewDuration(Duration maxAutoLockRenewDuration) Sets the amount of time to continue auto-renewing the lock. SettingDuration.ZEROornulldisables auto-renewal. ForRECEIVE_AND_DELETEmode, 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 pulls a message from the resource, the broker will apply an initial lock to the message. 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 message 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 message locked, the client will have to continuously renew the message lock before its expiration.
maxAutoLockRenewDurationcontrols 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 message lock renewal task will run for 5 minutes.
- Parameters:
maxAutoLockRenewDuration- the amount of time to continue auto-renewing the lock.Duration.ZEROornullindicates that auto-renewal is disabled.- Returns:
- The updated
ServiceBusClientBuilder.ServiceBusReceiverClientBuilderobject. - Throws:
IllegalArgumentException- If {code maxAutoLockRenewDuration} is negative.
-
prefetchCount
Sets the prefetch count of the receiver. For bothPEEK_LOCKandRECEIVE_AND_DELETEmodes 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 usingServiceBusReceiverAsyncClient.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
ServiceBusClientBuilder.ServiceBusReceiverClientBuilderobject. - Throws:
IllegalArgumentException- If {code prefetchCount} is negative.
-
queueName
Sets the name of the queue to create a receiver for.- Parameters:
queueName- Name of the queue.- Returns:
- The modified
ServiceBusClientBuilder.ServiceBusReceiverClientBuilderobject.
-
receiveMode
public ServiceBusClientBuilder.ServiceBusReceiverClientBuilder receiveMode(ServiceBusReceiveMode receiveMode) Sets the receive mode for the receiver.- Parameters:
receiveMode- Mode for receiving messages.- Returns:
- The modified
ServiceBusClientBuilder.ServiceBusReceiverClientBuilderobject.
-
subQueue
Sets the type of theSubQueueto connect to.- Parameters:
subQueue- The type of the sub queue.- Returns:
- The modified
ServiceBusClientBuilder.ServiceBusReceiverClientBuilderobject. - See Also:
-
subscriptionName
public ServiceBusClientBuilder.ServiceBusReceiverClientBuilder subscriptionName(String subscriptionName) Sets the name of the subscription in the topic to listen to.topicName(String)must also be set.- Parameters:
subscriptionName- Name of the subscription.- Returns:
- The modified
ServiceBusClientBuilder.ServiceBusReceiverClientBuilderobject. - See Also:
-
topicName
Sets the name of the topic.subscriptionName(String)must also be set.- Parameters:
topicName- Name of the topic.- Returns:
- The modified
ServiceBusClientBuilder.ServiceBusReceiverClientBuilderobject. - See Also:
-
buildAsyncClient
Creates an asynchronous Service Bus receiver responsible for readingmessagesfrom a specific queue or subscription.- Returns:
- An new
ServiceBusReceiverAsyncClientthat receives messages from a queue or subscription. - Throws:
IllegalStateException- ifqueueNameortopicNameare not set or, both of these fields are set. It is also thrown if the Service BusconnectionStringcontains anEntityPaththat does not match one set inqueueNameortopicName. Lastly, if atopicNameis set, butsubscriptionNameis not.IllegalArgumentException- Queue or topic name are not set viaqueueName()ortopicName(), respectively.
-
buildClient
Creates synchronous Service Bus receiver responsible for readingmessagesfrom a specific queue or subscription.- Returns:
- An new
ServiceBusReceiverClientthat receives messages from a queue or subscription. - Throws:
IllegalStateException- ifqueueNameortopicNameare not set or, both of these fields are set. It is also thrown if the Service BusconnectionStringcontains anEntityPaththat does not match one set inqueueNameortopicName. Lastly, if atopicNameis set, butsubscriptionNameis not.IllegalArgumentException- Queue or topic name are not set viaqueueName()ortopicName(), respectively.
-