QueueClient Class

Implements

public final class QueueClient
extends com.microsoft.azure.servicebus.InitializableEntity
implements IQueueClient

Constructor Summary

Constructor Description
QueueClient(ConnectionStringBuilder amqpConnectionStringBuilder, ReceiveMode receiveMode)
QueueClient(String namespace, String queuePath, ClientSettings clientSettings, ReceiveMode receiveMode)
QueueClient(URI namespaceEndpointURI, String queuePath, 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 cancelScheduledMessage(long sequenceNumber)

Cancels the enqueuing of an already sent scheduled message, if it was not already enqueued.

CompletableFuture<Void> cancelScheduledMessageAsync(long sequenceNumber)

Cancels the enqueuing of an already sent scheduled message, if it was not already enqueued.

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.

String getQueueName()

Gets the name of the queue.

ReceiveMode getReceiveMode()

Gets the ReceiveMode of the current receiver

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.

long scheduleMessage(IMessage message, Instant scheduledEnqueueTimeUtc)

Sends a scheduled message to the Azure Service Bus entity this sender is connected to.

long scheduleMessage(IMessage message, Instant scheduledEnqueueTimeUtc, TransactionContext transaction)

Sends a scheduled message to the Azure Service Bus entity this sender is connected to.

CompletableFuture<Long> scheduleMessageAsync(IMessage message, Instant scheduledEnqueueTimeUtc)

Sends a scheduled message to the Azure Service Bus entity this sender is connected to.

CompletableFuture<Long> scheduleMessageAsync(IMessage message, Instant scheduledEnqueueTimeUtc, TransactionContext transaction)

Sends a scheduled message to the Azure Service Bus entity this sender is connected to.

void send(IMessage message)

Sends a message to the Azure Service Bus entity this sender is connected to.

void send(IMessage message, TransactionContext transaction)

Sends a message to the Azure Service Bus entity this sender is connected to.

CompletableFuture<Void> sendAsync(IMessage message)

Sends a message to the Azure Service Bus entity this sender is connected to.

CompletableFuture<Void> sendAsync(IMessage message, TransactionContext transaction)

Sends a message to the Azure Service Bus entity this sender is connected to.

void sendBatch(Collection<? extends IMessage> messages)

Sends a batch of messages to the Azure Service Bus entity this sender is connected to.

void sendBatch(Collection<? extends IMessage> messages, TransactionContext transaction)

Sends a batch of messages to the Azure Service Bus entity this sender is connected to.

CompletableFuture<Void> sendBatchAsync(Collection<? extends IMessage> messages)

Sends a batch of messages to the Azure Service Bus entity this sender is connected to.

CompletableFuture<Void> sendBatchAsync(Collection<? extends IMessage> messages, TransactionContext transaction)

Sends a batch of messages to the Azure Service Bus entity this sender is connected to.

void setPrefetchCount(int prefetchCount)

Set the prefetch count of the receiver.

Methods inherited from ClientEntity

Methods inherited from java.lang.Object

Constructor Details

QueueClient

public QueueClient(ConnectionStringBuilder amqpConnectionStringBuilder, ReceiveMode receiveMode)

Parameters:

amqpConnectionStringBuilder
receiveMode

Throws:

QueueClient

public QueueClient(String namespace, String queuePath, ClientSettings clientSettings, ReceiveMode receiveMode)

Parameters:

namespace
queuePath
clientSettings
receiveMode

Throws:

QueueClient

public QueueClient(URI namespaceEndpointURI, String queuePath, ClientSettings clientSettings, ReceiveMode receiveMode)

Parameters:

namespaceEndpointURI
queuePath
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

cancelScheduledMessage

public void cancelScheduledMessage(long sequenceNumber)

Cancels the enqueuing of an already sent scheduled message, if it was not already enqueued. This method blocks until the message is sent to the entity. Calling this method is equivalent to calling cancelScheduledMessageAsync(sequenceNumber).get(). For better performance, use async methods.

Parameters:

sequenceNumber

Throws:

cancelScheduledMessageAsync

public CompletableFuture cancelScheduledMessageAsync(long sequenceNumber)

Cancels the enqueuing of an already sent scheduled message, if it was not already enqueued. This is an asynchronous method returning a CompletableFuture which completes when the message is cancelled.

Parameters:

sequenceNumber

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.

getQueueName

public String getQueueName()

Gets the name of the queue.

getReceiveMode

public ReceiveMode getReceiveMode()

Gets the ReceiveMode of the current receiver

onClose

protected CompletableFuture onClose()

Overrides:

QueueClient.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:

scheduleMessage

public long scheduleMessage(IMessage message, Instant scheduledEnqueueTimeUtc)

Sends a scheduled message to the Azure Service Bus entity this sender is connected to. A scheduled message is enqueued and made available to receivers only at the scheduled enqueue time. This method blocks until the message is sent to the entity. Calling this method is equivalent to calling scheduleMessageAsync(message, scheduledEnqueueTimeUtc).get(). For better performance, use async methods.

Parameters:

message
scheduledEnqueueTimeUtc

Throws:

scheduleMessage

public long scheduleMessage(IMessage message, Instant scheduledEnqueueTimeUtc, TransactionContext transaction)

Sends a scheduled message to the Azure Service Bus entity this sender is connected to. A scheduled message is enqueued and made available to receivers only at the scheduled enqueue time. This method blocks until the message is sent to the entity. Calling this method is equivalent to calling scheduleMessageAsync(message, scheduledEnqueueTimeUtc).get(). For better performance, use async methods.

Parameters:

message
scheduledEnqueueTimeUtc
transaction

Throws:

scheduleMessageAsync

public CompletableFuture scheduleMessageAsync(IMessage message, Instant scheduledEnqueueTimeUtc)

Sends a scheduled message to the Azure Service Bus entity this sender is connected to. A scheduled message is enqueued and made available to receivers only at the scheduled enqueue time. This is an asynchronous method returning a CompletableFuture which completes when the message is sent to the entity. The CompletableFuture, on completion, returns the sequence number of the scheduled message which can be used to cancel the scheduling of the message.

Parameters:

message
scheduledEnqueueTimeUtc

scheduleMessageAsync

public CompletableFuture scheduleMessageAsync(IMessage message, Instant scheduledEnqueueTimeUtc, TransactionContext transaction)

Sends a scheduled message to the Azure Service Bus entity this sender is connected to. A scheduled message is enqueued and made available to receivers only at the scheduled enqueue time. This is an asynchronous method returning a CompletableFuture which completes when the message is sent to the entity. The CompletableFuture, on completion, returns the sequence number of the scheduled message which can be used to cancel the scheduling of the message.

Parameters:

message
scheduledEnqueueTimeUtc
transaction

send

public void send(IMessage message)

Sends a message to the Azure Service Bus entity this sender is connected to. This method blocks until the message is sent to the entity. Calling this method is equivalent to calling sendAsync(message).get(). For better performance, use async methods.

Parameters:

message

Throws:

send

public void send(IMessage message, TransactionContext transaction)

Sends a message to the Azure Service Bus entity this sender is connected to. This method blocks until the message is sent to the entity. Calling this method is equivalent to calling sendAsync(message).get(). For better performance, use async methods.

Parameters:

message
transaction

Throws:

sendAsync

public CompletableFuture sendAsync(IMessage message)

Sends a message to the Azure Service Bus entity this sender is connected to. This is an asynchronous method returning a CompletableFuture which completes when the message is sent to the entity.

Parameters:

message

sendAsync

public CompletableFuture sendAsync(IMessage message, TransactionContext transaction)

Sends a message to the Azure Service Bus entity this sender is connected to. This is an asynchronous method returning a CompletableFuture which completes when the message is sent to the entity.

Parameters:

message
transaction

sendBatch

public void sendBatch(Collection messages)

Sends a batch of messages to the Azure Service Bus entity this sender is connected to. This method blocks until the batch is sent to the entity. Calling this method is equivalent to calling sendBatchAsync(messages).get(). For better performance, use async methods. When called on partitioned entities, messages meant for different partitions cannot be batched together.

Parameters:

messages

Throws:

sendBatch

public void sendBatch(Collection messages, TransactionContext transaction)

Sends a batch of messages to the Azure Service Bus entity this sender is connected to. This method blocks until the batch is sent to the entity. Calling this method is equivalent to calling sendBatchAsync(messages).get(). For better performance, use async methods. When called on partitioned entities, messages meant for different partitions cannot be batched together.

Parameters:

messages
transaction

Throws:

sendBatchAsync

public CompletableFuture sendBatchAsync(Collection messages)

Sends a batch of messages to the Azure Service Bus entity this sender is connected to. This is an asynchronous method returning a CompletableFuture which completes when the batch is sent to the entity. When called on partitioned entities, messages meant for different partitions cannot be batched together.

Parameters:

messages

sendBatchAsync

public CompletableFuture sendBatchAsync(Collection messages, TransactionContext transaction)

Sends a batch of messages to the Azure Service Bus entity this sender is connected to. This is an asynchronous method returning a CompletableFuture which completes when the batch is sent to the entity. When called on partitioned entities, messages meant for different partitions cannot be batched together.

Parameters:

messages
transaction

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