Package com.microsoft.azure.servicebus
Interface IMessageSender
-
- All Superinterfaces:
ICloseable
,IMessageEntityClient
- All Known Subinterfaces:
IQueueClient
,ITopicClient
- All Known Implementing Classes:
QueueClient
,TopicClient
public interface IMessageSender extends IMessageEntityClient
Represents a message sender that sends messages to Azure Service Bus.- Since:
- 1.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description 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.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.-
Methods inherited from interface com.microsoft.azure.servicebus.ICloseable
close, closeAsync
-
Methods inherited from interface com.microsoft.azure.servicebus.IMessageEntityClient
getEntityPath
-
-
-
-
Method Detail
-
send
void send(IMessage message) throws InterruptedException, ServiceBusException
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 callingsendAsync(message).get()
. For better performance, use async methods.- Parameters:
message
- message to be sent to the entity- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if message couldn't be sent to the entity
-
send
void send(IMessage message, TransactionContext transaction) throws InterruptedException, ServiceBusException
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 callingsendAsync(message).get()
. For better performance, use async methods.- Parameters:
message
- message to be sent to the entitytransaction
-TransactionContext
which this operation should enlist to.- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if message couldn't be sent to the entity
-
sendBatch
void sendBatch(Collection<? extends IMessage> messages) throws InterruptedException, ServiceBusException
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 callingsendBatchAsync(messages).get()
. For better performance, use async methods. When called on partitioned entities, messages meant for different partitions cannot be batched together.- Parameters:
messages
- collection of messages to be sent to the entity- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if the batch couldn't be sent to the entity
-
sendBatch
void sendBatch(Collection<? extends IMessage> messages, TransactionContext transaction) throws InterruptedException, ServiceBusException
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 callingsendBatchAsync(messages).get()
. For better performance, use async methods. When called on partitioned entities, messages meant for different partitions cannot be batched together.- Parameters:
messages
- collection of messages to be sent to the entitytransaction
-TransactionContext
which this operation should enlist to.- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if the batch couldn't be sent to the entity
-
sendAsync
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.- Parameters:
message
- message to be sent to the entity- Returns:
- a CompletableFuture representing the pending send
-
sendAsync
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.- Parameters:
message
- message to be sent to the entitytransaction
-TransactionContext
which this operation should enlist to.- Returns:
- a CompletableFuture representing the pending send
-
sendBatchAsync
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. When called on partitioned entities, messages meant for different partitions cannot be batched together.- Parameters:
messages
- collection of messages to be sent to the entity- Returns:
- a CompletableFuture representing the pending send
-
sendBatchAsync
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. When called on partitioned entities, messages meant for different partitions cannot be batched together.- Parameters:
messages
- collection of messages to be sent to the entitytransaction
-TransactionContext
which this operation should enlist to.- Returns:
- a CompletableFuture representing the pending send
-
scheduleMessageAsync
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.- Parameters:
message
- message to be sent to the entityscheduledEnqueueTimeUtc
- 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
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.- Parameters:
message
- message to be sent to the entityscheduledEnqueueTimeUtc
- instant at which the message should be enqueued in the entitytransaction
-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.
-
cancelScheduledMessageAsync
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.- Parameters:
sequenceNumber
- sequence number of the scheduled message- Returns:
- a CompletableFuture representing the pending cancellation
-
scheduleMessage
long scheduleMessage(IMessage message, Instant scheduledEnqueueTimeUtc) throws InterruptedException, ServiceBusException
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 callingscheduleMessageAsync(message, scheduledEnqueueTimeUtc).get()
. For better performance, use async methods.- Parameters:
message
- message to be sent to the entityscheduledEnqueueTimeUtc
- 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 waitingServiceBusException
- if message couldn't be sent to the entity
-
scheduleMessage
long scheduleMessage(IMessage message, Instant scheduledEnqueueTimeUtc, TransactionContext transaction) throws InterruptedException, ServiceBusException
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 callingscheduleMessageAsync(message, scheduledEnqueueTimeUtc).get()
. For better performance, use async methods.- Parameters:
message
- message to be sent to the entityscheduledEnqueueTimeUtc
- instant at which the message should be enqueued in the entitytransaction
-TransactionContext
which this operation should enlist to.- Returns:
- sequence number of the scheduled message
- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if message couldn't be sent to the entity
-
cancelScheduledMessage
void cancelScheduledMessage(long sequenceNumber) throws InterruptedException, ServiceBusException
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 callingcancelScheduledMessageAsync(sequenceNumber).get()
. For better performance, use async methods.- Parameters:
sequenceNumber
- sequence number of the scheduled message- Throws:
InterruptedException
- if the current thread was interrupted while waitingServiceBusException
- if scheduled message couldn't be cancelled
-
-