SubscriptionClient Class

Implements

public final class SubscriptionClient
extends com.microsoft.azure.servicebus.InitializableEntity
implements ISubscriptionClient

Field Summary

Modifier and Type Field and Description
static final String DEFAULT_RULE_NAME

Constructor Summary

Constructor Description
SubscriptionClient(ConnectionStringBuilder amqpConnectionStringBuilder, ReceiveMode receiveMode)
SubscriptionClient(String namespace, String subscriptionPath, ClientSettings clientSettings, ReceiveMode receiveMode)
SubscriptionClient(URI namespaceEndpointURI, String subscriptionPath, ClientSettings clientSettings, ReceiveMode receiveMode)

Method Summary

Modifier and Type Method and Description
void abandon(UUID lockToken)

Abandon Message with lock token.

void abandon(UUID lockToken, TransactionContext transaction)

Abandon Message with lock token.

void abandon(UUID lockToken, Map<String,Object> propertiesToModify)

Abandon Message with lock token and updated message property.

void abandon(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction)

Abandon Message with lock token and updated message property.

CompletableFuture<Void> abandonAsync(UUID lockToken)

Asynchronously abandon Message with lock token.

CompletableFuture<Void> abandonAsync(UUID lockToken, TransactionContext transaction)

Asynchronously abandon Message with lock token.

CompletableFuture<Void> abandonAsync(UUID lockToken, Map<String,Object> propertiesToModify)

Asynchronously abandon Message with lock token and updated message property.

CompletableFuture<Void> abandonAsync(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction)

Asynchronously abandon Message with lock token and updated message property.

void addRule(RuleDescription ruleDescription)

Adds a rule to the current subscription to filter the messages reaching from topic to the subscription.

void addRule(String ruleName, Filter filter)

Adds a rule with specified name and Filter to the current subscription to filter the messages reaching from topic to the subscription.

CompletableFuture<Void> addRuleAsync(RuleDescription ruleDescription)

Asynchronously adds a rule to the current subscription to filter the messages reaching from topic to the subscription.

CompletableFuture<Void> addRuleAsync(String ruleName, Filter filter)

Asynchronously adds a rule with specified name and Filter to the current subscription to filter the messages reaching from topic to the subscription.

void complete(UUID lockToken)

Completes a Message using its lock token.

void complete(UUID lockToken, TransactionContext transaction)

Completes a Message using its lock token.

CompletableFuture<Void> completeAsync(UUID lockToken)

Asynchronously completes a Message using its lock token.

CompletableFuture<Void> completeAsync(UUID lockToken, TransactionContext transaction)

Asynchronously completes a Message using its lock token.

void deadLetter(UUID lockToken)

Moves a Message to the deadletter sub-queue.

void deadLetter(UUID lockToken, TransactionContext transaction)

Moves a Message to the deadletter sub-queue.

void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription)

Moves a Message to the deadletter sub-queue with deadletter reason and error description.

void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, TransactionContext transaction)

Moves a Message to the deadletter sub-queue with deadletter reason and error description.

void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String,Object> propertiesToModify)

Moves a Message to the deadletter sub-queue with deadletter reason and error description and modified properties.

void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String,Object> propertiesToModify, TransactionContext transaction)

Moves a Message to the deadletter sub-queue with deadletter reason and error description and modified properties.

void deadLetter(UUID lockToken, Map<String,Object> propertiesToModify)

Moves a Message to the deadletter sub-queue with modified message properties.

void deadLetter(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction)

Moves a Message to the deadletter sub-queue with modified message properties.

CompletableFuture<Void> deadLetterAsync(UUID lockToken)

Asynchronously moves a Message to the deadletter sub-queue with deadletter.

CompletableFuture<Void> deadLetterAsync(UUID lockToken, TransactionContext transaction)

Asynchronously moves a Message to the deadletter sub-queue with deadletter.

CompletableFuture<Void> deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription)

Asynchronously moves a Message to the deadletter sub-queue with deadletter reason and error description.

CompletableFuture<Void> deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, TransactionContext transaction)

Asynchronously moves a Message to the deadletter sub-queue with deadletter reason and error description.

CompletableFuture<Void> deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String,Object> propertiesToModify)

Asynchronously moves a Message to the deadletter sub-queue with deadletter reason and error description and modified properties.

CompletableFuture<Void> deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String,Object> propertiesToModify, TransactionContext transaction)

Asynchronously moves a Message to the deadletter sub-queue with deadletter reason and error description and modified properties.

CompletableFuture<Void> deadLetterAsync(UUID lockToken, Map<String,Object> propertiesToModify)

