2

So I'd like to perform the following - each N seconds get X messages from a sessions-enabled queue (peek-lock) and then send them together(in a single request) up to the next processing point. Here are options I've come up so far -

  1. "Get messages from a queue" action

Seems like it requires me to hardcode a session id beforehand(?), which is not that handy.

  1. "Batch receiver" logic app

It's still in preview

  1. Custom trigger

Seems like it will work, but requires extra coding.

Any suggestions on how to effectively achieve it via Logic Apps with stuff available today?

Kiryl
  • 1,416
  • 9
  • 21

2 Answers2

1

You don't need Sessions specifically to retrieve a specific number of messages in a batch....just read 10 message then do whatever processing you need.

If you need to also retrieve the messages in order, then yes, use a Session enabled Queue where all callers use the same SessionId.

Keep in mind, the SessinId is an arbitrary Application value so you can use the same value as the Queue name if you want. I don't see this as any kind of hurdle and it's just how it works.

You can use a Recurrence Trigger at whatever interval you need.

Sessions are primarily for grouping messages. The SessionID can be any specific arbitrary value, HighPriority/LowPriority or a value determined at runtime, such as a guid, if you're doing Correlation among specific related messages. Now that I think about it, the FIFO side affect seems more to support correlation scenarios.

Johns-305
  • 10,908
  • 12
  • 21
  • How's that? It fails at the step when Logic App tries to retrieve messages if I don't specify SessionId. As I said before, I've enabled sessions on my queue which is a vital thing for me. – Kiryl Feb 10 '19 at 18:20
  • @KirylZ The implication was to use a non-session enabled queue. What are you using Sessions for? You don't need Sessions to retrieve only n-count messages. – Johns-305 Feb 10 '19 at 19:13
  • 1
    I need seesions to gurantee ordered handling of the messages. – Kiryl Feb 11 '19 at 06:17
  • I'm kind of confused so please forgive me. I have thousands of possible values for SessionId that my messages are issued with. So as far as I get it, unless I specify a precise value that matches a particular SessionId, "Get messages from a queue" won't work. That's what I've meant by "not that handy" describing my first option. Am I wrong? – Kiryl Feb 12 '19 at 07:27
  • Ah, ok. Why do you have so many SessionId values? Maybe there's a better way to handle that. – Johns-305 Feb 12 '19 at 12:29
  • Well, from perspective of the domain logic, certain events concerning a certain domain object shall be "aligned' to be processed properly. And it's quite simple to leverage entity id as SessionId. Of course, I could've come up with a custom hash function to hash an id down to a partition id(1-16) or something to that manner, but I was hoping there is a more simple way. – Kiryl Feb 13 '19 at 10:46
  • Then it seems you're just using SessionId outside it's intended purpose. You can set the 'domain' of the message using a message property freeing up SessionId for it's primary use. Meaning set message property domain=customer, then SessionID=MyOrderQueue1. – Johns-305 Feb 13 '19 at 12:27
  • I don't have a customer or tenant. But even if I had them it still doesn't change the fact that I would have to set up as many logic apps as customers/tenants I have. – Kiryl Feb 16 '19 at 09:10
  • @KirylZ No, you misunderstand. 'customer' is only an *example*. You can use whatever value you want. You use the Message Property to convey the domain alignment, then use a static SessionID to get the FIFO effect. I think you're way over thinking this.\ – Johns-305 Feb 16 '19 at 18:50
  • I totally get it. What I'm trying to say is that your approach suggesting that I shall have a logic app per static sessionid. No? – Kiryl Feb 16 '19 at 20:29
  • @KirylZ The SessonID can be dynamic (variable), that's how we use it for Correlation scenarios. – Johns-305 Feb 16 '19 at 21:50
1

One way to address this is to set the maximum concurrency on the logic app.

Go to the settings of the service bus receiving action:

enter image description here

Then choose to enable concurrency for 10:

enter image description here

Alex Gordon
  • 57,446
  • 287
  • 670
  • 1,062
  • Yeah, I've figured that Concurrency control thing too. But I'm looking for a way to assemble received messages together to move them to the next processing point in a single request. My bad I wasn't specific about in the question :( Do you think there is a chance to coalesce messages somehow? – Kiryl Feb 16 '19 at 09:07
  • Give us more info and we'll try to help – Alex Gordon Feb 17 '19 at 12:56