/
azure.servicebus.ServiceBusSender.yml
286 lines (258 loc) · 12 KB
/
azure.servicebus.ServiceBusSender.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
### YamlMime:PythonClass
uid: azure.servicebus.ServiceBusSender
name: ServiceBusSender
fullName: azure.servicebus.ServiceBusSender
module: azure.servicebus
inheritances:
- azure.servicebus._base_handler.BaseHandler
- azure.servicebus._servicebus_sender.SenderMixin
summary: 'The ServiceBusSender class defines a high level interface for
sending messages to the Azure Service Bus Queue or Topic.
**Please use the `get_<queue/topic>_sender` method of ~azure.servicebus.ServiceBusClient
to create a
ServiceBusSender instance.**'
constructor:
syntax: 'ServiceBusSender(fully_qualified_namespace: str, credential: TokenCredential
| AzureSasCredential | AzureNamedKeyCredential, *, queue_name: str | None = None,
topic_name: str | None = None, **kwargs: Any)'
parameters:
- name: fully_qualified_namespace
description: 'The fully qualified host name for the Service Bus namespace.
The namespace format is: *<yournamespace>.servicebus.windows.net*.'
isRequired: true
types:
- <xref:str>
- name: credential
description: 'The credential object used for authentication which
implements a particular interface for getting tokens. It accepts
credential objects generated by the azure-identity library and objects that
implement the
*get_token(self, *scopes)* method, or alternatively, an AzureSasCredential can
be provided too.'
isRequired: true
types:
- <xref:azure.core.credentials.TokenCredential>
- <xref:azure.core.credentials.AzureSasCredential>
- <xref:azure.core.credentials.AzureNamedKeyCredential>
keywordOnlyParameters:
- name: queue_name
description: The path of specific Service Bus Queue the client connects to.
types:
- <xref:str>
- name: topic_name
description: The path of specific Service Bus Topic the client connects to.
types:
- <xref:str>
- name: logging_enable
description: Whether to output network trace logs to the logger. Default is *False*.
types:
- <xref:bool>
- name: transport_type
description: 'The type of transport protocol that will be used for communicating
with
the Service Bus service. Default is *TransportType.Amqp*.'
types:
- <xref:azure.servicebus.TransportType>
- name: http_proxy
description: 'HTTP proxy settings. This must be a dictionary with the following
keys: *''proxy_hostname''* (str value) and *''proxy_port''* (int value).
Additionally the following keys may also be present: *''username'', ''password''*.'
types:
- <xref:typing.Dict>
- name: user_agent
description: If specified, this will be added in front of the built-in user agent
string.
types:
- <xref:str>
- name: client_identifier
description: 'A string-based identifier to uniquely identify the client instance.
Service Bus will associate it with some error messages for easier correlation
of errors.
If not specified, a unique id will be generated.'
types:
- <xref:str>
- name: socket_timeout
description: 'The time in seconds that the underlying socket on the connection
should
wait when sending and receiving data before timing out. The default value is
0.2 for TransportType.Amqp
and 1 for TransportType.AmqpOverWebsocket. If connection errors are occurring
due to write timing out,
a larger than default value may need to be passed in.'
types:
- <xref:float>
variables:
- description: 'The fully qualified host name for the Service Bus namespace.
The namespace format is: *<yournamespace>.servicebus.windows.net*.'
name: fully_qualified_namespace
types:
- <xref:str>
- description: The name of the entity that the client connects to.
name: entity_name
types:
- <xref:str>
methods:
- uid: azure.servicebus.ServiceBusSender.cancel_scheduled_messages
name: cancel_scheduled_messages
summary: Cancel one or more messages that have previously been scheduled and are
still pending.
signature: 'cancel_scheduled_messages(sequence_numbers: int | List[int], *, timeout:
float | None = None, **kwargs: Any) -> None'
parameters:
- name: sequence_numbers
description: The sequence numbers of the scheduled messages.
isRequired: true
types:
- <xref:int>
- <xref:list>[<xref:int>]
keywordOnlyParameters:
- name: timeout
description: 'The total operation timeout in seconds including all the retries.
The value must be
greater than 0 if specified. The default value is None, meaning no timeout.'
types:
- <xref:float>
return:
types:
- <xref:None>
exceptions:
- type: azure.servicebus.exceptions.ServiceBusError if messages cancellation failed
due to message alreadycancelled or enqueued.
examples:
- "Cancelling messages scheduled to be sent in future<!--[!code-python[Main](les\\\
sync_samples\\sample_code_servicebus.py )]-->\n\n<!-- literal_block {\"ids\":\
\ [], \"classes\": [], \"names\": [], \"dupnames\": [], \"backrefs\": [], \"source\"\
: \"C:\\\\hostedtoolcache\\\\windows\\\\Python\\\\3.11.9\\\\x64\\\\Lib\\\\site-packages\\\
\\py2docfx\\\\dist_temp\\\\221\\\\azure-servicebus-7.12.2\\\\samples\\\\sync_samples\\\
\\sample_code_servicebus.py\", \"xml:space\": \"preserve\", \"force\": false,\
\ \"language\": \"python\", \"highlight_args\": {\"linenostart\": 1}, \"linenos\"\
: false} -->\n\n````python\n\n with servicebus_sender:\n servicebus_sender.cancel_scheduled_messages(sequence_nums)\n\
\n ````\n"
- uid: azure.servicebus.ServiceBusSender.close
name: close
summary: 'Close down the handler links (and connection if the handler uses a separate
connection).
If the handler has already closed, this operation will do nothing.'
signature: close() -> None
return:
types:
- <xref:None>
- uid: azure.servicebus.ServiceBusSender.create_message_batch
name: create_message_batch
summary: 'Create a ServiceBusMessageBatch object with the max size of all content
being constrained by
max_size_in_bytes. The max_size should be no greater than the max allowed message
size defined by the service.'
signature: 'create_message_batch(max_size_in_bytes: int | None = None) -> ServiceBusMessageBatch'
parameters:
- name: max_size_in_bytes
description: 'The maximum size of bytes data that a ServiceBusMessageBatch object
can
hold. By default, the value is determined by your Service Bus tier.'
defaultValue: None
types:
- <xref:typing.Optional>[<xref:int>]
return:
description: A ServiceBusMessageBatch object
types:
- <xref:azure.servicebus.ServiceBusMessageBatch>
examples:
- "Create ServiceBusMessageBatch object within limited size<!--[!code-python[Main](les\\\
sync_samples\\sample_code_servicebus.py )]-->\n\n<!-- literal_block {\"ids\":\
\ [], \"classes\": [], \"names\": [], \"dupnames\": [], \"backrefs\": [], \"source\"\
: \"C:\\\\hostedtoolcache\\\\windows\\\\Python\\\\3.11.9\\\\x64\\\\Lib\\\\site-packages\\\
\\py2docfx\\\\dist_temp\\\\221\\\\azure-servicebus-7.12.2\\\\samples\\\\sync_samples\\\
\\sample_code_servicebus.py\", \"xml:space\": \"preserve\", \"force\": false,\
\ \"language\": \"python\", \"highlight_args\": {\"linenostart\": 1}, \"linenos\"\
: false} -->\n\n````python\n\n with servicebus_sender:\n batch_message\
\ = servicebus_sender.create_message_batch()\n batch_message.add_message(ServiceBusMessage(\"\
Single message inside batch\"))\n\n ````\n"
- uid: azure.servicebus.ServiceBusSender.schedule_messages
name: schedule_messages
summary: 'Send Message or multiple Messages to be enqueued at a specific time.
Returns a list of the sequence numbers of the enqueued messages.'
signature: 'schedule_messages(messages: MessageTypes, schedule_time_utc: datetime,
*, timeout: float | None = None, **kwargs: Any) -> List[int]'
parameters:
- name: messages
description: The message or list of messages to schedule.
isRequired: true
types:
- <xref:typing.Union>[<xref:azure.servicebus.ServiceBusMessage>, <xref:azure.servicebus.amqp.AmqpAnnotatedMessage>,
<xref:typing.List>[<xref:typing.Union>[<xref:azure.servicebus.ServiceBusMessage>,
<xref:azure.servicebus.amqp.AmqpAnnotatedMessage>]]]
- name: schedule_time_utc
description: The utc date and time to enqueue the messages.
isRequired: true
types:
- <xref:datetime.datetime>
keywordOnlyParameters:
- name: timeout
description: 'The total operation timeout in seconds including all the retries.
The value must be
greater than 0 if specified. The default value is None, meaning no timeout.'
types:
- <xref:float>
return:
description: A list of the sequence numbers of the enqueued messages.
types:
- <xref:list>[<xref:int>]
examples:
- "Schedule a message to be sent in future<!--[!code-python[Main](les\\sync_samples\\\
sample_code_servicebus.py )]-->\n\n<!-- literal_block {\"ids\": [], \"classes\"\
: [], \"names\": [], \"dupnames\": [], \"backrefs\": [], \"source\": \"C:\\\\\
hostedtoolcache\\\\windows\\\\Python\\\\3.11.9\\\\x64\\\\Lib\\\\site-packages\\\
\\py2docfx\\\\dist_temp\\\\221\\\\azure-servicebus-7.12.2\\\\samples\\\\sync_samples\\\
\\sample_code_servicebus.py\", \"xml:space\": \"preserve\", \"force\": false,\
\ \"language\": \"python\", \"highlight_args\": {\"linenostart\": 1}, \"linenos\"\
: false} -->\n\n````python\n\n with servicebus_sender:\n scheduled_time_utc\
\ = datetime.datetime.utcnow() + datetime.timedelta(seconds=30)\n scheduled_messages\
\ = [ServiceBusMessage(\"Scheduled message\") for _ in range(10)]\n sequence_nums\
\ = servicebus_sender.schedule_messages(scheduled_messages, scheduled_time_utc)\n\
\n ````\n"
- uid: azure.servicebus.ServiceBusSender.send_messages
name: send_messages
summary: 'Sends message and blocks until acknowledgement is received or operation
times out.
If a list of messages was provided, attempts to send them as a single batch, throwing
a
*ValueError* if they cannot fit in a single batch.'
signature: 'send_messages(message: MessageTypes | ServiceBusMessageBatch, *, timeout:
float | None = None, **kwargs: Any) -> None'
parameters:
- name: message
description: The ServiceBus message to be sent.
isRequired: true
types:
- <xref:typing.Union>[<xref:azure.servicebus.ServiceBusMessage>, <xref:azure.servicebus.ServiceBusMessageBatch>,
<xref:azure.servicebus.amqp.AmqpAnnotatedMessage>, <xref:typing.List>[<xref:typing.Union>[<xref:azure.servicebus.ServiceBusMessage>,
<xref:azure.servicebus.amqp.AmqpAnnotatedMessage>]]]
keywordOnlyParameters:
- name: timeout
description: 'The total operation timeout in seconds including all the retries.
The value must be greater than 0 if specified. The default value is None, meaning
no timeout.'
types:
- <xref:typing.Optional>[<xref:float>]
return:
types:
- <xref:None>
exceptions:
- type: azure.servicebus.exceptions.OperationTimeoutError if sending times out.
examples:
- "Send message.<!--[!code-python[Main](les\\sync_samples\\sample_code_servicebus.py\
\ )]-->\n\n<!-- literal_block {\"ids\": [], \"classes\": [], \"names\": [], \"\
dupnames\": [], \"backrefs\": [], \"source\": \"C:\\\\hostedtoolcache\\\\windows\\\
\\Python\\\\3.11.9\\\\x64\\\\Lib\\\\site-packages\\\\py2docfx\\\\dist_temp\\\\\
221\\\\azure-servicebus-7.12.2\\\\samples\\\\sync_samples\\\\sample_code_servicebus.py\"\
, \"xml:space\": \"preserve\", \"force\": false, \"language\": \"python\", \"\
highlight_args\": {\"linenostart\": 1}, \"linenos\": false} -->\n\n````python\n\
\n with servicebus_sender:\n message_send = ServiceBusMessage(\"Hello\
\ World\")\n servicebus_sender.send_messages(message_send)\n\n ````\n"
attributes:
- uid: azure.servicebus.ServiceBusSender.client_identifier
name: client_identifier
summary: Get the ServiceBusSender client_identifier associated with the sender instance.
return:
types:
- <xref:str>