I am using cloudx frameworks publisher subscriber mechanism for processing messages through azure topic/subscription.
Some of the expired messages are moved to DeadletterQueue. When i try to read those deadletter messages using MessageReceiver, i get serialization error.
var msgReceiver = msgFactory.CreateMessageReceiver(deadletterPath);
BrokeredMessage msg = msgReceiver.Peek();
UserExitMessage deadLetterObject = msg.GetBody<UserExitMessage>();
It seems cloudfx frameworks modify ( or encode ) the messages and hence they are not able to deserialize properly.
Any help would be appreciated as i am stuck from quite some time.
P.S. - This issue occurs only with messages there are published using cloudfx, for deadletter messages that were send using TopicClient code works fine.
By default, CloudFx uses the compressing serializer when publishing messages to a topic. This is to ensure the optimal message payload size. This serialzer is implemented by the CloudStorageEntitySerializer
class. If you don't provide a custom serialzer, all messages published to the SB topic will go through the standard serialzer mentioned earlier.
To consume messages using the SB API directly, just read their body as a Stream and then pass the returned stream to the Deserialize method provided by CloudStorageEntitySerializer
. This should produce the desired outcome.