QueueClient Class

  • java.lang.Object
    • ClientEntity
      • com.microsoft.azure.servicebus.InitializableEntity
        • com.microsoft.azure.servicebus.QueueClient

public class QueueClient 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)
void abandon(UUID lockToken, Map<String, Object> propertiesToModify)
void abandon(UUID lockToken, Map<String, Object> propertiesToModify, TransactionContext transaction)
void abandon(UUID lockToken, TransactionContext transaction)
CompletableFuture<Void> abandonAsync(UUID lockToken)
CompletableFuture<Void> abandonAsync(UUID lockToken, Map<String, Object> propertiesToModify)
CompletableFuture<Void> abandonAsync(UUID lockToken, Map<String, Object> propertiesToModify, TransactionContext transaction)
CompletableFuture<Void> abandonAsync(UUID lockToken, TransactionContext transaction)
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 . For better performance, use async methods.

CompletableFuture<Void> 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.

void complete(UUID lockToken)
void complete(UUID lockToken, TransactionContext transaction)
CompletableFuture<Void> completeAsync(UUID lockToken)
CompletableFuture<Void> completeAsync(UUID lockToken, TransactionContext transaction)
void deadLetter(UUID lockToken)
void deadLetter(UUID lockToken, Map<String, Object> propertiesToModify)
void deadLetter(UUID lockToken, Map<String, Object> propertiesToModify, TransactionContext transaction)
void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription)
void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String, Object> propertiesToModify)
void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String, Object> propertiesToModify, TransactionContext transaction)
void deadLetter(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, TransactionContext transaction)
void deadLetter(UUID lockToken, TransactionContext transaction)
CompletableFuture<Void> deadLetterAsync(UUID lockToken)
CompletableFuture<Void> deadLetterAsync(UUID lockToken, Map<String, Object> propertiesToModify)
CompletableFuture<Void> deadLetterAsync(UUID lockToken, Map<String, Object> propertiesToModify, TransactionContext transaction)
CompletableFuture<Void> deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription)
CompletableFuture<Void> deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String, Object> propertiesToModify)
CompletableFuture<Void> deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, Map<String, Object> propertiesToModify, TransactionContext transaction)
CompletableFuture<Void> deadLetterAsync(UUID lockToken, String deadLetterReason, String deadLetterErrorDescription, TransactionContext transaction)
CompletableFuture<Void> deadLetterAsync(UUID lockToken, TransactionContext transaction)
String getEntityPath()

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

int getPrefetchCount()
String getQueueName()

Gets the name of the queue.

ReceiveMode getReceiveMode()

Gets the ReceiveMode of the current receiver

CompletableFuture<Void> onClose()
void registerMessageHandler(IMessageHandler handler)
void registerMessageHandler(IMessageHandler handler, ExecutorService executorService)
void registerMessageHandler(IMessageHandler handler, MessageHandlerOptions handlerOptions)
void registerMessageHandler(IMessageHandler handler, MessageHandlerOptions handlerOptions, ExecutorService executorService)
void registerSessionHandler(ISessionHandler handler)
void registerSessionHandler(ISessionHandler handler, ExecutorService executorService)
void registerSessionHandler(ISessionHandler handler, SessionHandlerOptions handlerOptions)
void registerSessionHandler(ISessionHandler handler, SessionHandlerOptions handlerOptions, ExecutorService executorService)
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 . For better performance, use async methods.

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 . For better performance, use async methods.

CompletableFuture<Long> 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.

CompletableFuture<Long> 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.

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 . For better performance, use async methods.

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 . For better performance, use async methods.

CompletableFuture<Void> 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.

CompletableFuture<Void> 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.

