如何通过的sequenceNumber使用MessageReceiver.Receive方法上ServiceBus [英] How to use the MessageReceiver.Receive method by sequenceNumber on ServiceBus

查看:663
本文介绍了如何通过的sequenceNumber使用MessageReceiver.Receive方法上ServiceBus的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从死信队列重新提交邮件。

I'm trying to resubmit a message from a deadletter queue.

我可以重播消息死信队列,多数民众赞成罚款。 问题是,当我想现在从死信队列中删除。

I am can replay a message on a dead letter queue, thats fine. The problem is when I want to now delete this from the deadletter queue.

下面是我想要做什么:

var subscription = "mySubscription";
var topic = "myTopic";

var connectionString = "connectionStringOnAzure";
var messagingFactory = MessagingFactory.CreateFromConnectionString(connectionString);

var messageReceiver = messagingFactory.CreateMessageReceiver(SubscriptionClient.FormatDeadLetterPath(topic, subscription), ReceiveMode.ReceiveAndDelete);


long messageSequenceNumber = 835;
var brokeredMessage = messageReceiver.Receive(messageSequenceNumber);  // this part fails

// mark message as complete to remove from the queue
brokeredMessage.Complete();

我得到以下错误信息:

I get following error message:

 Microsoft.ServiceBus.Messaging.MessageNotFoundException : Failed to lock one or more specified messages. The message does not exist..TrackingId:ae15edcc-06ac-4d2b-9059-009599cf5c4e_G5_B15,TimeStamp:8/13/2013 1:45:42 PM

不过,而不是指定一个消息序列号,我只是用ReceiveBatch如下图所示,它是好的。

However, instead of specifying a message sequence number and I just use the ReceiveBatch as shown below, it is fine.

// this works and does not throw any errors
var brokeredMessages = messageReceiver.ReceiveBatch(10);

我缺少的东西?还是有再加工deadletters的另一种方式,并删除它们?

Am I missing something? Or is there another way of reprocessing deadletters and removing them?

推荐答案

在死信队列顺序,就像任何其他的队列处理。

The deadletter queue is processed in sequence just like any other queue.

的接收(SEQNO)方法组合使用推迟(),这使该消息到一个不同的辅助队列 - 的延期队列。延期队列存在的场合下,您收到的邮件了预期的顺序(例如,在一个状态机),需要一个地方来存放,早期到达的消息。一旦你准备好这样做那些你可以推迟(公园),并记下(甚至可能在会话状态),然后将这些消息。由SharePoint工作流管理器运行时使用该功能,例如。

The Receive(seqNo) method is used in combination with Defer(), which puts the message into a different secondary Queue - the "deferral queue". The deferral queue exists for scenarios where you are getting messages out of the expected order (eg. in a state machine) and need a place to put the messages that arrived early. Those you can park with Defer() and make a note of that (probably even in session state) and then pull the messages once you're ready to do so. The Workflow Manager runtime used by SharePoint uses that feature, for instance.

这篇关于如何通过的sequenceNumber使用MessageReceiver.Receive方法上ServiceBus的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