@@ -55,23 +55,53 @@ def servicebus_trigger(msg: func.ServiceBusMessage) -> str:
55
55
return result
56
56
57
57
58
+ @app .route (route = "put_message_batch" )
59
+ @app .service_bus_queue_output (
60
+ arg_name = "msg" ,
61
+ connection = "AzureWebJobsServiceBusConnectionString" ,
62
+ queue_name = "testqueuebatch" )
63
+ def put_message_batch (req : func .HttpRequest , msg : func .Out [str ]):
64
+ msg .set (req .get_body ().decode ('utf-8' ))
65
+ return 'OK'
66
+
67
+
58
68
@app .service_bus_queue_trigger (
59
69
arg_name = "msg" ,
60
70
connection = "AzureWebJobsServiceBusConnectionString" ,
61
- queue_name = "testqueue" ,
62
- cardinality = func .Cardinality .MANY )
71
+ queue_name = "testqueuebatch" , cardinality = "many" )
63
72
@app .blob_output (arg_name = "$return" ,
64
- path = "python-worker-tests/servicebus-triggered_batch .txt" ,
73
+ path = "python-worker-tests/test- servicebus-batch .txt" ,
65
74
connection = "AzureWebJobsStorage" )
66
- def servicebus_triggered (msg : func .ServiceBusMessage ) -> str :
67
- return str (msg )
75
+ def servicebus_trigger_batch (msg : func .ServiceBusMessage ) -> str :
76
+ msg = msg [0 ]
77
+ print (f"Message ============> { msg } " )
78
+ result = json .dumps ({
79
+ 'body' : msg .get_body ().decode ('utf-8' ),
80
+ 'content_type' : msg .content_type ,
81
+ 'delivery_count' : msg .delivery_count ,
82
+ 'expiration_time' : (msg .expiration_time .isoformat () if
83
+ msg .expiration_time else None ),
84
+ 'label' : msg .label ,
85
+ 'partition_key' : msg .partition_key ,
86
+ 'reply_to' : msg .reply_to ,
87
+ 'reply_to_session_id' : msg .reply_to_session_id ,
88
+ 'scheduled_enqueue_time' : (msg .scheduled_enqueue_time .isoformat () if
89
+ msg .scheduled_enqueue_time else None ),
90
+ 'session_id' : msg .session_id ,
91
+ 'time_to_live' : msg .time_to_live ,
92
+ 'to' : msg .to ,
93
+ 'user_properties' : msg .user_properties ,
94
+ })
95
+
96
+ return result
68
97
69
98
70
- @app .route (route = "servicebus_triggered " )
99
+ @app .route (route = "get_servicebus_triggered_batch " )
71
100
@app .blob_input (arg_name = "file" ,
72
- path = "python-worker-tests/servicebus-triggered_batch .txt" ,
101
+ path = "python-worker-tests/test- servicebus-batch .txt" ,
73
102
connection = "AzureWebJobsStorage" )
74
- def get_servicebus_triggered (req : func .HttpRequest ,
75
- file : func .InputStream ) -> str :
103
+ def get_servicebus_triggered_batch (req : func .HttpRequest ,
104
+ file : func .InputStream ) -> str :
76
105
return func .HttpResponse (
77
- file .read ().decode ('utf-8' ), mimetype = 'application/json' )
106
+ file .read ().decode ('utf-8' ), mimetype = 'application/json' )
107
+
0 commit comments