0

i was wondering if there is a way to implement metadata or even multiple metadata to a service bus queue message to be used later on in an application to sort on but still maintaining FIFO in the queue.

So in short, what i want to do is: Maintaining Fifo, that s First in First Out structure in the queue, but as the messages are coming and inserted to the queue from different Sources i want to be able to sort from which source the message came from with for example metadata.

I know this is possible with Topics where you can insert a property to the message, but also i am unsure if it is possible to implement multiple properties into the topic message.

Hope i made my self clear on what i am asking is possible.

2
  • So what is sorting then? Do you want to change the order or just read the metadata (properties)? Commented Nov 12, 2017 at 19:55
  • Yes, I want to read the metadata to be able to sort on that in my application. Commented Nov 12, 2017 at 20:01

2 Answers 2

2

I assume you use .NET API. If this case you can use Properties dictionary to write and read your custom metadata:

BrokeredMessage message = new BrokeredMessage(body);
message.Properties.Add("Source", mySource);

You are free to add multiple properties too. This is the same for both Queues and Topics/Subscriptions.

Sign up to request clarification or add additional context in comments.

1 Comment

interesting, i will definitely check this out, thank you!
1

i was wondering if there is a way to implement metadata or even multiple metadata to a service bus queue message to be used later on in an application to sort on but still maintaining FIFO in the queue.

To maintain FIFO in the queue, you'd have to use Message Sessions. Without message sessions you would not be able to maintain FIFO in the queue itself. You would be able to set a custom property and use it in your application and sort out messages once they are received out of order, but you won't receive message in FIFO order as were asking in your original question.

If you drop the requirement of having an order preserved on the queue, the the answer @Mikhail has provided will be suitable for in-process sorting based on custom property(s). Just be aware that in-process sorting will be not a trivial task.

6 Comments

Ok, so i don't know if i am completely out of scope here but if i understand your comment correctly what you are saying is: Message Sessions put the incoming messages in the right order to later be polled out in the right order on the other end? So that is if i had a logic app pulling the messages they would still come in order less so to speak because the logic app is scalable/threaded?
I've read up a bit on Message Sessions, the message will require a Session-ID. So what is the best way to implement one and and how do i handle in best practice how to increment the session ID for each message?
It's important to provide details as what service / environment you're using to get a better answer :) If you're using Logic Apps, then you have an implementation of what's known as "Sequential Convoy" pattern. For that, Logic Apps provides a template that can correlated in-order delivery with Azure Service Bus message sessions. There's a post on it you can read here.
"what's the best way to implement" - it depends. If you have all messages as a part of a single session or not. You'd be looking at configuring Session ID Next Available if you have multiple sessions or Next Available if a single session with all of your messages. Hope that helps. Cheers.
I think that got me pointed in the right direction, i will definitely look into this, Thank you for your quick answer.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.