forked from Azure/azure-sdk-for-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ServiceBus] Http proxy/transport type bug fixing and sample update (A…
…zure#10721) * 1.Http proxy/transport type bug fixing 2.sample update * update changelog * add test for proxy and websocket
- Loading branch information
1 parent
2b2cfd4
commit 0225748
Showing
8 changed files
with
195 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
sdk/servicebus/azure-servicebus/samples/async_samples/proxy_async.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env python | ||
|
||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
""" | ||
Example to show sending message through http proxy to a Service Bus Queue asynchronously. | ||
""" | ||
|
||
# pylint: disable=C0111 | ||
|
||
import os | ||
import asyncio | ||
from azure.servicebus import Message | ||
from azure.servicebus.aio import ServiceBusClient | ||
|
||
CONNECTION_STR = os.environ['SERVICE_BUS_CONNECTION_STR'] | ||
QUEUE_NAME = os.environ["SERVICE_BUS_QUEUE_NAME"] | ||
|
||
|
||
HTTP_PROXY = { | ||
'proxy_hostname': '127.0.0.1', # proxy hostname. | ||
'proxy_port': 8899, # proxy port. | ||
'username': 'admin', # username used for proxy authentication if needed. | ||
'password': '123456' # password used for proxy authentication if needed. | ||
} | ||
|
||
|
||
async def send_single_message(sender): | ||
message = Message("DATA" * 64) | ||
await sender.send(message) | ||
|
||
|
||
async def main(): | ||
servicebus_client = ServiceBusClient.from_connection_string( | ||
conn_str=CONNECTION_STR, | ||
http_proxy=HTTP_PROXY | ||
) | ||
|
||
async with servicebus_client: | ||
sender = servicebus_client.get_queue_sender(queue_name=QUEUE_NAME) | ||
async with sender: | ||
await send_single_message(sender) | ||
|
||
print("Send message is done.") | ||
|
||
|
||
loop = asyncio.get_event_loop() | ||
loop.run_until_complete(main()) |
44 changes: 44 additions & 0 deletions
44
sdk/servicebus/azure-servicebus/samples/sync_samples/proxy.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env python | ||
|
||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
""" | ||
Example to show sending message through http proxy to a Service Bus Queue. | ||
""" | ||
|
||
# pylint: disable=C0111 | ||
|
||
import os | ||
from azure.servicebus import ServiceBusClient, Message | ||
|
||
CONNECTION_STR = os.environ['SERVICE_BUS_CONNECTION_STR'] | ||
QUEUE_NAME = os.environ["SERVICE_BUS_QUEUE_NAME"] | ||
|
||
|
||
HTTP_PROXY = { | ||
'proxy_hostname': '127.0.0.1', # proxy hostname. | ||
'proxy_port': 8899, # proxy port. | ||
'username': 'admin', # username used for proxy authentication if needed. | ||
'password': '123456' # password used for proxy authentication if needed. | ||
} | ||
|
||
|
||
def send_single_message(sender): | ||
message = Message("DATA" * 64) | ||
sender.send(message) | ||
|
||
|
||
servicebus_client = ServiceBusClient.from_connection_string( | ||
conn_str=CONNECTION_STR, | ||
http_proxy=HTTP_PROXY | ||
) | ||
|
||
with servicebus_client: | ||
sender = servicebus_client.get_queue_sender(queue_name=QUEUE_NAME) | ||
with sender: | ||
send_single_message(sender) | ||
|
||
print("Send message is done.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters