Skip to content

Commit 26d1df7

Browse files
Use case templates for Azure service bus (#505)
* Add files via upload * Removing account name: from yaml file * Add files via upload * Removing account-name: from yaml file * Update template-metadata.json * Update and rename Route messages from Azure Service Bus queue to Cosmos DB then forward to another queue and acknowledge the message.yaml to Route messages from Azure Service Bus queue to Cosmos DB then forward to another queue and acknowledge the message_instructions.md * Update Route messages from Azure Service Bus queue to Cosmos DB then forward to another queue and acknowledge the message_instructions.md update * Corrections --------- Co-authored-by: Deepak Ayilliath <[email protected]> Co-authored-by: Deepak Ayilliath <[email protected]>
1 parent ef573c3 commit 26d1df7

3 files changed

+270
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
$integration: http://ibm.com/appconnect/integration/v2/integrationFile
2+
integration:
3+
type: trigger-action
4+
trigger-interfaces:
5+
trigger-interface-1:
6+
type: event-trigger
7+
connector-type: azureservicebus
8+
triggers:
9+
CREATED:
10+
assembly:
11+
$ref: '#/integration/assemblies/assembly-1'
12+
input-context:
13+
data: Messages
14+
options:
15+
entityType: Queues
16+
entityType_Id: routingqueue
17+
parentFilter:
18+
entityType: Queues
19+
entityType_Id: routingqueue
20+
subscription: {}
21+
connectorServiceOptions:
22+
httpMethod: post
23+
path: >-
24+
resources/{entityType}/{entityType_Id}/Messages/operations/CREATED/subscribe
25+
action: created
26+
action-interfaces:
27+
action-interface-1:
28+
type: api-action
29+
business-object: Items
30+
connector-type: azurecosmosdb
31+
actions:
32+
getanItem: {}
33+
options:
34+
connectorServiceOptions:
35+
httpMethod: get
36+
path: >-
37+
resources/Database/{DatabaseId}/Container/{ContainerId}/Items/operations/getanItem
38+
action: retrieve
39+
action-interface-2:
40+
type: api-action
41+
business-object: Messages
42+
connector-type: azureservicebus
43+
actions:
44+
sendMessage: {}
45+
options:
46+
connectorServiceOptions:
47+
httpMethod: post
48+
path: >-
49+
resources/{entityType}/{entityType_Id}/Messages/operations/sendMessage
50+
action: create
51+
action-interface-3:
52+
type: api-action
53+
business-object: Messages
54+
connector-type: azureservicebus
55+
actions:
56+
acknowledgeMessage: {}
57+
options:
58+
connectorServiceOptions:
59+
httpMethod: post
60+
path: >-
61+
resources/{entityType}/{entityType_Id}/Messages/operations/acknowledgeMessage
62+
action: custom
63+
assemblies:
64+
assembly-1:
65+
assembly:
66+
execute:
67+
- parse:
68+
parse-format: json
69+
source:
70+
template: '{{$Trigger.body}}'
71+
input:
72+
- variable: Trigger
73+
$ref: '#/trigger/payload'
74+
- variable: flowDetails
75+
$ref: '#/flowDetails'
76+
sample-data: |-
77+
{
78+
"id":"abc",
79+
"container":"shipments",
80+
"message":"message to be send."
81+
}
82+
output-schema:
83+
$schema: http://json-schema.org/draft-04/schema#
84+
type: object
85+
properties:
86+
id:
87+
type: string
88+
container:
89+
type: string
90+
message:
91+
type: string
92+
title: Parsed JSON
93+
name: JSON Parser Parse
94+
- custom-action:
95+
name: Azure Cosmos DB Retrieve item by ID
96+
target:
97+
$ref: '#/integration/action-interfaces/action-interface-1'
98+
action: getanItem
99+
map:
100+
mappings:
101+
- ContainerId:
102+
template: '{{$JSONParserParse.container}}'
103+
- DatabaseId:
104+
template: DHL
105+
$map: http://ibm.com/appconnect/map/v1
106+
input:
107+
- variable: Trigger
108+
$ref: '#/trigger/payload'
109+
- variable: JSONParserParse
110+
$ref: '#/node-output/JSON Parser Parse/response/payload'
111+
- variable: flowDetails
112+
$ref: '#/flowDetails'
113+
filter:
114+
where:
115+
and:
116+
- id: '{{$JSONParserParse.id}}'
117+
- ContainerId: '{{$JSONParserParse.container}}'
118+
- DatabaseId: SampleID
119+
input:
120+
- variable: Trigger
121+
$ref: '#/trigger/payload'
122+
- variable: JSONParserParse
123+
$ref: '#/node-output/JSON Parser Parse/response/payload'
124+
- variable: flowDetails
125+
$ref: '#/flowDetails'
126+
- custom-action:
127+
name: Azure Service Bus Send message
128+
target:
129+
$ref: '#/integration/action-interfaces/action-interface-2'
130+
action: sendMessage
131+
map:
132+
mappings:
133+
- body:
134+
template: >-
135+
{"message": {{$JSONParserParse.message}},
136+
"data":{{$AzureCosmosDBRetrieveitembyID.Data}}}
137+
- entityType:
138+
template: '{{$AzureCosmosDBRetrieveitembyID.entityType}}'
139+
- entityType_Id:
140+
template: '{{$AzureCosmosDBRetrieveitembyID.entityId}}'
141+
$map: http://ibm.com/appconnect/map/v1
142+
input:
143+
- variable: Trigger
144+
$ref: '#/trigger/payload'
145+
- variable: JSONParserParse
146+
$ref: '#/node-output/JSON Parser Parse/response/payload'
147+
- variable: AzureCosmosDBRetrieveitembyID
148+
$ref: >-
149+
#/node-output/Azure Cosmos DB Retrieve item by
150+
ID/response/payload
151+
- variable: flowDetails
152+
$ref: '#/flowDetails'
153+
filter:
154+
where:
155+
and:
156+
- entityType: '{{$AzureCosmosDBRetrieveitembyID.entityType}}'
157+
- entityType_Id: '{{$AzureCosmosDBRetrieveitembyID.entityId}}'
158+
input:
159+
- variable: Trigger
160+
$ref: '#/trigger/payload'
161+
- variable: JSONParserParse
162+
$ref: '#/node-output/JSON Parser Parse/response/payload'
163+
- variable: AzureCosmosDBRetrieveitembyID
164+
$ref: >-
165+
#/node-output/Azure Cosmos DB Retrieve item by
166+
ID/response/payload
167+
- variable: flowDetails
168+
$ref: '#/flowDetails'
169+
- logging:
170+
map:
171+
$map: http://ibm.com/appconnect/map/v1
172+
input:
173+
- variable: Trigger
174+
$ref: '#/trigger/payload'
175+
- variable: JSONParserParse
176+
$ref: '#/node-output/JSON Parser Parse/response/payload'
177+
- variable: AzureCosmosDBRetrieveitembyID
178+
$ref: >-
179+
#/node-output/Azure Cosmos DB Retrieve item by
180+
ID/response/payload
181+
- variable: AzureServiceBusSendmessage
182+
$ref: >-
183+
#/node-output/Azure Service Bus Send
184+
message/response/payload
185+
- variable: flowDetails
186+
$ref: '#/flowDetails'
187+
mappings:
188+
- logLevel:
189+
template: Info
190+
- logMessage:
191+
template: '=====> locktoken???{{$Trigger.lockToken}}'
192+
name: Log
193+
- custom-action:
194+
name: Azure Service Bus Acknowledge a message
195+
target:
196+
$ref: '#/integration/action-interfaces/action-interface-3'
197+
action: acknowledgeMessage
198+
map:
199+
mappings:
200+
- acknowledgeType:
201+
template: Acknowledge and Delete
202+
- entityType:
203+
template: Queues
204+
- entityType_Id:
205+
template: routingqueue
206+
- lockToken:
207+
template: '{{$Trigger.lockToken}}'
208+
- messageIdOrSequenceNo:
209+
template: '{{$Trigger.messageId}}'
210+
$map: http://ibm.com/appconnect/map/v1
211+
input:
212+
- variable: Trigger
213+
$ref: '#/trigger/payload'
214+
- variable: JSONParserParse
215+
$ref: '#/node-output/JSON Parser Parse/response/payload'
216+
- variable: AzureCosmosDBRetrieveitembyID
217+
$ref: >-
218+
#/node-output/Azure Cosmos DB Retrieve item by
219+
ID/response/payload
220+
- variable: AzureServiceBusSendmessage
221+
$ref: >-
222+
#/node-output/Azure Service Bus Send
223+
message/response/payload
224+
- variable: flowDetails
225+
$ref: '#/flowDetails'
226+
filter:
227+
where:
228+
and:
229+
- entityType: Queues
230+
- entityType_Id: routingqueue
231+
input:
232+
- variable: Trigger
233+
$ref: '#/trigger/payload'
234+
- variable: JSONParserParse
235+
$ref: '#/node-output/JSON Parser Parse/response/payload'
236+
- variable: AzureCosmosDBRetrieveitembyID
237+
$ref: >-
238+
#/node-output/Azure Cosmos DB Retrieve item by
239+
ID/response/payload
240+
- variable: AzureServiceBusSendmessage
241+
$ref: >-
242+
#/node-output/Azure Service Bus Send
243+
message/response/payload
244+
- variable: flowDetails
245+
$ref: '#/flowDetails'
246+
name: Route messages from Azure Service Bus queue to Cosmos DB then forward to another queue and acknowledge the message
247+
models: {}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
To refer to these instructions while editing the flow, open [the GitHub page](https://github.com/ot4i/app-connect-templates/blob/main/resources/markdown/Route%20messages%20from%20the%20Azure%20Service%20Bus%20queue%20to%20Azure%20Cosmos%20DB%20based%20on%20the%20message%20content%2C%20then%20send%20them%20to%20another%20Azure%20Service%20Bus%20queue%20and%20acknowledge%20the%20message_instructions.md) (opens in a new window).
2+
3+
This template is used to recieve a message from a routing queue containing ID that can be used to query Azure Cosmos database to obtain routing details contaning which queue or topic to push the message to, and then acknowlege it.
4+
5+
## Using the template
6+
7+
1. Click **Use this template** to start using the template.
8+
1. Click on the **Azure Service Bus** node, and if you're not already connected, connect to your [Azure Service Bus Account](https://www.ibm.com/docs/en/app-connect/saas?topic=apps-azure-service-bus).
9+
1. Click on the **Azure Cosmos DB** node, and if you're not already connected, connect to your [Azure Cosmos DB account](https://www.ibm.com/docs/en/app-connect/saas?topic=apps-azure-cosmos-db).
10+
1. To start the flow, in the banner click **Deploy flow**.
11+
12+
Use this template to route messages from the Azure Service Bus queue to Azure Cosmos DB based on the message content, then send them to another Azure Service Bus queue and acknowledge the message.

resources/template-metadata.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3791,11 +3791,20 @@
37913791
{
37923792
"name": "Create a message in a new Google Pub Sub topic using data from Azure Cosmos DB when a new message is received",
37933793
"description": "Use this template to create a new message in a new Google Cloud Pub/Sub topic using the details retrieved from Azure Cosmos DB item whenever a new message is created in a topic.",
3794-
"summary": "googlepubsub to 2 applications",
3794+
"summary": "Google Cloud Pub Sub to 2 applications",
37953795
"sourceApp": "googlepubsub",
37963796
"targetApps": ["azurecosmosdb","googlepubsub"],
37973797
"tags": ["googlepubsub", "azurecosmosdb", "event-driven flow"],
37983798
"offerings": ["app connect professional"]
3799-
}
3799+
},
3800+
{
3801+
"name": "Route messages from Azure Service Bus queue to Cosmos DB then forward to another queue and acknowledge the message",
3802+
"description": "Use this template to recieve a message from a routing queue containing an ID that can be used to query Azure Cosmos database to obtain routing details of which queue or topic to push the message to, and then acknowlege it.",
3803+
"summary": "Azure Service Bus to 2 applications",
3804+
"sourceApp": "azureservicebus",
3805+
"targetApps": ["azureservicebus", "azurecosmosdb"],
3806+
"tags": ["azureservicebus", "JSON parse", "log", "azurecosmosdb"],
3807+
"offerings": ["app connect professional"]
3808+
}
38003809
]
38013810
}

0 commit comments

Comments
 (0)