[英]Service Bus Clone from Dead Letter Queue Not Working
I am trying to take a single message from a service bus dead letter queue, clone it and send it back to the original queue.我试图从服务总线死信队列中获取一条消息,克隆它并将其发送回原始队列。 I am using the clone method, then removing dead letter reasons from the userproperties before using SendAsync to send it back.
我正在使用克隆方法,然后在使用 SendAsync 将其发回之前从用户属性中删除死信原因。
Two issues I've noticed -- as I remove properties from the new, cloned message, those properties are also being removed from the original message.我注意到的两个问题——当我从新的、克隆的消息中删除属性时,这些属性也从原始消息中删除。 Also, when I use the SendAsync method, I never see the new message anywhere.
此外,当我使用 SendAsync 方法时,我从未在任何地方看到新消息。
Any help would be appreciated.任何帮助,将不胜感激。
string fullPath = EntityNameHelper.FormatSubscriptionPath(TopicName, subscriptionName);
var deadLetterClient = new MessageReceiver(ServiceBusConnectionString, fullDeadLetterPath);
var client = new MessageSender(ServiceBusConnectionString, fullPath);
var messages = deadLetterClient.ReceiveAsync(1).Result;
if (messages.Any())
{
var message = messages.First();
var newMessage = message.Clone();
newMessage.UserProperties.Remove("DeadLetterReason");
newMessage.UserProperties.Remove("DeadLetterErrorDescription");
client.SendAsync(newMessage);
}
newMessage.UserProperties == message.UserProperties yields true. newMessage.UserProperties == message.UserProperties 产生真。 Apparently there is some type of bug with the clone method where it is not doing a deep clone.
显然, clone 方法存在某种类型的错误,它没有进行深度克隆。
My best guess at this point is I am going to have to manually create a new copy of the message object rather than rely on the clone operation.在这一点上,我最好的猜测是我将不得不手动创建消息对象的新副本,而不是依赖于克隆操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.