void sendBatch(Collection<? extends IMessage> 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 . For better performance, use async methods.

void sendBatch(Collection<? extends IMessage> 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 . For better performance, use async methods.

CompletableFuture<Void> sendBatchAsync(Collection<? extends IMessage> 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.

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. This is an asynchronous method returning a CompletableFuture which completes when the batch is sent to the entity.

void setPrefetchCount(int prefetchCount)

Inherited Members

Constructor Details

QueueClient

public QueueClient(ConnectionStringBuilder amqpConnectionStringBuilder, ReceiveMode receiveMode)

Parameters:

amqpConnectionStringBuilder
receiveMode

QueueClient

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

Parameters:

namespace
queuePath
clientSettings
receiveMode

QueueClient

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

Parameters:

namespaceEndpointURI
queuePath
clientSettings
receiveMode

Method Details

abandon

public void abandon(UUID lockToken)

Parameters:

lockToken

abandon

public void abandon(UUID lockToken, Map propertiesToModify)

Parameters:

lockToken
propertiesToModify

abandon

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

Parameters:

lockToken
propertiesToModify
transaction

abandon

public void abandon(UUID lockToken, TransactionContext transaction)

Parameters:

lockToken
transaction

abandonAsync

public CompletableFuture abandonAsync(UUID lockToken)

Parameters:

lockToken

abandonAsync

public CompletableFuture abandonAsync(UUID lockToken, Map propertiesToModify)

Parameters:

lockToken
propertiesToModify

abandonAsync

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

Parameters:

lockToken
propertiesToModify
transaction

abandonAsync

public CompletableFuture abandonAsync(UUID lockToken, TransactionContext transaction)

Parameters:

lockToken
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 . For better performance, use async methods.

Overrides:

QueueClient.cancelScheduledMessage(long sequenceNumber)

Parameters:

sequenceNumber - sequence number of the scheduled message

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if scheduled message couldn't be cancelled

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.

Overrides:

QueueClient.cancelScheduledMessageAsync(long sequenceNumber)

Parameters:

sequenceNumber - sequence number of the scheduled message

Returns:

a CompletableFuture representing the pending cancellation

complete

public void complete(UUID lockToken)

Parameters:

lockToken

complete

public void complete(UUID lockToken, TransactionContext transaction)

Parameters:

lockToken
transaction

completeAsync

public CompletableFuture completeAsync(UUID lockToken)

Parameters:

lockToken

completeAsync

public CompletableFuture completeAsync(UUID lockToken, TransactionContext transaction)

Parameters:

lockToken
transaction

deadLetter

public void deadLetter(UUID lockToken)

Parameters:

lockToken

deadLetter

public void deadLetter(UUID lockToken, Map propertiesToModify)

Parameters:

lockToken
propertiesToModify

deadLetter

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

Parameters:

lockToken
propertiesToModify
transaction

deadLetter

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

Parameters:

lockToken
deadLetterReason
deadLetterErrorDescription

deadLetter

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

Parameters:

lockToken
deadLetterReason
deadLetterErrorDescription
propertiesToModify

deadLetter

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

Parameters:

lockToken
deadLetterReason
deadLetterErrorDescription
propertiesToModify
transaction

deadLetter

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

Parameters:

lockToken
deadLetterReason
deadLetterErrorDescription
transaction

deadLetter

public void deadLetter(UUID lockToken, TransactionContext transaction)

Parameters:

lockToken
transaction

deadLetterAsync

public CompletableFuture deadLetterAsync(UUID lockToken)

Parameters:

lockToken

deadLetterAsync

public CompletableFuture deadLetterAsync(UUID lockToken, Map propertiesToModify)

Parameters:

lockToken
propertiesToModify

deadLetterAsync

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

Parameters:

lockToken
propertiesToModify
transaction

deadLetterAsync

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

Parameters:

lockToken
deadLetterReason
deadLetterErrorDescription

deadLetterAsync

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

Parameters:

lockToken
deadLetterReason
deadLetterErrorDescription
propertiesToModify

deadLetterAsync

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

Parameters:

lockToken
deadLetterReason
deadLetterErrorDescription
propertiesToModify
transaction

deadLetterAsync

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

Parameters:

lockToken
deadLetterReason
deadLetterErrorDescription
transaction

deadLetterAsync

public CompletableFuture deadLetterAsync(UUID lockToken, TransactionContext transaction)

Parameters:

lockToken
transaction

getEntityPath

public String getEntityPath()

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

Overrides:

QueueClient.getEntityPath()

Returns:

path of the entity this client is connecting to

getPrefetchCount

public int getPrefetchCount()

getQueueName

public String getQueueName()

Gets the name of the queue.

Overrides:

QueueClient.getQueueName()

Returns:

The name of the queue.

getReceiveMode

public ReceiveMode getReceiveMode()

Gets the ReceiveMode of the current receiver

Overrides:

QueueClient.getReceiveMode()

Returns:

The receive mode.

onClose

protected CompletableFuture onClose()

registerMessageHandler

public void registerMessageHandler(IMessageHandler handler)

Parameters:

handler

registerMessageHandler

public void registerMessageHandler(IMessageHandler handler, ExecutorService executorService)

Parameters:

handler
executorService

registerMessageHandler

public void registerMessageHandler(IMessageHandler handler, MessageHandlerOptions handlerOptions)

Parameters:

handler
handlerOptions

registerMessageHandler

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

Parameters:

handler
handlerOptions
executorService

registerSessionHandler

public void registerSessionHandler(ISessionHandler handler)

Parameters:

handler

registerSessionHandler

public void registerSessionHandler(ISessionHandler handler, ExecutorService executorService)

Parameters:

handler
executorService

registerSessionHandler

public void registerSessionHandler(ISessionHandler handler, SessionHandlerOptions handlerOptions)

Parameters:

handler
handlerOptions

registerSessionHandler

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

Parameters:

handler
handlerOptions
executorService

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 . For better performance, use async methods.

Overrides:

QueueClient.scheduleMessage(IMessage message, Instant scheduledEnqueueTimeUtc)

Parameters:

message - message to be sent to the entity
scheduledEnqueueTimeUtc - instant at which the message should be enqueued in the entity

Returns:

sequence number of the scheduled message

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if message couldn't be sent to the entity

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 . For better performance, use async methods.

Overrides:

QueueClient.scheduleMessage(IMessage message, Instant scheduledEnqueueTimeUtc, TransactionContext transaction)

Parameters:

message - message to be sent to the entity
scheduledEnqueueTimeUtc - instant at which the message should be enqueued in the entity
transaction -

TransactionContext which this operation should enlist to.

Returns:

sequence number of the scheduled message

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if message couldn't be sent to the entity

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.

Overrides:

QueueClient.scheduleMessageAsync(IMessage message, Instant scheduledEnqueueTimeUtc)

Parameters:

message - message to be sent to the entity
scheduledEnqueueTimeUtc - instant at which the message should be enqueued in the entity

Returns:

a CompletableFuture representing the pending send, which returns the sequence number of the scheduled message. This sequence number can be used to cancel the scheduling of the message.

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.

Overrides:

QueueClient.scheduleMessageAsync(IMessage message, Instant scheduledEnqueueTimeUtc, TransactionContext transaction)

Parameters:

message - message to be sent to the entity
scheduledEnqueueTimeUtc - instant at which the message should be enqueued in the entity
transaction -

TransactionContext which this operation should enlist to.

Returns:

a CompletableFuture representing the pending send, which returns the sequence number of the scheduled message. This sequence number can be used to cancel the scheduling of the message.

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 . For better performance, use async methods.

Overrides:

QueueClient.send(IMessage message)

Parameters:

message - message to be sent to the entity

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if message couldn't be sent to the entity

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 . For better performance, use async methods.

Overrides:

QueueClient.send(IMessage message, TransactionContext transaction)

Parameters:

message - message to be sent to the entity
transaction -

TransactionContext which this operation should enlist to.

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if message couldn't be sent to the entity

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.

Overrides:

QueueClient.sendAsync(IMessage message)

Parameters:

message - message to be sent to the entity

Returns:

a CompletableFuture representing the pending send

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.

Overrides:

QueueClient.sendAsync(IMessage message, TransactionContext transaction)

Parameters:

message - message to be sent to the entity
transaction -

TransactionContext which this operation should enlist to.

Returns:

a CompletableFuture representing the pending send

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 . For better performance, use async methods.

Overrides:

QueueClient.sendBatch(Collection<? extends IMessage> messages)

Parameters:

messages - collection of messages to be sent to the entity

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if the batch couldn't be sent to the entity

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 . For better performance, use async methods.

Overrides:

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

Parameters:

messages - collection of messages to be sent to the entity
transaction -

TransactionContext which this operation should enlist to.

Throws:

InterruptedException - if the current thread was interrupted while waiting
ServiceBusException - if the batch couldn't be sent to the entity

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.

Overrides:

QueueClient.sendBatchAsync(Collection<? extends IMessage> messages)

Parameters:

messages - collection of messages to be sent to the entity

Returns:

a CompletableFuture representing the pending send

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.

Overrides:

QueueClient.sendBatchAsync(Collection<? extends IMessage> messages, TransactionContext transaction)

Parameters:

messages - collection of messages to be sent to the entity
transaction -

TransactionContext which this operation should enlist to.

Returns:

a CompletableFuture representing the pending send

setPrefetchCount

public void setPrefetchCount(int prefetchCount)

Parameters:

prefetchCount

Applies to