Send a message with a new library (Microsoft.Azure.ServiceBus) that is read by an old library (Microsoft.ServiceBus.Messaging) with BodyType - String

前端 未结 1 1537
广开言路
广开言路 2020-12-07 03:30

I have a client written for some time ago that uses the old library and does call GetBody() to read the body when receiving messages.

Now

1条回答
  •  庸人自扰
    2020-12-07 04:15

    The scenario is described here. You will need to serialize the message following this approach:

     var serializer = DataContractBinarySerializer.Instance; 
     using (MemoryStream stream = new MemoryStream()) 
     {
         serializer.WriteObject(stream, some_string);
         var msg = new Message(stream.ToArray());
         var client = new Microsoft.Azure.ServiceBus.QueueClient(ConnectionString, Queue);
         await client.SendAsync(msg);
         await client.CloseAsync(); 
     }
    

    0 讨论(0)
提交回复
热议问题