from pyspark.sql import SparkSession
from azure.servicebus import ServiceBusClient, ServiceBusMessage
if __name__ == "__main__":
rith_servicebus_conn_string = "Endpoint=sb://servicebusname.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=umaboZwpRa+sQ="
rith_service_bus_queue = "rithwik"
rith_message = "Hello Rithwik Bojja Service Bus!"
with ServiceBusClient.from_connection_string(rith_servicebus_conn_string) as client:
with client.get_queue_sender(rith_service_bus_queue) as sender:
rith_msg = ServiceBusMessage(rith_message)
sender.send_messages(rith_msg)
print("Hello Rithwik Bojja!!!, Messages sent to Service Bus.")
1条答案
按热度按时间mmvthczy1#
从synapse notebook向服务总线队列发送消息
你可以使用下面的代码来做同样的事情:
字符串
在这里,
rith_service_bus_queue
=队列名称rith_servicebus_conn_string
=连接字符串在使用上面的代码之前,请安装这个包:
型
的数据
Output:
的
In Service Bus Queue:
的