Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 在同一事件中发送多条消息_Asp.net_Persistence_Nservicebus - Fatal编程技术网

Asp.net 在同一事件中发送多条消息

Asp.net 在同一事件中发送多条消息,asp.net,persistence,nservicebus,Asp.net,Persistence,Nservicebus,以下是我的设想: 一个向nservicebus发送消息的模式触发,这个模式可以触发x次,但我只需要发送最新消息。我可以使用多个传奇(每条消息1个)来实现这一点,但是为了清洁,我希望在1个传奇中实现这一点 这是我的车,快叫我来 busService.Send(new PendingMentorEmailCommand() { PendingMentorEmailCommandId = mentorshipData.CandidateMentorMenteeMatchID, Ment

以下是我的设想:

一个向nservicebus发送消息的模式触发,这个模式可以触发x次,但我只需要发送最新消息。我可以使用多个传奇(每条消息1个)来实现这一点,但是为了清洁,我希望在1个传奇中实现这一点

这是我的车,快叫我来

busService.Send(new PendingMentorEmailCommand()
{
    PendingMentorEmailCommandId = mentorshipData.CandidateMentorMenteeMatchID,
    MentorshipData = mentorshipData,
    JobBoardCode = Config.JobBoardCode
});
命令处理程序:

public void Handle(PendingMentorEmailCommand message)
{
    Data.PendingMentorEmailCommandId = message.PendingMentorEmailCommandId;
    Data.MentorshipData = message.MentorshipData;
    Data.JobBoardCode = message.JobBoardCode;

    RequestTimeout<PendingMentorEmailTimeout>(TimeSpan.FromSeconds(PendingMentorEmailTimeoutValue));

}
消息处理程序:

public void Handle(PendingMentorEmailMessage message)
{
    ResendPendingNotification(message);
}
在我的重发方法中,我需要根据支票发送电子邮件

// is there another (newer) message in the queue?
if (currentMentorShipData.DateMentorContacted == message.MentorshipData.DateMentorContacted) 
CurrentmentshipData
是一个数据库拉取,用于获取消息时的值

因此,我在10:22运行message one,并期望它在10:25触发,而当我在10:24发送第二条消息时,我只希望在10:27触发一条消息(更新的消息),在10:25触发任何消息,因为我的if条件应在10:25失败。我想发生的事情是,Saga数据对象被第二条消息覆盖,导致第一条和第二条消息上的两条消息都以DateMentorContacted=10:24的方式触发,所以我的问题是如何分别保存每条消息的数据

如果我能解释其他任何事情,请告诉我,我是nServiceBus的新手,我已尝试提供尽可能多的细节。

听到这句话“我只需要发送最新消息”,我认为对于给定的特定于应用程序的ID(在您的情况下可能是Candidatementormenteemachid),这是正确的

我会在你的传奇中使用这个ID作为相关ID,这样每个ID就有一个传奇实例

接下来,我会让故事本身过滤掉不必要的信息发送


这可以通过在传奇中存储一种序列号并在超时数据中传回来实现。然后,在超时处理程序中,您可以将当前saga上的序列号与超时数据中的序列号进行比较,这将告诉您在超时期间是否收到了另一条消息。只有序列号匹配,您才会发送最终导致电子邮件发送的消息。

我昨晚对此进行了一些思考,并意识到可能我正试图让NSB以不同于其工作方式的方式工作,但您是对的,我可以传递一个新的GUID,而不是传入Candidatementormnteematchid。你所指的检查已经到位,并且已经联系了DateMentorContacted,使用新的方法,而不是让检查失败&等待另一条消息,我现在将结束这个传奇,因为新消息将有另一条消息。我只是希望每个候选人都有一个传奇故事。
// is there another (newer) message in the queue?
if (currentMentorShipData.DateMentorContacted == message.MentorshipData.DateMentorContacted)