Asynchronously moves a Message to the deadletter sub-queue with modified properties.

CompletableFuture<Void> deadLetterAsync(UUID lockToken, Map<String,Object> propertiesToModify, TransactionContext transaction)

Asynchronously moves a Message to the deadletter sub-queue with modified properties.

String getEntityPath()

Gets the path of the entity this client is sending messages to or receiving messages from.

int getPrefetchCount()

Get the prefetch value set.

ReceiveMode getReceiveMode()

Gets the ReceiveMode of the current receiver

Collection<RuleDescription> getRules()

Get all rules associated with the subscription.

CompletableFuture<Collection<RuleDescription>> getRulesAsync()

Get all rules associated with the subscription.

String getSubscriptionName()

Gets the subscription name.

String getTopicName()

Gets the name of the topic, for this subscription.

protected CompletableFuture<Void> onClose()
void registerMessageHandler(IMessageHandler handler)

Receive messages continuously from the entity.

void registerMessageHandler(IMessageHandler handler, MessageHandlerOptions handlerOptions)

Receive messages continuously from the entity.

void registerMessageHandler(IMessageHandler handler, MessageHandlerOptions handlerOptions, ExecutorService executorService)

Receive messages continuously from the entity.

void registerMessageHandler(IMessageHandler handler, ExecutorService executorService)

Receive messages continuously from the entity.

void registerSessionHandler(ISessionHandler handler)

Receive session messages continuously from the queue.

void registerSessionHandler(ISessionHandler handler, SessionHandlerOptions handlerOptions)

Receive session messages continuously from the queue.

void registerSessionHandler(ISessionHandler handler, SessionHandlerOptions handlerOptions, ExecutorService executorService)

Receive session messages continuously from the queue.

void registerSessionHandler(ISessionHandler handler, ExecutorService executorService)

Receive session messages continuously from the queue.

void removeRule(String ruleName)

Removes the rule on the subscription identified by ruleName

CompletableFuture<Void> removeRuleAsync(String ruleName)

Asynchronously removes the rule on the subscription identified by ruleName

void setPrefetchCount(int prefetchCount)

Set the prefetch count of the receiver.

Methods inherited from ClientEntity

Methods inherited from java.lang.Object

Field Details

DEFAULT_RULE_NAME

public static final String DEFAULT_RULE_NAME

Constructor Details

SubscriptionClient

public SubscriptionClient(ConnectionStringBuilder amqpConnectionStringBuilder, ReceiveMode receiveMode)

Parameters:

amqpConnectionStringBuilder
receiveMode

Throws:

SubscriptionClient

public SubscriptionClient(String namespace, String subscriptionPath, ClientSettings clientSettings, ReceiveMode receiveMode)

Parameters:

namespace
subscriptionPath
clientSettings
receiveMode

Throws:

SubscriptionClient

public SubscriptionClient(URI namespaceEndpointURI, String subscriptionPath, ClientSettings clientSettings, ReceiveMode receiveMode)

Parameters:

namespaceEndpointURI
subscriptionPath
clientSettings
receiveMode

Throws:

Method Details

abandon

public void abandon(UUID lockToken)

Abandon Message with lock token. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message

Parameters:

lockToken

Throws:

abandon

public void abandon(UUID lockToken, TransactionContext transaction)

Abandon Message with lock token. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message

Parameters:

lockToken
transaction

Throws:

abandon

public void abandon(UUID lockToken, Map propertiesToModify)

Abandon Message with lock token and updated message property. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message

Parameters:

lockToken
propertiesToModify

Throws:

abandon

public void abandon(UUID lockToken, Map propertiesToModify, TransactionContext transaction)

Abandon Message with lock token and updated message property. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message

Parameters:

lockToken
propertiesToModify
transaction

Throws:

abandonAsync

public CompletableFuture abandonAsync(UUID lockToken)

Asynchronously abandon Message with lock token. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message.

Parameters:

lockToken

abandonAsync

public CompletableFuture abandonAsync(UUID lockToken, TransactionContext transaction)

Asynchronously abandon Message with lock token. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message.

Parameters:

lockToken
transaction

abandonAsync

public CompletableFuture abandonAsync(UUID lockToken, Map propertiesToModify)

Asynchronously abandon Message with lock token and updated message property. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message.

Parameters:

lockToken
propertiesToModify

abandonAsync

public CompletableFuture abandonAsync(UUID lockToken, Map propertiesToModify, TransactionContext transaction)

Asynchronously abandon Message with lock token and updated message property. This will make the message available again for processing. Abandoning a message will increase the delivery count on the message.

Parameters:

lockToken
propertiesToModify
transaction

