2011-09-15 77 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存儲隊列是:

消息在存儲隊列通常是先入先出,但有時他們能進能出的順序;例如,當消息的可見性超時持續時間到期(例如,由於 客戶機應用程序在處理期間崩潰)。當可見性 超時過期時,消息在隊列上再次變爲可見,以供另一個工作人員將其出列。此時,最近可見的消息 可能會放在隊列中(要再次出隊),該消息在最初排隊後的消息 之後。

也許這對你來說足夠好了?否則使用服務總線。