2015-08-17 57 views
0

我試圖設置一個消息到達使用NServiceBus中的MSMQTransportProtocol隊列的超時。NServiceBus消息超時timeToReachQueue

我讀過這個:http://docs.particular.net/nservicebus/msmq/connection-strings並試圖實現timeToReachQueue財產(從我的理解)。

我所做的是一個TimeToReachQueue屬性添加到我的消息:

public class PlaceOrder : IMessage 
{ 
    [MessagingDescription("MsgTimeToReachQueue")] 
    public TimeSpan TimeToReachQueue { get; set; } 

    public Guid Id { get; set; } 

    public string Product { get; set; } 
} 

在發送我已經把下面的app.config郵件客戶端:

<connectionStrings> 
    <add name="NServiceBus/Transport" 
     connectionString="deadLetter=true; 
     journal=true; 
     useTransactionalQueues=true; 
     cacheSendConnection=true; 
     timeToReachQueue=01:01:01"/> 
</connectionStrings> 

我已經嘗試了不同的時間戳值 - 基本上我正在嘗試一個不可能的時間來傳遞信息 - 我有意讓它超時。

但是,無論我在連接字符串中設置了什麼值,它似乎都不適用。消息總是成功到達,並且如果我在調試中檢查timeToReachQueue屬性,則會看到所有值都爲零 - 而不是我嘗試設置的值。

我甚至試過在我EndpointConfig如下:

configuration.UseTransport<MsmqTransport>().ConnectionStringName("NServiceBus/Transport"); 

缺少什麼我在這裏?

回答

1

我想設置一個超時消息到達隊列

的事情是,即使消息在隊列到達的時間內(由於網絡問題),它很可能最終會長時間坐在這個隊列中(可能是由於處理代碼被關閉)。

我認爲TimeToBeReceived是你要找的。看到這個前一個線程:

NServiceBus setting time to be received

什麼文件都在談論時說This sets the underlying Message.TimeToReachQueue是MSMQ消息的TimeToReachQueue屬性(如鏈接描述),而不是自己的消息對象的屬性。

+0

謝謝。我會嘗試。那些文件中的新設置怎麼樣?我理解錯了嗎? – developer82

+0

更新了我的答案 –