Logic app Servce Bus trigger with session creates duplicated runs for the same message
Hi, I'm playing with service bus sessions and logic apps and I have problem with duplicated runs for the same message when using sessions in Logic app. This is my publisher logic app:
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"contentVersion": "1.0.0.0",
"actions": {
"For_each": {
"type": "Foreach",
"foreach": "@range(0, 5)",
"actions": {
"Send_message": {
"type": "ServiceProvider",
"inputs": {
"parameters": {
"entityName": "sb-tk-sess-poc",
"message": {
"contentData": {},
"sessionId": "1"
}
},
"serviceProviderConfiguration": {
"connectionName": "serviceBus",
"operationId": "sendMessage",
"serviceProviderId": "/serviceProviders/serviceBus"
}
}
}
},
"runAfter": {}
},
"For_each-copy": {
"type": "Foreach",
"foreach": "@range(0, 5)",
"actions": {
"Send_message_1": {
"type": "ServiceProvider",
"inputs": {
"parameters": {
"entityName": "sb-tk-sess-poc",
"message": {
"contentData": {},
"sessionId": "2"
}
},
"serviceProviderConfiguration": {
"connectionName": "serviceBus",
"operationId": "sendMessage",
"serviceProviderId": "/serviceProviders/serviceBus"
}
}
}
},
"runAfter": {}
}
},
"outputs": {},
"triggers": {
"When_an_HTTP_request_is_received": {
"type": "Request",
"kind": "Http"
}
}
},
"kind": "Stateful"
}
Very simple LA with HTTP trigger that puts 5 messages with sessionId = 1 and 5 messages with sessionID = 2.
This is my topic - subscription configuration:
π User's image
nothing fancy here either, default settings with sessions enabled and lock set to 5min.
Last one is my subscriner logic app:
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"contentVersion": "1.0.0.0",
"actions": {
"Delay": {
"type": "Wait",
"inputs": {
"interval": {
"count": 20,
"unit": "Second"
}
},
"runAfter": {}
},
"Close_a_topic_session": {
"type": "ServiceProvider",
"inputs": {
"parameters": {
"topicName": "sb-tk-sess-poc",
"subscriptionName": "sb-tk-sess-poc",
"sessionId": "@triggerBody()?['sessionId']"
},
"serviceProviderConfiguration": {
"connectionName": "serviceBus",
"operationId": "closeTopicSession",
"serviceProviderId": "/serviceProviders/serviceBus"
}
},
"runAfter": {
"Complete_the_message_in_a_session": [
"SUCCEEDED"
]
}
},
"Complete_the_message_in_a_session": {
"type": "ServiceProvider",
"inputs": {
"parameters": {
"messageId": "@triggerBody()?['messageId']",
"lockToken": "@triggerBody()?['lockToken']"
},
"serviceProviderConfiguration": {
"connectionName": "serviceBus",
"operationId": "completeMessageInSession",
"serviceProviderId": "/serviceProviders/serviceBus"
}
},
"runAfter": {
"Delay": [
"SUCCEEDED"
]
}
}
},
"outputs": {},
"triggers": {
"On_new_messages_from_topic_session": {
"type": "ServiceProvider",
"kind": "Polling",
"inputs": {
"parameters": {
"topicName": "sb-tk-sess-poc",
"subscriptionName": "sb-tk-sess-poc",
"maxMessages": 1
},
"serviceProviderConfiguration": {
"connectionName": "serviceBus",
"operationId": "onNewMessagesFromTopicSession",
"serviceProviderId": "/serviceProviders/serviceBus"
}
},
"recurrence": {
"interval": 10,
"frequency": "Second"
},
"splitOn": "@triggerOutputs()?['body']"
}
}
},
"kind": "stateful"
}
Trigger is configured to run every 10s, delay is set to 20s. Now lets look at the runs history:
only two session was created so I expected to see 2 runs trigger as similar time, but sometimes 3 runs are created (take a close look at trigger time), when I checked the trigger output details it turns out 2 runs were created for the same message. Later one instance failes because it tries to complete the message that was already completed.
I tired both session triggers: "onNewMessagesFromTopicSession" and "onSingleNewMessageFromTopicSession" and both have above issue. How can I solve it?
1 answer
-
Praveen Kumar Gudipudi 2,290 Reputation points β’ Microsoft External Staff β’ Moderator
Hello Tomasz Kaniewski ,
Could you please configure Concurrency control setting to 1 to both HTTP trigger and service bus trigger avoid duplicate runs (it won't allow logic app parallel runs)
Please accept as answer and do a Thumbs-up to upvote this response if you are satisfied with the community help. Your upvote will be beneficial for the community users facing similar issues.
-
Praveen Kumar Gudipudi 2,290 Reputation points β’ Microsoft External Staff β’ Moderator
Hello Tomasz Kaniewski ,
We havenβt heard from you on the last response and was just checking back to see if you have a resolution yet. In case if you have any resolution please do share that same with the community as it can be helpful to others. Otherwise, will respond with more details and we will try to help.
Sign in to comment -