addRule

public void addRule(RuleDescription ruleDescription)

Adds a rule to the current subscription to filter the messages reaching from topic to the subscription.

Parameters:

ruleDescription

Throws:

addRule

public void addRule(String ruleName, Filter filter)

Adds a rule with specified name and Filter to the current subscription to filter the messages reaching from topic to the subscription.

Parameters:

ruleName
filter

Throws:

addRuleAsync

public CompletableFuture addRuleAsync(RuleDescription ruleDescription)

Asynchronously adds a rule to the current subscription to filter the messages reaching from topic to the subscription.

Parameters:

ruleDescription

addRuleAsync

public CompletableFuture addRuleAsync(String ruleName, Filter filter)

Asynchronously adds a rule with specified name and Filter to the current subscription to filter the messages reaching from topic to the subscription.

Parameters:

ruleName
filter

complete

public void complete(UUID lockToken)

Completes a Message using its lock token. This will delete the message from the service.

Parameters:

lockToken

Throws:

complete

public void complete(UUID lockToken, TransactionContext transaction)

Completes a Message using its lock token. This will delete the message from the service.

Parameters:

lockToken
transaction

Throws:

completeAsync

public CompletableFuture completeAsync(UUID lockToken)

Asynchronously completes a Message using its lock token. This will delete the message from the service.

Parameters:

lockToken

completeAsync

public CompletableFuture completeAsync(UUID lockToken, TransactionContext transaction)

Asynchronously completes a Message using its lock token. This will delete the message from the service.

Parameters:

lockToken
transaction

deadLetter

public void deadLetter(UUID lockToken)

Moves a Message to the deadletter sub-queue.

Parameters:

lockToken

Throws:

deadLetter

public void deadLetter(UUID lockToken, TransactionContext transaction)

Moves a Message to the deadletter sub-queue.

Parameters:

lockToken
transaction

Throws:

deadLetter

public void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription)

Moves a Message to the deadletter sub-queue with deadletter reason and error description.

Parameters:

lockToken
deadLetterReason
deadLetterErrorDescription

Throws:

deadLetter

public void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, TransactionContext transaction)

Moves a Message to the deadletter sub-queue with deadletter reason and error description.

Parameters:

lockToken
deadLetterReason
deadLetterErrorDescription
transaction

Throws:

deadLetter

public void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map propertiesToModify)

Moves a Message to the deadletter sub-queue with deadletter reason and error description and modified properties.

Parameters:

lockToken
deadLetterReason
deadLetterErrorDescription
propertiesToModify

Throws:

deadLetter

public void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map propertiesToModify, TransactionContext transaction)

Moves a Message to the deadletter sub-queue with deadletter reason and error description and modified properties.

Parameters:

lockToken
deadLetterReason
deadLetterErrorDescription
propertiesToModify
transaction

Throws:

deadLetter

public void deadLetter(UUID lockToken, Map propertiesToModify)

Moves a Message to the deadletter sub-queue with modified message properties.

Parameters:

lockToken
propertiesToModify

Throws:

deadLetter

public void deadLetter(UUID lockToken, Map propertiesToModify, TransactionContext transaction)

Moves a Message to the deadletter sub-queue with modified message properties.

Parameters:

lockToken
propertiesToModify
transaction

Throws:

deadLetterAsync

public CompletableFuture deadLetterAsync(UUID lockToken)

Asynchronously moves a Message to the deadletter sub-queue with deadletter.

Parameters:

lockToken

deadLetterAsync

public CompletableFuture deadLetterAsync(UUID lockToken, TransactionContext transaction)

Asynchronously moves a Message to the deadletter sub-queue with deadletter.

Parameters:

lockToken
transaction

deadLetterAsync

public CompletableFuture deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription)

Asynchronously moves a Message to the deadletter sub-queue with deadletter reason and error description.

Parameters:

lockToken
deadLetterReason
deadLetterErrorDescription

deadLetterAsync

public CompletableFuture deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, TransactionContext transaction)

Asynchronously moves a Message to the deadletter sub-queue with deadletter reason and error description.

Parameters:

lockToken
deadLetterReason
deadLetterErrorDescription
transaction

deadLetterAsync

public CompletableFuture deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map propertiesToModify)

Asynchronously moves a Message to the deadletter sub-queue with deadletter reason and error description and modified properties.

Parameters:

lockToken
deadLetterReason
deadLetterErrorDescription
propertiesToModify

deadLetterAsync

public CompletableFuture deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map propertiesToModify, TransactionContext transaction)

Asynchronously moves a Message to the deadletter sub-queue with deadletter reason and error description and modified properties.

Parameters:

