Package com.azure.messaging.servicebus
Class ServiceBusClientBuilder.ServiceBusSessionReceiverClientBuilder
java.lang.Object
com.azure.messaging.servicebus.ServiceBusClientBuilder.ServiceBusSessionReceiverClientBuilder
- Enclosing class:
- ServiceBusClientBuilder
Builder for creating
ServiceBusReceiverClient
and ServiceBusReceiverAsyncClient
to consume
messages from a session aware Service Bus entity.-
Method Summary
Modifier and TypeMethodDescriptionCreates an asynchronous, session-aware Service Bus receiver responsible for readingmessages
from a specific queue or subscription.Creates a synchronous, session-aware Service Bus receiver responsible for readingmessages
from 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 session 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 theSubQueue
to 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.ServiceBusSessionReceiverClientBuilder
object.
-
maxAutoLockRenewDuration
public ServiceBusClientBuilder.ServiceBusSessionReceiverClientBuilder maxAutoLockRenewDuration(Duration maxAutoLockRenewDuration) Sets the amount of time to continue auto-renewing the session lock. SettingDuration.ZERO
ornull
disables auto-renewal. ForRECEIVE_AND_DELETE
mode, auto-renewal is disabled.- Parameters:
maxAutoLockRenewDuration
- the amount of time to continue auto-renewing the session lock.Duration.ZERO
ornull
indicates that auto-renewal is disabled.- Returns:
- The updated
ServiceBusClientBuilder.ServiceBusSessionReceiverClientBuilder
object. - Throws:
IllegalArgumentException
- If {code maxAutoLockRenewDuration} is negative.
-
prefetchCount
public ServiceBusClientBuilder.ServiceBusSessionReceiverClientBuilder prefetchCount(int prefetchCount) Sets the prefetch count of the receiver. For bothPEEK_LOCK
andRECEIVE_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 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.ServiceBusSessionReceiverClientBuilder
object. - 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.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
ServiceBusClientBuilder.ServiceBusSessionReceiverClientBuilder
object.
-
subQueue
Sets the type of theSubQueue
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
ServiceBusClientBuilder.ServiceBusSessionReceiverClientBuilder
object. - See Also:
-
A queuename or #topicName A topic name should be set as well.
SubQueue
-
subscriptionName
public ServiceBusClientBuilder.ServiceBusSessionReceiverClientBuilder 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.ServiceBusSessionReceiverClientBuilder
object. - See Also:
-
A topic name should be set as well.
-
topicName
Sets the name of the topic.subscriptionName(String)
must also be set.- Parameters:
topicName
- Name of the topic.- Returns:
- The modified
ServiceBusClientBuilder.ServiceBusSessionReceiverClientBuilder
object. - See Also:
-
A subscription name should be set as well.
-
buildAsyncClient
Creates an asynchronous, session-aware Service Bus receiver responsible for readingmessages
from a specific queue or subscription.- Returns:
- An new
ServiceBusSessionReceiverAsyncClient
that receives messages from a queue or subscription. - Throws:
IllegalStateException
- ifqueueName
ortopicName
are not set or, both of these fields are set. It is also thrown if the Service BusconnectionString
contains anEntityPath
that does not match one set inqueueName
ortopicName
. Lastly, if atopicName
is set, butsubscriptionName
is not.IllegalArgumentException
- Queue or topic name are not set viaqueueName()
ortopicName()
, respectively.
-
buildClient
Creates a synchronous, session-aware Service Bus receiver responsible for readingmessages
from a specific queue or subscription.- Returns:
- An new
ServiceBusReceiverClient
that receives messages from a queue or subscription. - Throws:
IllegalStateException
- ifqueueName
ortopicName
are not set or, both of these fields are set. It is also thrown if the Service BusconnectionString
contains anEntityPath
that does not match one set inqueueName
ortopicName
. Lastly, if atopicName
is set, butsubscriptionName
is not.IllegalArgumentException
- Queue or topic name are not set viaqueueName()
ortopicName()
, respectively.
-