Hi everyone,I have few doubt about to implement azure service bus receive messages from topic subscriptions.Now I’m going to receive those JSON object which I have already sent to the azure queue before moving to the deadletter.
- Moved by DotNet WangMicrosoft contingent staff Friday, February 03, 2017 2:47 AM
Based on your description, your case more related to Azure service bus, I will help move your case to Microsoft Azure > Service Bus forum for better support.
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
There are several ways to do this.
If you are using full .net framework, you can use following constructor:
var msg = new BrokeredMessage(null, serializer);
var ser = new DataContractJsonSerializer(typeof(object));
var ser = new DataContractSerializer(typeof(object));
The later one is default one. This is why your messages are XML serialized.
However following approach can be more interesting. It is a bit more complicate but it give you a chance to manipulate format and encoding:
SENDER:string strMsg = JsonConvert.SerializeObject(anySerializableObject);
BrokeredMessage msg = new BrokeredMessage(new MemoryStream(UTF8Encoding.UTF8.GetBytes(strMsg)));
. . .
var data = msg.GetBody<Stream>();
byte buff = new byte[data.Length];
data.Read(buff, 0, (int)data.Length);
var anySerializableObject = Encoding.UTF8.GetString(buff);
By using of this approach, it does not matter, if you have a list plain object or anything else. As long it is serializable it will work.
- Edited by Damir DobricMicrosoft contingent staff Saturday, March 18, 2017 12:22 PM