/
azure.servicebus.ServiceBusClient.yml
702 lines (590 loc) · 28.4 KB
/
azure.servicebus.ServiceBusClient.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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
### YamlMime:PythonClass
uid: azure.servicebus.ServiceBusClient
name: ServiceBusClient
fullName: azure.servicebus.ServiceBusClient
module: azure.servicebus
inheritances:
- builtins.object
summary: 'The ServiceBusClient class defines a high level interface for
getting ServiceBusSender and ServiceBusReceiver.'
constructor:
syntax: 'ServiceBusClient(fully_qualified_namespace: str, credential: TokenCredential
| AzureSasCredential | AzureNamedKeyCredential, *, retry_total: int = 3, retry_backoff_factor:
float = 0.8, retry_backoff_max: float = 120, retry_mode: str = ''exponential'',
**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: 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* in which case port
5671 is used.
If the port 5671 is unavailable/blocked in the network environment, *TransportType.AmqpOverWebsocket*
could
be used instead which uses port 443 for communication.'
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: retry_total
description: 'The total number of attempts to redo a failed operation when an
error occurs.
Default value is 3.'
defaultValue: '3'
types:
- <xref:int>
- name: retry_backoff_factor
description: 'Delta back-off internal in the unit of second between retries.
Default value is 0.8.'
defaultValue: '0.8'
types:
- <xref:float>
- name: retry_backoff_max
description: Maximum back-off interval in the unit of second. Default value is
120.
defaultValue: '120'
types:
- <xref:float>
- name: retry_mode
description: 'The delay behavior between retry attempts. Supported values are
"fixed" or "exponential",
where default is "exponential".'
defaultValue: exponential
types:
- <xref:str>
- name: custom_endpoint_address
description: 'The custom endpoint address to use for establishing a connection
to
the Service Bus service, allowing network requests to be routed through any
application gateways or
other paths needed for the host environment. Default is None.
The format would be like "sb://<custom_endpoint_hostname>:<custom_endpoint_port>".
If port is not specified in the *custom_endpoint_address*, by default port 443
will be used.'
types:
- <xref:str>
- name: connection_verify
description: 'Path to the custom CA_BUNDLE file of the SSL certificate which is
used to
authenticate the identity of the connection endpoint.
Default is None in which case *certifi.where()* will be used.'
types:
- <xref:str>
- name: uamqp_transport
description: 'Whether to use the *uamqp* library as the underlying transport.
The default value is
False and the Pure Python AMQP library will be used as the underlying transport.'
types:
- <xref:bool>
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>
examples:
- "Create a new instance of the ServiceBusClient.<!--[!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.1\\\\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 import os\n\
\ from azure.identity import DefaultAzureCredential\n from azure.servicebus\
\ import ServiceBusClient\n fully_qualified_namespace = os.environ['SERVICEBUS_FULLY_QUALIFIED_NAMESPACE']\n\
\ servicebus_client = ServiceBusClient(\n fully_qualified_namespace=fully_qualified_namespace,\n\
\ credential=DefaultAzureCredential()\n )\n\n ````\n"
methods:
- uid: azure.servicebus.ServiceBusClient.close
name: close
summary: 'Close down the ServiceBus client.
All spawned senders, receivers and underlying connection will be shutdown.'
signature: close() -> None
return:
description: None
- uid: azure.servicebus.ServiceBusClient.from_connection_string
name: from_connection_string
summary: Create a ServiceBusClient from a connection string.
signature: 'from_connection_string(conn_str: str, *, retry_total: int = 3, retry_backoff_factor:
float = 0.8, retry_backoff_max: float = 120, retry_mode: str = ''exponential'',
**kwargs: Any) -> ServiceBusClient'
parameters:
- name: conn_str
description: The connection string of a Service Bus.
isRequired: true
types:
- <xref:str>
keywordOnlyParameters:
- 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* in which case port
5671 is used.
If the port 5671 is unavailable/blocked in the network environment, *TransportType.AmqpOverWebsocket*
could
be used instead which uses port 443 for communication.'
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: retry_total
description: 'The total number of attempts to redo a failed operation when an
error occurs.
Default value is 3.'
defaultValue: '3'
types:
- <xref:int>
- name: retry_backoff_factor
description: 'Delta back-off internal in the unit of second between retries.
Default value is 0.8.'
defaultValue: '0.8'
types:
- <xref:float>
- name: retry_backoff_max
description: Maximum back-off interval in the unit of second. Default value is
120.
defaultValue: '120'
types:
- <xref:float>
- name: retry_mode
description: 'The delay behavior between retry attempts. Supported values are
''fixed'' or ''exponential'',
where default is ''exponential''.'
defaultValue: exponential
types:
- <xref:str>
- name: custom_endpoint_address
description: 'The custom endpoint address to use for establishing a connection
to
the Service Bus service, allowing network requests to be routed through any
application gateways or
other paths needed for the host environment. Default is None.
The format would be like "sb://<custom_endpoint_hostname>:<custom_endpoint_port>".
If port is not specified in the custom_endpoint_address, by default port 443
will be used.'
types:
- <xref:str>
- name: connection_verify
description: 'Path to the custom CA_BUNDLE file of the SSL certificate which is
used to
authenticate the identity of the connection endpoint.
Default is None in which case *certifi.where()* will be used.'
types:
- <xref:str>
- name: uamqp_transport
description: 'Whether to use the *uamqp* library as the underlying transport.
The default value is
False and the Pure Python AMQP library will be used as the underlying transport.'
types:
- <xref:bool>
return:
types:
- <xref:azure.servicebus.ServiceBusClient>
examples:
- "Create a new instance of the ServiceBusClient from connection string.<!--[!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.1\\\\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 import os\n from azure.servicebus import ServiceBusClient\n\
\ servicebus_connection_str = os.environ['SERVICEBUS_CONNECTION_STR']\n servicebus_client\
\ = ServiceBusClient.from_connection_string(conn_str=servicebus_connection_str)\n\
\n ````\n"
- uid: azure.servicebus.ServiceBusClient.get_queue_receiver
name: get_queue_receiver
summary: Get ServiceBusReceiver for the specific queue.
signature: 'get_queue_receiver(queue_name: str, *, session_id: str | ~typing.Literal[<ServiceBusSessionFilter.NEXT_AVAILABLE:
0>] | None = None, sub_queue: ~azure.servicebus._common.constants.ServiceBusSubQueue
| str | None = None, receive_mode: ~azure.servicebus._common.constants.ServiceBusReceiveMode
| str = ServiceBusReceiveMode.PEEK_LOCK, max_wait_time: float | None = None, auto_lock_renewer:
~azure.servicebus._common.auto_lock_renewer.AutoLockRenewer | None = None, prefetch_count:
int = 0, **kwargs: ~typing.Any) -> ServiceBusReceiver'
parameters:
- name: queue_name
description: The path of specific Service Bus Queue the client connects to.
isRequired: true
types:
- <xref:str>
keywordOnlyParameters:
- name: session_id
description: 'A specific session from which to receive. This must be specified
for a
sessionful queue, otherwise it must be None. In order to receive messages from
the next available
session, set this to ~azure.servicebus.NEXT_AVAILABLE_SESSION.'
types:
- <xref:str>
- <xref:azure.servicebus.NEXT_AVAILABLE_SESSION>
- name: sub_queue
description: 'If specified, the subqueue this receiver will connect to.
This includes the DEAD_LETTER and TRANSFER_DEAD_LETTER queues, holds messages
that can''t be delivered to any
receiver or messages that can''t be processed.
The default is None, meaning connect to the primary queue. Can be assigned
values from *ServiceBusSubQueue*
enum or equivalent string values "deadletter" and "transferdeadletter".'
types:
- <xref:str>
- <xref:azure.servicebus.ServiceBusSubQueue>
- <xref:None>
- name: receive_mode
description: 'The receive_mode with which messages will be retrieved from the
entity. The two options
are PEEK_LOCK and RECEIVE_AND_DELETE. Messages received with PEEK_LOCK must
be settled within a given
lock period before they will be removed from the queue. Messages received with
RECEIVE_AND_DELETE
will be immediately removed from the queue, and cannot be subsequently rejected
or re-received if
the client fails to process the message. The default receive_mode is PEEK_LOCK.'
defaultValue: ServiceBusReceiveMode.PEEK_LOCK
types:
- <xref:typing.Union>[<xref:azure.servicebus.ServiceBusReceiveMode>, <xref:str>]
- name: max_wait_time
description: 'The timeout in seconds to wait for the first and subsequent
messages to arrive. If no messages arrive, and no timeout is specified, this
call will not return
until the connection is closed. The default value is None, meaning no timeout.
On a sessionful
queue/topic when NEXT_AVAILABLE_SESSION is specified, this will act as the timeout
for connecting.
If connection errors are occurring due to write timing out,the connection timeout
value may need to be adjusted. See the *socket_timeout* optional parameter for
more details.'
types:
- <xref:typing.Optional>[<xref:float>]
- name: auto_lock_renewer
description: 'An ~azure.servicebus.AutoLockRenewer
can be provided such that messages are automatically registered on receipt.
If the receiver is a session
receiver, it will apply to the session instead.'
types:
- <xref:typing.Optional>[<xref:azure.servicebus.AutoLockRenewer>]
- name: prefetch_count
description: 'The maximum number of messages to cache with each request to the
service.
This setting is only for advanced performance tuning. Increasing this value
will improve message throughput
performance but increase the chance that messages will expire while they are
cached if they''re not
processed fast enough.
The default value is 0, meaning messages will be received from the service and
processed one at a time.
In the case of prefetch_count being 0, *ServiceBusReceiver.receive_messages*
would try to cache
*max_message_count* (if provided) within its request to the service.
>>**<<WARNING: If prefetch_count > 0 and RECEIVE_AND_DELETE mode is used, all
prefetched messages will stay in
the in-memory prefetch buffer until they''re received into the application.
If the application ends before
the messages are received into the application, those messages will be lost
and unable to be recovered.
Therefore, it''s recommended that PEEK_LOCK mode be used with prefetch.'
types:
- <xref:int>
- name: client_identifier
description: 'A string-based identifier to uniquely identify the receiver 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>
return:
types:
- <xref:azure.servicebus.ServiceBusReceiver>
examples:
- "Create a new instance of the ServiceBusReceiver from ServiceBusClient.<!--[!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.1\\\\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 import os\n from azure.servicebus import ServiceBusClient\n\
\ servicebus_connection_str = os.environ['SERVICEBUS_CONNECTION_STR']\n queue_name\
\ = os.environ['SERVICEBUS_QUEUE_NAME']\n servicebus_client = ServiceBusClient.from_connection_string(conn_str=servicebus_connection_str)\n\
\ with servicebus_client:\n queue_receiver = servicebus_client.get_queue_receiver(queue_name=queue_name)\n\
\n ````\n"
- uid: azure.servicebus.ServiceBusClient.get_queue_sender
name: get_queue_sender
summary: Get ServiceBusSender for the specific queue.
signature: 'get_queue_sender(queue_name: str, **kwargs: Any) -> ServiceBusSender'
parameters:
- name: queue_name
description: The path of specific Service Bus Queue the client connects to.
isRequired: true
types:
- <xref:str>
keywordOnlyParameters:
- name: client_identifier
description: 'A string-based identifier to uniquely identify the sender 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>
return:
description: A queue Sender.
types:
- <xref:azure.servicebus.ServiceBusSender>
examples:
- "Create a new instance of the ServiceBusSender from ServiceBusClient.<!--[!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.1\\\\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 import os\n from azure.servicebus import ServiceBusClient\n\
\ servicebus_connection_str = os.environ['SERVICEBUS_CONNECTION_STR']\n queue_name\
\ = os.environ['SERVICEBUS_QUEUE_NAME']\n servicebus_client = ServiceBusClient.from_connection_string(conn_str=servicebus_connection_str)\n\
\ with servicebus_client:\n queue_sender = servicebus_client.get_queue_sender(queue_name=queue_name)\n\
\n ````\n"
- uid: azure.servicebus.ServiceBusClient.get_subscription_receiver
name: get_subscription_receiver
summary: Get ServiceBusReceiver for the specific subscription under the topic.
signature: 'get_subscription_receiver(topic_name: str, subscription_name: str, *,
session_id: str | ~typing.Literal[<ServiceBusSessionFilter.NEXT_AVAILABLE: 0>]
| None = None, sub_queue: ~azure.servicebus._common.constants.ServiceBusSubQueue
| str | None = None, receive_mode: ~azure.servicebus._common.constants.ServiceBusReceiveMode
| str = ServiceBusReceiveMode.PEEK_LOCK, max_wait_time: float | None = None, auto_lock_renewer:
~azure.servicebus._common.auto_lock_renewer.AutoLockRenewer | None = None, prefetch_count:
int = 0, **kwargs: ~typing.Any) -> ServiceBusReceiver'
parameters:
- name: topic_name
description: The name of specific Service Bus Topic the client connects to.
isRequired: true
types:
- <xref:str>
- name: subscription_name
description: 'The name of specific Service Bus Subscription
under the given Service Bus Topic.'
isRequired: true
types:
- <xref:str>
keywordOnlyParameters:
- name: session_id
description: 'A specific session from which to receive. This must be specified
for a
sessionful subscription, otherwise it must be None. In order to receive messages
from the next available
session, set this to ~azure.servicebus.NEXT_AVAILABLE_SESSION.'
types:
- <xref:str>
- <xref:azure.servicebus.NEXT_AVAILABLE_SESSION>
- name: sub_queue
description: 'If specified, the subqueue this receiver will connect to.
This includes the DEAD_LETTER and TRANSFER_DEAD_LETTER queues, holds messages
that can''t be delivered to any
receiver or messages that can''t be processed.
The default is None, meaning connect to the primary queue. Can be assigned
values from *ServiceBusSubQueue*
enum or equivalent string values "deadletter" and "transferdeadletter".'
types:
- <xref:str>
- <xref:azure.servicebus.ServiceBusSubQueue>
- <xref:None>
- name: receive_mode
description: 'The receive_mode with which messages will be retrieved from the
entity. The two options
are PEEK_LOCK and RECEIVE_AND_DELETE. Messages received with PEEK_LOCK must
be settled within a given
lock period before they will be removed from the subscription. Messages received
with RECEIVE_AND_DELETE
will be immediately removed from the subscription, and cannot be subsequently
rejected or re-received if
the client fails to process the message. The default receive_mode is PEEK_LOCK.'
defaultValue: ServiceBusReceiveMode.PEEK_LOCK
types:
- <xref:typing.Union>[<xref:azure.servicebus.ServiceBusReceiveMode>, <xref:str>]
- name: max_wait_time
description: 'The timeout in seconds to wait for the first and subsequent
messages to arrive. If no messages arrive, and no timeout is specified, this
call will not return
until the connection is closed. The default value is None, meaning no timeout.
On a sessionful
queue/topic when NEXT_AVAILABLE_SESSION is specified, this will act as the timeout
for connecting.
If connection errors are occurring due to write timing out,the connection timeout
value may need to be adjusted. See the *socket_timeout* optional parameter for
more details.'
types:
- <xref:typing.Optional>[<xref:float>]
- name: auto_lock_renewer
description: 'An ~azure.servicebus.AutoLockRenewer
can be provided such that messages are automatically registered on receipt.
If the receiver is a session
receiver, it will apply to the session instead.'
types:
- <xref:typing.Optional>[<xref:azure.servicebus.AutoLockRenewer>]
- name: prefetch_count
description: 'The maximum number of messages to cache with each request to the
service.
This setting is only for advanced performance tuning. Increasing this value
will improve message throughput
performance but increase the chance that messages will expire while they are
cached if they''re not
processed fast enough.
The default value is 0, meaning messages will be received from the service and
processed one at a time.
In the case of prefetch_count being 0, *ServiceBusReceiver.receive_messages*
would try to cache
*max_message_count* (if provided) within its request to the service.
>>**<<WARNING: If prefetch_count > 0 and RECEIVE_AND_DELETE mode is used, all
prefetched messages will stay in
the in-memory prefetch buffer until they''re received into the application.
If the application ends before
the messages are received into the application, those messages will be lost
and unable to be recovered.
Therefore, it''s recommended that PEEK_LOCK mode be used with prefetch.'
types:
- <xref:int>
- name: client_identifier
description: 'A string-based identifier to uniquely identify the receiver 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>
return:
types:
- <xref:azure.servicebus.ServiceBusReceiver>
examples:
- "Create a new instance of the ServiceBusReceiver from ServiceBusClient.<!--[!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.1\\\\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 import os\n from azure.servicebus import ServiceBusClient\n\
\ servicebus_connection_str = os.environ['SERVICEBUS_CONNECTION_STR']\n topic_name\
\ = os.environ[\"SERVICEBUS_TOPIC_NAME\"]\n subscription_name = os.environ[\"\
SERVICEBUS_SUBSCRIPTION_NAME\"]\n servicebus_client = ServiceBusClient.from_connection_string(conn_str=servicebus_connection_str)\n\
\ with servicebus_client:\n subscription_receiver = servicebus_client.get_subscription_receiver(\n\
\ topic_name=topic_name,\n subscription_name=subscription_name,\n\
\ )\n\n ````\n"
- uid: azure.servicebus.ServiceBusClient.get_topic_sender
name: get_topic_sender
summary: Get ServiceBusSender for the specific topic.
signature: 'get_topic_sender(topic_name: str, *, client_identifier: str | None =
None, socket_timeout: float | None = None, **kwargs: Any) -> ServiceBusSender'
parameters:
- name: topic_name
description: The path of specific Service Bus Topic the client connects to.
isRequired: true
types:
- <xref:str>
keywordOnlyParameters:
- name: client_identifier
description: 'A string-based identifier to uniquely identify the sender 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>
- <xref:None>
- 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. If None, a default value
of 0.2 for TransportType.Amqp
and 1 for TransportType.AmqpOverWebsocket is used. If connection errors are
occurring due to write timing out,
a larger than default value may need to be passed in.'
types:
- <xref:float>
- <xref:None>
return:
description: A topic sender.
types:
- <xref:azure.servicebus.ServiceBusSender>
examples:
- "Create a new instance of the ServiceBusSender from ServiceBusClient.<!--[!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.1\\\\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 import os\n from azure.servicebus import ServiceBusClient\n\
\ servicebus_connection_str = os.environ['SERVICEBUS_CONNECTION_STR']\n topic_name\
\ = os.environ['SERVICEBUS_TOPIC_NAME']\n servicebus_client = ServiceBusClient.from_connection_string(conn_str=servicebus_connection_str)\n\
\ with servicebus_client:\n topic_sender = servicebus_client.get_topic_sender(topic_name=topic_name)\n\
\n ````\n"