【问题标题】:NServiceBus message timeout with timeToReachQueueNServiceBus 消息超时与 timeToReachQueue
【发布时间】:2015-08-17 09:09:17
【问题描述】:

我正在尝试使用 NServiceBus 中的 MSMQTransportProtocol 设置消息到达队列的超时时间。

我已阅读: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");

我在这里错过了什么?

【问题讨论】:

    标签: msmq nservicebus nservicebus5


    【解决方案1】:

    我正在尝试设置消息到达队列的超时时间

    问题是,即使消息在该时间范围内到达队列(由于网络问题),它也很可能最终在该队列中停留很长时间(可能是由于处理代码已关闭)。

    我认为 TimeToBeReceived 是您正在寻找的。请参阅上一个帖子:

    NServiceBus setting time to be received

    当文档中提到 This sets the underlying Message.TimeToReachQueue 时,它所谈论的是 MSMQ 消息的 TimeToReachQueue 属性(如链接中所述),而不是您自己的消息对象上的属性。

    【讨论】:

    • 谢谢。我会试试。文档中的新设置怎么样?我理解错了吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多