lockToken
deadLetterReason
deadLetterErrorDescription
propertiesToModify
transaction

deadLetterAsync

public CompletableFuture deadLetterAsync(UUID lockToken, Map propertiesToModify)

Asynchronously moves a Message to the deadletter sub-queue with modified properties.

Parameters:

lockToken
propertiesToModify

deadLetterAsync

public CompletableFuture deadLetterAsync(UUID lockToken, Map propertiesToModify, TransactionContext transaction)

Asynchronously moves a Message to the deadletter sub-queue with modified properties.

Parameters:

lockToken
propertiesToModify
transaction

getEntityPath

public String getEntityPath()

Gets the path of the entity this client is sending messages to or receiving messages from.

getPrefetchCount

public int getPrefetchCount()

Get the prefetch value set.

getReceiveMode

public ReceiveMode getReceiveMode()

Gets the ReceiveMode of the current receiver

getRules

public Collection getRules()

Get all rules associated with the subscription.

Throws:

getRulesAsync

public CompletableFuture<>> getRulesAsync()

Get all rules associated with the subscription.

getSubscriptionName

public String getSubscriptionName()

Gets the subscription name.

getTopicName

public String getTopicName()

Gets the name of the topic, for this subscription.

onClose

protected CompletableFuture onClose()

Overrides:

SubscriptionClient.onClose()

registerMessageHandler

@Deprecated
public void registerMessageHandler(IMessageHandler handler)

Receive messages continuously from the entity. Registers a message handler and begins a new thread to receive messages. IMessageHandler methods are executed on java.util.concurrent.commonPool()

Parameters:

handler

Throws:

registerMessageHandler

@Deprecated
public void registerMessageHandler(IMessageHandler handler, MessageHandlerOptions handlerOptions)

Receive messages continuously from the entity. Registers a message handler and begins a new thread to receive messages. IMessageHandler methods are executed on java.util.concurrent.commonPool()

Parameters:

handler
handlerOptions

Throws:

registerMessageHandler

public void registerMessageHandler(IMessageHandler handler, MessageHandlerOptions handlerOptions, ExecutorService executorService)

Receive messages continuously from the entity. Registers a message handler and begins a new thread to receive messages. IMessageHandler methods are executed on the passed executor service.

Parameters:

handler
handlerOptions
executorService

Throws:

registerMessageHandler

public void registerMessageHandler(IMessageHandler handler, ExecutorService executorService)

Receive messages continuously from the entity. Registers a message handler and begins a new thread to receive messages. IMessageHandler methods are executed on the passed executor service.

Parameters:

handler
executorService

Throws:

registerSessionHandler

@Deprecated
public void registerSessionHandler(ISessionHandler handler)

Receive session messages continuously from the queue. Registers a message handler and begins a new thread to receive session-messages. ISessionHandler methods are executed on java.util.concurrent.commonPool()

Parameters:

handler

Throws:

registerSessionHandler

@Deprecated
public void registerSessionHandler(ISessionHandler handler, SessionHandlerOptions handlerOptions)

Receive session messages continuously from the queue. Registers a message handler and begins a new thread to receive session-messages. ISessionHandler methods are executed on java.util.concurrent.commonPool()

Parameters:

handler
handlerOptions

Throws:

registerSessionHandler

public void registerSessionHandler(ISessionHandler handler, SessionHandlerOptions handlerOptions, ExecutorService executorService)

Receive session messages continuously from the queue. Registers a message handler and begins a new thread to receive session-messages. ISessionHandler methods are executed on the passed executor service.

Parameters:

handler
handlerOptions
executorService

Throws:

registerSessionHandler

public void registerSessionHandler(ISessionHandler handler, ExecutorService executorService)

Receive session messages continuously from the queue. Registers a message handler and begins a new thread to receive session-messages. ISessionHandler methods are executed on the passed executor service.

Parameters:

handler
executorService

Throws:

removeRule

public void removeRule(String ruleName)

Removes the rule on the subscription identified by ruleName

Parameters:

ruleName

Throws:

removeRuleAsync

public CompletableFuture removeRuleAsync(String ruleName)

Asynchronously removes the rule on the subscription identified by ruleName

Parameters:

ruleName

setPrefetchCount

public void setPrefetchCount(int prefetchCount)

Set the prefetch count of the receiver. 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 Receive. Setting a non-zero value prefetches PrefetchCount number of messages. Setting the value to zero turns prefetch off. For RECEIVEANDDELETE mode, the default value is 0. For PEEKLOCK mode, the default value is 100.

The value cannot be set until the receiver is created.

Parameters:

prefetchCount

Throws:

Applies to