2011-09-15 78 views

回答

3

最新服务总线版本提供了可靠的消息队列:Queues, topics and subscriptions

+0

Thinks Richrdbower –

+0

不幸的是,这似乎正在回答OP提出的问题。 Azure服务总线与Azure队列服务不同 –

1

您只需要遵循bel流步骤,以确保消息排序:

1)启用=假会话创建队列。 2)虽然在队列中保存消息,提供会话ID等如下: -

var message = new BrokeredMessage(item); 
message.SessionId = "LB"; 
Console.WriteLine("Response from Central Scoring System : " + item); 
client.Send(message); 

3)尽管为了恢复消息创建接收器: -

queueClient.OnMessage(s => 
{ 
    var body = s.GetBody<string>(); 
    var messageId = s.MessageId; 
    Console.WriteLine("Message Body:" + body); 
    Console.WriteLine("Message Id:" + messageId); 
}); 

4)虽然具有相同的会话ID它会自动确保订单并提供订购的消息。

谢谢!

0

我不知道你想如何快速处理这些消息,但如果你需要有一个真正的FIFO,不允许Azure的队列同时得到一个以上的消息。

在函数顶部的“program.cs”中使用它。

static void Main() 
      { 
       var config = new JobHostConfiguration(); 

       if (config.IsDevelopment) 
       { 
        config.UseDevelopmentSettings(); 
       } 
       config.Queues.BatchSize = 1; //Number of messages to dequeue at the same time. 
       config.Queues.MaxPollingInterval = TimeSpan.FromMilliseconds(100); //Pooling request to the queue. 


       JobHost host = new JobHost(config); 

....your initial information... 

      // The following code ensures that the WebJob will be running continuously 
      host.RunAndBlock(); 

这会在100毫秒的等待一段时间得到一个消息。

这是一个记录器webjob工作完全写入文件traze信息。

0

docs说的Azure存储队列是:

消息在存储队列通常是先入先出,但有时他们能进能出的顺序;例如,当消息的可见性超时持续时间到期(例如,由于 客户机应用程序在处理期间崩溃)。当可见性 超时过期时,消息在队列上再次变为可见,以供另一个工作人员将其出列。此时,最近可见的消息 可能会放在队列中(要再次出队),该消息在最初排队后的消息 之后。

也许这对你来说足够好了?否则使用服务总线。