Search code examples
azure-logic-appsazureservicebusazure-logic-app-standard

Logic app standard - service bus session problems


I have an azure logic app standard application. This has two workflows; RunBre and StubSatellite.

The desired interaction flow is illustrated in the following diagram:

enter image description here

The RunBre workflow generates a guid as a session id. It then publishes this to the service bus topic:

enter image description here

This message is being correctly consumed by the StubSatellite workflow:

enter image description here

From checking the logic app the run history and service bus explorer, I can see that a message with the same session id generated by RunBre is correctly being published to the response-queue by the StubSatellite workflow. Also, the service bus explore shows an active session on the response queue, with the correct session id.

enter image description here

My problem comes when the RunBre workflow attempts to consume the response message from the queue. I'm using the built-in action "Get messages from a queue session". I'm passing it the correct sessionId as a parameter but it's throwing the following error:

{
  "code": "ServiceProviderActionFailed",
  "message": "The service provider action failed with error code 'ServiceOperationFailed' and error message 'The Service Bus session was not found to perform operation 'getMessagesFromQueueSession' on session id '30cb936a-4e11-4126-8047-4ac6f4b876b8'.'."
}

I think the reason for the error is that the session aware action "Get messages from a queue session" can only be used in a workflow that's triggered by a session aware trigger such as "On single new message from queue session". However, this is not possible in my scenario. I need to support the following:

http client --sync request--> logic app process manager --> svc bus topic --> logic app worker --> service bus queue --> logic app process manager --sync response--> http client


Solution

  • It turns out what I was trying to do is not possible using the new session aware actions. They will only work in a workflow that's triggered by one of the new session aware triggers - details here

    As a work-around, I added a local function that uses the Azure.Messaging.ServiceBus nuget package to read from the session queue:

    var client = new ServiceBusClient(serviceBusNamespace, credential);
    
    var receiver = await client.AcceptSessionAsync(queueName, sessionId);
    ServiceBusReceivedMessage message = await receiver.ReceiveMessageAsync();