NServiceBus message timeout with timeToReachQueue

227 views Asked by At

I'm trying to set a timeout for a message to arrive to a queue using MSMQTransportProtocol in NServiceBus.

I've read this: http://docs.particular.net/nservicebus/msmq/connection-strings and trying to implement timeToReachQueue property (from my understanding).

What I did is to add a TimeToReachQueue property to my message:

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

    public Guid Id { get; set; }

    public string Product { get; set; }
}

In the client that sends the message I have placed the following in app.config:

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

I have tried different time stamps values - basically I'm trying to an impossible time for the message to arrive - I'm purposely want it to time out.

But whatever value I set in the the connection string it doesn't seem to apply. Message always arrives successfully, and if I check the timeToReachQueue property in debug, I see that all the values are zero - not the value I try to set.

I even tried the following in my EndpointConfig:

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

What am I missing here?

1

There are 1 answers

1
Udi Dahan On

I'm trying to set a timeout for a message to arrive to a queue

The thing is that even if the message arrives at the queue within that timeframe (due to network issues) it could very well end up sitting in that queue for a long time (potentially due to the processing code being down).

I think that TimeToBeReceived is what you're looking for. See this previous thread:

NServiceBus setting time to be received

What the documentation is talking about when it says This sets the underlying Message.TimeToReachQueue is the MSMQ message's TimeToReachQueue property (as is described in the link) rather than the property on your own message object.