azure-docs-sdk-java/docs-ref-autogen/com.azure.messaging.service...

296 строки
35 KiB
YAML

### YamlMime:JavaType
uid: "com.azure.messaging.servicebus.ServiceBusSenderClient"
fullName: "com.azure.messaging.servicebus.ServiceBusSenderClient"
name: "ServiceBusSenderClient"
nameWithType: "ServiceBusSenderClient"
summary: "A **synchronous** sender responsible for sending <xref uid=\"com.azure.messaging.servicebus.ServiceBusMessage\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusMessage\"></xref> to a queue or topic on Azure Service Bus."
inheritances:
- "<xref href=\"java.lang.Object?displayProperty=fullName\" data-throw-if-not-resolved=\"False\" />"
inheritedClassMethods:
- classRef: "java.lang.<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html\">Object</a>"
methodsRef:
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--\">clone</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-\">equals</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--\">finalize</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--\">getClass</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--\">hashCode</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--\">notify</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--\">notifyAll</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--\">toString</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--\">wait</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-\">wait</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-\">wait</a>"
syntax: "public final class **ServiceBusSenderClient**</br> implements <a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/AutoCloseable.html\">AutoCloseable</a>"
methods:
- uid: "com.azure.messaging.servicebus.ServiceBusSenderClient.cancelScheduledMessage(long)"
fullName: "com.azure.messaging.servicebus.ServiceBusSenderClient.cancelScheduledMessage(long sequenceNumber)"
name: "cancelScheduledMessage(long sequenceNumber)"
nameWithType: "ServiceBusSenderClient.cancelScheduledMessage(long sequenceNumber)"
summary: "Cancels the enqueuing of a scheduled message, if they are not already enqueued."
parameters:
- description: "The sequence number of the message to cancel."
name: "sequenceNumber"
type: "<xref href=\"long?alt=long&text=long\" data-throw-if-not-resolved=\"False\" />"
syntax: "public void cancelScheduledMessage(long sequenceNumber)"
desc: "Cancels the enqueuing of a scheduled message, if they are not already enqueued."
- uid: "com.azure.messaging.servicebus.ServiceBusSenderClient.cancelScheduledMessages(java.lang.Iterable<java.lang.Long>)"
fullName: "com.azure.messaging.servicebus.ServiceBusSenderClient.cancelScheduledMessages(Iterable<Long> sequenceNumbers)"
name: "cancelScheduledMessages(Iterable<Long> sequenceNumbers)"
nameWithType: "ServiceBusSenderClient.cancelScheduledMessages(Iterable<Long> sequenceNumbers)"
summary: "Cancels the enqueuing of scheduled messages, if they are not already enqueued."
parameters:
- description: "The sequence numbers of messages to cancel."
name: "sequenceNumbers"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html\">Iterable</a>&lt;<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Long.html\">Long</a>&gt;"
syntax: "public void cancelScheduledMessages(Iterable<Long> sequenceNumbers)"
desc: "Cancels the enqueuing of scheduled messages, if they are not already enqueued."
- uid: "com.azure.messaging.servicebus.ServiceBusSenderClient.close()"
fullName: "com.azure.messaging.servicebus.ServiceBusSenderClient.close()"
name: "close()"
nameWithType: "ServiceBusSenderClient.close()"
summary: "Disposes of the <xref uid=\"com.azure.messaging.servicebus.ServiceBusSenderClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusSenderClient\"></xref>."
syntax: "public void close()"
desc: "Disposes of the <xref uid=\"com.azure.messaging.servicebus.ServiceBusSenderClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusSenderClient\"></xref>. If the client has a dedicated connection, the underlying connection is also closed."
- uid: "com.azure.messaging.servicebus.ServiceBusSenderClient.commitTransaction(com.azure.messaging.servicebus.ServiceBusTransactionContext)"
fullName: "com.azure.messaging.servicebus.ServiceBusSenderClient.commitTransaction(ServiceBusTransactionContext transactionContext)"
name: "commitTransaction(ServiceBusTransactionContext transactionContext)"
nameWithType: "ServiceBusSenderClient.commitTransaction(ServiceBusTransactionContext transactionContext)"
summary: "Commits the transaction given <xref uid=\"com.azure.messaging.servicebus.ServiceBusTransactionContext\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusTransactionContext\"></xref>."
parameters:
- description: "to be committed."
name: "transactionContext"
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusTransactionContext?alt=com.azure.messaging.servicebus.ServiceBusTransactionContext&text=ServiceBusTransactionContext\" data-throw-if-not-resolved=\"False\" />"
syntax: "public void commitTransaction(ServiceBusTransactionContext transactionContext)"
desc: "Commits the transaction given <xref uid=\"com.azure.messaging.servicebus.ServiceBusTransactionContext\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusTransactionContext\"></xref>."
- uid: "com.azure.messaging.servicebus.ServiceBusSenderClient.createMessageBatch()"
fullName: "com.azure.messaging.servicebus.ServiceBusSenderClient.createMessageBatch()"
name: "createMessageBatch()"
nameWithType: "ServiceBusSenderClient.createMessageBatch()"
summary: "Creates a <xref uid=\"com.azure.messaging.servicebus.ServiceBusMessageBatch\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusMessageBatch\"></xref> that can fit as many messages as the transport allows."
syntax: "public ServiceBusMessageBatch createMessageBatch()"
desc: "Creates a <xref uid=\"com.azure.messaging.servicebus.ServiceBusMessageBatch\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusMessageBatch\"></xref> that can fit as many messages as the transport allows."
returns:
description: "A <xref uid=\"com.azure.messaging.servicebus.ServiceBusMessageBatch\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusMessageBatch\"></xref> that can fit as many messages as the transport allows."
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusMessageBatch?alt=com.azure.messaging.servicebus.ServiceBusMessageBatch&text=ServiceBusMessageBatch\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.messaging.servicebus.ServiceBusSenderClient.createMessageBatch(com.azure.messaging.servicebus.models.CreateMessageBatchOptions)"
fullName: "com.azure.messaging.servicebus.ServiceBusSenderClient.createMessageBatch(CreateMessageBatchOptions options)"
name: "createMessageBatch(CreateMessageBatchOptions options)"
nameWithType: "ServiceBusSenderClient.createMessageBatch(CreateMessageBatchOptions options)"
summary: "Creates an <xref uid=\"com.azure.messaging.servicebus.ServiceBusMessageBatch\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusMessageBatch\"></xref> configured with the options specified."
parameters:
- description: "A set of options used to configure the <xref uid=\"com.azure.messaging.servicebus.ServiceBusMessageBatch\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusMessageBatch\"></xref>."
name: "options"
type: "<xref href=\"com.azure.messaging.servicebus.models.CreateMessageBatchOptions?alt=com.azure.messaging.servicebus.models.CreateMessageBatchOptions&text=CreateMessageBatchOptions\" data-throw-if-not-resolved=\"False\" />"
syntax: "public ServiceBusMessageBatch createMessageBatch(CreateMessageBatchOptions options)"
desc: "Creates an <xref uid=\"com.azure.messaging.servicebus.ServiceBusMessageBatch\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusMessageBatch\"></xref> configured with the options specified."
returns:
description: "A new <xref uid=\"com.azure.messaging.servicebus.ServiceBusMessageBatch\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusMessageBatch\"></xref> configured with the given options."
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusMessageBatch?alt=com.azure.messaging.servicebus.ServiceBusMessageBatch&text=ServiceBusMessageBatch\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.messaging.servicebus.ServiceBusSenderClient.createTransaction()"
fullName: "com.azure.messaging.servicebus.ServiceBusSenderClient.createTransaction()"
name: "createTransaction()"
nameWithType: "ServiceBusSenderClient.createTransaction()"
summary: "Starts a new transaction on Service Bus."
syntax: "public ServiceBusTransactionContext createTransaction()"
desc: "Starts a new transaction on Service Bus. The <xref uid=\"com.azure.messaging.servicebus.ServiceBusTransactionContext\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusTransactionContext\"></xref> should be passed along to all operations that need to be in this transaction."
returns:
description: "A new <xref uid=\"com.azure.messaging.servicebus.ServiceBusTransactionContext\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusTransactionContext\"></xref>."
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusTransactionContext?alt=com.azure.messaging.servicebus.ServiceBusTransactionContext&text=ServiceBusTransactionContext\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.messaging.servicebus.ServiceBusSenderClient.getEntityPath()"
fullName: "com.azure.messaging.servicebus.ServiceBusSenderClient.getEntityPath()"
name: "getEntityPath()"
nameWithType: "ServiceBusSenderClient.getEntityPath()"
summary: "Gets the name of the Service Bus resource."
syntax: "public String getEntityPath()"
desc: "Gets the name of the Service Bus resource."
returns:
description: "The name of the Service Bus resource."
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- uid: "com.azure.messaging.servicebus.ServiceBusSenderClient.getFullyQualifiedNamespace()"
fullName: "com.azure.messaging.servicebus.ServiceBusSenderClient.getFullyQualifiedNamespace()"
name: "getFullyQualifiedNamespace()"
nameWithType: "ServiceBusSenderClient.getFullyQualifiedNamespace()"
summary: "Gets the fully qualified namespace."
syntax: "public String getFullyQualifiedNamespace()"
desc: "Gets the fully qualified namespace."
returns:
description: "The fully qualified namespace."
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- uid: "com.azure.messaging.servicebus.ServiceBusSenderClient.getIdentifier()"
fullName: "com.azure.messaging.servicebus.ServiceBusSenderClient.getIdentifier()"
name: "getIdentifier()"
nameWithType: "ServiceBusSenderClient.getIdentifier()"
summary: "Gets the identifier of the instance of <xref uid=\"com.azure.messaging.servicebus.ServiceBusSenderClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusSenderClient\"></xref>."
syntax: "public String getIdentifier()"
desc: "Gets the identifier of the instance of <xref uid=\"com.azure.messaging.servicebus.ServiceBusSenderClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusSenderClient\"></xref>."
returns:
description: "The identifier that can identify the instance of <xref uid=\"com.azure.messaging.servicebus.ServiceBusSenderClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusSenderClient\"></xref>."
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- uid: "com.azure.messaging.servicebus.ServiceBusSenderClient.rollbackTransaction(com.azure.messaging.servicebus.ServiceBusTransactionContext)"
fullName: "com.azure.messaging.servicebus.ServiceBusSenderClient.rollbackTransaction(ServiceBusTransactionContext transactionContext)"
name: "rollbackTransaction(ServiceBusTransactionContext transactionContext)"
nameWithType: "ServiceBusSenderClient.rollbackTransaction(ServiceBusTransactionContext transactionContext)"
summary: "Rollbacks the transaction given and all operations associated with it."
parameters:
- description: "The transaction to rollback."
name: "transactionContext"
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusTransactionContext?alt=com.azure.messaging.servicebus.ServiceBusTransactionContext&text=ServiceBusTransactionContext\" data-throw-if-not-resolved=\"False\" />"
syntax: "public void rollbackTransaction(ServiceBusTransactionContext transactionContext)"
desc: "Rollbacks the transaction given and all operations associated with it."
- uid: "com.azure.messaging.servicebus.ServiceBusSenderClient.scheduleMessage(com.azure.messaging.servicebus.ServiceBusMessage,java.time.OffsetDateTime)"
fullName: "com.azure.messaging.servicebus.ServiceBusSenderClient.scheduleMessage(ServiceBusMessage message, OffsetDateTime scheduledEnqueueTime)"
name: "scheduleMessage(ServiceBusMessage message, OffsetDateTime scheduledEnqueueTime)"
nameWithType: "ServiceBusSenderClient.scheduleMessage(ServiceBusMessage message, OffsetDateTime scheduledEnqueueTime)"
summary: "Sends a scheduled message to the Azure Service Bus entity this sender is connected to."
parameters:
- description: "Message to be sent to the Service Bus Queue or Topic."
name: "message"
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusMessage?alt=com.azure.messaging.servicebus.ServiceBusMessage&text=ServiceBusMessage\" data-throw-if-not-resolved=\"False\" />"
- description: "Datetime at which the message should appear in the Service Bus queue or topic."
name: "scheduledEnqueueTime"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/time/OffsetDateTime.html\">OffsetDateTime</a>"
syntax: "public Long scheduleMessage(ServiceBusMessage message, OffsetDateTime scheduledEnqueueTime)"
desc: "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."
returns:
description: "The sequence number of the scheduled message which can be used to cancel the scheduling of the message."
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Long.html\">Long</a>"
- uid: "com.azure.messaging.servicebus.ServiceBusSenderClient.scheduleMessage(com.azure.messaging.servicebus.ServiceBusMessage,java.time.OffsetDateTime,com.azure.messaging.servicebus.ServiceBusTransactionContext)"
fullName: "com.azure.messaging.servicebus.ServiceBusSenderClient.scheduleMessage(ServiceBusMessage message, OffsetDateTime scheduledEnqueueTime, ServiceBusTransactionContext transactionContext)"
name: "scheduleMessage(ServiceBusMessage message, OffsetDateTime scheduledEnqueueTime, ServiceBusTransactionContext transactionContext)"
nameWithType: "ServiceBusSenderClient.scheduleMessage(ServiceBusMessage message, OffsetDateTime scheduledEnqueueTime, ServiceBusTransactionContext transactionContext)"
summary: "Sends a scheduled message to the Azure Service Bus entity this sender is connected to."
parameters:
- description: "Message to be sent to the Service Bus Queue or Topic."
name: "message"
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusMessage?alt=com.azure.messaging.servicebus.ServiceBusMessage&text=ServiceBusMessage\" data-throw-if-not-resolved=\"False\" />"
- description: "Datetime at which the message should appear in the Service Bus queue or topic."
name: "scheduledEnqueueTime"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/time/OffsetDateTime.html\">OffsetDateTime</a>"
- description: "to be set on message before sending to Service Bus."
name: "transactionContext"
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusTransactionContext?alt=com.azure.messaging.servicebus.ServiceBusTransactionContext&text=ServiceBusTransactionContext\" data-throw-if-not-resolved=\"False\" />"
syntax: "public Long scheduleMessage(ServiceBusMessage message, OffsetDateTime scheduledEnqueueTime, ServiceBusTransactionContext transactionContext)"
desc: "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."
returns:
description: "The sequence number of the scheduled message which can be used to cancel the scheduling of the message."
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Long.html\">Long</a>"
- uid: "com.azure.messaging.servicebus.ServiceBusSenderClient.scheduleMessages(java.lang.Iterable<com.azure.messaging.servicebus.ServiceBusMessage>,java.time.OffsetDateTime)"
fullName: "com.azure.messaging.servicebus.ServiceBusSenderClient.scheduleMessages(Iterable<ServiceBusMessage> messages, OffsetDateTime scheduledEnqueueTime)"
name: "scheduleMessages(Iterable<ServiceBusMessage> messages, OffsetDateTime scheduledEnqueueTime)"
nameWithType: "ServiceBusSenderClient.scheduleMessages(Iterable<ServiceBusMessage> messages, OffsetDateTime scheduledEnqueueTime)"
summary: "Sends a batch of scheduled messages to the Azure Service Bus entity this sender is connected to."
parameters:
- description: "Messages to be sent to the Service Bus queue or topic."
name: "messages"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html\">Iterable</a>&lt;<xref href=\"com.azure.messaging.servicebus.ServiceBusMessage?alt=com.azure.messaging.servicebus.ServiceBusMessage&text=ServiceBusMessage\" data-throw-if-not-resolved=\"False\" />&gt;"
- description: "Instant at which the message should appear in the Service Bus queue or topic."
name: "scheduledEnqueueTime"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/time/OffsetDateTime.html\">OffsetDateTime</a>"
syntax: "public Iterable<Long> scheduleMessages(Iterable<ServiceBusMessage> messages, OffsetDateTime scheduledEnqueueTime)"
desc: "Sends a batch of scheduled messages 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."
returns:
description: "Sequence numbers of the scheduled messages which can be used to cancel the messages."
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html\">Iterable</a>&lt;<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Long.html\">Long</a>&gt;"
- uid: "com.azure.messaging.servicebus.ServiceBusSenderClient.scheduleMessages(java.lang.Iterable<com.azure.messaging.servicebus.ServiceBusMessage>,java.time.OffsetDateTime,com.azure.messaging.servicebus.ServiceBusTransactionContext)"
fullName: "com.azure.messaging.servicebus.ServiceBusSenderClient.scheduleMessages(Iterable<ServiceBusMessage> messages, OffsetDateTime scheduledEnqueueTime, ServiceBusTransactionContext transactionContext)"
name: "scheduleMessages(Iterable<ServiceBusMessage> messages, OffsetDateTime scheduledEnqueueTime, ServiceBusTransactionContext transactionContext)"
nameWithType: "ServiceBusSenderClient.scheduleMessages(Iterable<ServiceBusMessage> messages, OffsetDateTime scheduledEnqueueTime, ServiceBusTransactionContext transactionContext)"
summary: "Sends a batch of scheduled messages to the Azure Service Bus entity this sender is connected to."
parameters:
- description: "Messages to be sent to the Service Bus Queue or Topic."
name: "messages"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html\">Iterable</a>&lt;<xref href=\"com.azure.messaging.servicebus.ServiceBusMessage?alt=com.azure.messaging.servicebus.ServiceBusMessage&text=ServiceBusMessage\" data-throw-if-not-resolved=\"False\" />&gt;"
- description: "Instant at which the message should appear in the Service Bus queue or topic."
name: "scheduledEnqueueTime"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/time/OffsetDateTime.html\">OffsetDateTime</a>"
- description: "Transaction to associate with the operation."
name: "transactionContext"
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusTransactionContext?alt=com.azure.messaging.servicebus.ServiceBusTransactionContext&text=ServiceBusTransactionContext\" data-throw-if-not-resolved=\"False\" />"
syntax: "public Iterable<Long> scheduleMessages(Iterable<ServiceBusMessage> messages, OffsetDateTime scheduledEnqueueTime, ServiceBusTransactionContext transactionContext)"
desc: "Sends a batch of scheduled messages 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."
returns:
description: "Sequence numbers of the scheduled messages which can be used to cancel the messages."
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html\">Iterable</a>&lt;<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Long.html\">Long</a>&gt;"
- uid: "com.azure.messaging.servicebus.ServiceBusSenderClient.sendMessage(com.azure.messaging.servicebus.ServiceBusMessage)"
fullName: "com.azure.messaging.servicebus.ServiceBusSenderClient.sendMessage(ServiceBusMessage message)"
name: "sendMessage(ServiceBusMessage message)"
nameWithType: "ServiceBusSenderClient.sendMessage(ServiceBusMessage message)"
summary: "Sends a message to a Service Bus queue or topic."
parameters:
- description: "Message to be sent to Service Bus queue or topic."
name: "message"
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusMessage?alt=com.azure.messaging.servicebus.ServiceBusMessage&text=ServiceBusMessage\" data-throw-if-not-resolved=\"False\" />"
syntax: "public void sendMessage(ServiceBusMessage message)"
desc: "Sends a message to a Service Bus queue or topic."
- uid: "com.azure.messaging.servicebus.ServiceBusSenderClient.sendMessage(com.azure.messaging.servicebus.ServiceBusMessage,com.azure.messaging.servicebus.ServiceBusTransactionContext)"
fullName: "com.azure.messaging.servicebus.ServiceBusSenderClient.sendMessage(ServiceBusMessage message, ServiceBusTransactionContext transactionContext)"
name: "sendMessage(ServiceBusMessage message, ServiceBusTransactionContext transactionContext)"
nameWithType: "ServiceBusSenderClient.sendMessage(ServiceBusMessage message, ServiceBusTransactionContext transactionContext)"
summary: "Sends a message to a Service Bus queue or topic."
parameters:
- description: "Message to be sent to Service Bus queue or topic."
name: "message"
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusMessage?alt=com.azure.messaging.servicebus.ServiceBusMessage&text=ServiceBusMessage\" data-throw-if-not-resolved=\"False\" />"
- description: "to be set on message before sending to Service Bus."
name: "transactionContext"
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusTransactionContext?alt=com.azure.messaging.servicebus.ServiceBusTransactionContext&text=ServiceBusTransactionContext\" data-throw-if-not-resolved=\"False\" />"
syntax: "public void sendMessage(ServiceBusMessage message, ServiceBusTransactionContext transactionContext)"
desc: "Sends a message to a Service Bus queue or topic."
- uid: "com.azure.messaging.servicebus.ServiceBusSenderClient.sendMessages(com.azure.messaging.servicebus.ServiceBusMessageBatch)"
fullName: "com.azure.messaging.servicebus.ServiceBusSenderClient.sendMessages(ServiceBusMessageBatch batch)"
name: "sendMessages(ServiceBusMessageBatch batch)"
nameWithType: "ServiceBusSenderClient.sendMessages(ServiceBusMessageBatch batch)"
summary: "Sends a message batch to the Azure Service Bus entity this sender is connected to."
parameters:
- description: "of messages which allows client to send maximum allowed size for a batch of messages."
name: "batch"
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusMessageBatch?alt=com.azure.messaging.servicebus.ServiceBusMessageBatch&text=ServiceBusMessageBatch\" data-throw-if-not-resolved=\"False\" />"
syntax: "public void sendMessages(ServiceBusMessageBatch batch)"
desc: "Sends a message batch to the Azure Service Bus entity this sender is connected to."
- uid: "com.azure.messaging.servicebus.ServiceBusSenderClient.sendMessages(com.azure.messaging.servicebus.ServiceBusMessageBatch,com.azure.messaging.servicebus.ServiceBusTransactionContext)"
fullName: "com.azure.messaging.servicebus.ServiceBusSenderClient.sendMessages(ServiceBusMessageBatch batch, ServiceBusTransactionContext transactionContext)"
name: "sendMessages(ServiceBusMessageBatch batch, ServiceBusTransactionContext transactionContext)"
nameWithType: "ServiceBusSenderClient.sendMessages(ServiceBusMessageBatch batch, ServiceBusTransactionContext transactionContext)"
summary: "Sends a message batch to the Azure Service Bus entity this sender is connected to."
parameters:
- description: "of messages which allows client to send maximum allowed size for a batch of messages."
name: "batch"
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusMessageBatch?alt=com.azure.messaging.servicebus.ServiceBusMessageBatch&text=ServiceBusMessageBatch\" data-throw-if-not-resolved=\"False\" />"
- description: "to be set on message before sending to Service Bus."
name: "transactionContext"
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusTransactionContext?alt=com.azure.messaging.servicebus.ServiceBusTransactionContext&text=ServiceBusTransactionContext\" data-throw-if-not-resolved=\"False\" />"
syntax: "public void sendMessages(ServiceBusMessageBatch batch, ServiceBusTransactionContext transactionContext)"
desc: "Sends a message batch to the Azure Service Bus entity this sender is connected to."
- uid: "com.azure.messaging.servicebus.ServiceBusSenderClient.sendMessages(java.lang.Iterable<com.azure.messaging.servicebus.ServiceBusMessage>)"
fullName: "com.azure.messaging.servicebus.ServiceBusSenderClient.sendMessages(Iterable<ServiceBusMessage> messages)"
name: "sendMessages(Iterable<ServiceBusMessage> messages)"
nameWithType: "ServiceBusSenderClient.sendMessages(Iterable<ServiceBusMessage> messages)"
summary: "Sends a set of <xref uid=\"com.azure.messaging.servicebus.ServiceBusMessage\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusMessage\"></xref> to a Service Bus queue or topic using a batched approach."
parameters:
- description: "Messages to be sent to Service Bus queue or topic."
name: "messages"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html\">Iterable</a>&lt;<xref href=\"com.azure.messaging.servicebus.ServiceBusMessage?alt=com.azure.messaging.servicebus.ServiceBusMessage&text=ServiceBusMessage\" data-throw-if-not-resolved=\"False\" />&gt;"
syntax: "public void sendMessages(Iterable<ServiceBusMessage> messages)"
desc: "Sends a set of <xref uid=\"com.azure.messaging.servicebus.ServiceBusMessage\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusMessage\"></xref> to a Service Bus queue or topic using a batched approach. If the size of messages exceed the maximum size of a single batch, an exception will be triggered and the send will fail. By default, the message size is the max amount allowed on the link."
- uid: "com.azure.messaging.servicebus.ServiceBusSenderClient.sendMessages(java.lang.Iterable<com.azure.messaging.servicebus.ServiceBusMessage>,com.azure.messaging.servicebus.ServiceBusTransactionContext)"
fullName: "com.azure.messaging.servicebus.ServiceBusSenderClient.sendMessages(Iterable<ServiceBusMessage> messages, ServiceBusTransactionContext transactionContext)"
name: "sendMessages(Iterable<ServiceBusMessage> messages, ServiceBusTransactionContext transactionContext)"
nameWithType: "ServiceBusSenderClient.sendMessages(Iterable<ServiceBusMessage> messages, ServiceBusTransactionContext transactionContext)"
summary: "Sends a set of <xref uid=\"com.azure.messaging.servicebus.ServiceBusMessage\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusMessage\"></xref> to a Service Bus queue or topic using a batched approach."
parameters:
- description: "Messages to be sent to Service Bus queue or topic."
name: "messages"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html\">Iterable</a>&lt;<xref href=\"com.azure.messaging.servicebus.ServiceBusMessage?alt=com.azure.messaging.servicebus.ServiceBusMessage&text=ServiceBusMessage\" data-throw-if-not-resolved=\"False\" />&gt;"
- description: "to be set on message before sending to Service Bus."
name: "transactionContext"
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusTransactionContext?alt=com.azure.messaging.servicebus.ServiceBusTransactionContext&text=ServiceBusTransactionContext\" data-throw-if-not-resolved=\"False\" />"
syntax: "public void sendMessages(Iterable<ServiceBusMessage> messages, ServiceBusTransactionContext transactionContext)"
desc: "Sends a set of <xref uid=\"com.azure.messaging.servicebus.ServiceBusMessage\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusMessage\"></xref> to a Service Bus queue or topic using a batched approach. If the size of messages exceed the maximum size of a single batch, an exception will be triggered and the send will fail. By default, the message size is the max amount allowed on the link."
type: "class"
desc: "A **synchronous** sender responsible for sending <xref uid=\"com.azure.messaging.servicebus.ServiceBusMessage\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusMessage\"></xref> to a queue or topic on Azure Service Bus.\n\nThe examples shown in this document use a credential object named DefaultAzureCredential for authentication, which is appropriate for most scenarios, including local development and production environments. Additionally, we recommend using [managed identity][] for authentication in production environments. You can find more information on different ways of authenticating and their corresponding credential types in the [Azure Identity documentation\"][Azure Identity documentation].\n\n**Sample: Create an instance of sender**\n\n```java\nTokenCredential credential = new DefaultAzureCredentialBuilder().build();\n\n // 'fullyQualifiedNamespace' will look similar to \"{your-namespace}.servicebus.windows.net\"\n ServiceBusSenderClient sender = new ServiceBusClientBuilder()\n .credential(fullyQualifiedNamespace, credential)\n .sender()\n .queueName(queueName)\n .buildClient();\n\n sender.sendMessage(new ServiceBusMessage(\"Foo bar\"));\n```\n\n**Sample: Send messages to a Service Bus resource**\n\n```java\nTokenCredential credential = new DefaultAzureCredentialBuilder().build();\n\n // 'fullyQualifiedNamespace' will look similar to \"{your-namespace}.servicebus.windows.net\"\n ServiceBusSenderClient sender = new ServiceBusClientBuilder()\n .credential(fullyQualifiedNamespace, credential)\n .sender()\n .queueName(queueName)\n .buildClient();\n\n List<ServiceBusMessage> messages = Arrays.asList(\n new ServiceBusMessage(\"test-1\"),\n new ServiceBusMessage(\"test-2\"));\n\n // Creating a batch without options set.\n ServiceBusMessageBatch batch = sender.createMessageBatch();\n for (ServiceBusMessage message : messages) {\n if (batch.tryAddMessage(message)) {\n continue;\n }\n\n // The batch is full. Send the current batch and create a new one.\n sender.sendMessages(batch);\n\n batch = sender.createMessageBatch();\n\n // Add the message we couldn't before.\n if (!batch.tryAddMessage(message)) {\n throw new IllegalArgumentException(\"Message is too large for an empty batch.\");\n }\n }\n\n // Send the final batch if there are any messages in it.\n if (batch.getCount() > 0) {\n sender.sendMessages(batch);\n }\n\n // Continue using the sender and finally, dispose of the sender.\n // Clients should be long-lived objects as they require resources\n // and time to establish a connection to the service.\n sender.close();\n```\n\n**Sample: Send messages using a size-limited <xref uid=\"com.azure.messaging.servicebus.ServiceBusMessageBatch\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusMessageBatch\"></xref>**\n\n```java\nList<ServiceBusMessage> telemetryMessages = Arrays.asList(firstMessage, secondMessage, thirdMessage);\n\n // Setting `setMaximumSizeInBytes` when creating a batch, limits the size of that batch.\n // In this case, all the batches created with these options are limited to 256 bytes.\n CreateMessageBatchOptions options = new CreateMessageBatchOptions()\n .setMaximumSizeInBytes(256);\n\n ServiceBusMessageBatch currentBatch = sender.createMessageBatch(options);\n\n // For each telemetry message, we try to add it to the current batch.\n // When the batch is full, send it then create another batch to add more mesages to.\n for (ServiceBusMessage message : telemetryMessages) {\n if (!currentBatch.tryAddMessage(message)) {\n sender.sendMessages(currentBatch);\n currentBatch = sender.createMessageBatch(options);\n\n // Add the message we couldn't before.\n if (!currentBatch.tryAddMessage(message)) {\n throw new IllegalArgumentException(\"Message is too large for an empty batch.\");\n }\n }\n }\n\n // Send the final batch if there are any messages in it.\n if (currentBatch.getCount() > 0) {\n sender.sendMessages(currentBatch);\n }\n\n // Continue using the sender and finally, dispose of the sender.\n // Clients should be long-lived objects as they require resources\n // and time to establish a connection to the service.\n sender.close();\n```\n\n**Sample: Sending a message to a session-enabled queue**\n\nThe snippet below demonstrates sending a message to a [Service Bus sessions][] enabled queue. Setting <xref uid=\"com.azure.messaging.servicebus.ServiceBusMessage.setMessageId(java.lang.String)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusMessage#setMessageId(String)\"></xref> property to \"greetings\" will send the message to a Service Bus session with an id of \"greetings\".\n\n```java\n// 'fullyQualifiedNamespace' will look similar to \"{your-namespace}.servicebus.windows.net\"\n ServiceBusSenderClient sender = new ServiceBusClientBuilder()\n .credential(fullyQualifiedNamespace, new DefaultAzureCredentialBuilder().build())\n .sender()\n .queueName(sessionEnabledQueueName)\n .buildClient();\n\n // Setting sessionId publishes that message to a specific session, in this case, \"greeting\".\n ServiceBusMessage message = new ServiceBusMessage(\"Hello world\")\n .setSessionId(\"greetings\");\n\n sender.sendMessage(message);\n\n // Dispose of the sender.\n sender.close();\n```\n\n\n[managed identity]: https://learn.microsoft.com/azure/active-directory/managed-identities-azure-resources/\n[Azure Identity documentation]: https://learn.microsoft.com/java/api/overview/azure/identity-readme\n[Service Bus sessions]: https://learn.microsoft.com/azure/service-bus-messaging/message-sessions"
implements:
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/AutoCloseable.html\">AutoCloseable</a>"
metadata: {}
package: "com.azure.messaging.servicebus"
artifact: com.azure:azure-messaging-servicebus:7.17.5