We want to be able to hold a property in a Service Bus Queue Brokered Message that stores the status of the item; so in the cases where an item is reprocessed for whatever reason we have a record indicating where in the process it had got to (improving our retry logic).
So we have the below code for picking up an item from a queue:
var brokeredMessage =
_queueClient.Receive(TimeSpan.FromSeconds(DEFAULT_WAIT_TIME_IN_SECONDS));
Then we want to adjust a property so it holds a status enum like so:
brokeredMessage.Properties.Add("Status", MessageStatusEnum.MessageReceived);
Is it possible to persist a new / update property within a Brokered Message like this, does an additional method have to be called, or will any changes made to the properties be lost after it has been received?
Today we do not have the ability to update and existing brokeredmessage in a Queue. You can add properties to an existing brokered message but only when you are performing Abandon
or DeadLetter
operations on the message itself. See http://msdn.microsoft.com/en-us/library/windowsazure/jj673129.aspx
We do support scenarios where you want to store the progress of a workflow/group of messages through the MessageSession
. Here essentially you enable Sessions
for a Queue/Subscription and then rather than processing messages you call AcceptMessageSession
. The SessionID
property of a message will determine what session it belongs to. Each session has a state available that you can access thru GetState
and SetState
on MessageSession
. Also transactions are supported for all these operations for you to allow for strong consistency guarantees. Following is a sample that demonstrates the use of sessions and session state:
http://code.msdn.microsoft.com/Brokered-Messaging-Session-41c43fb4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With