Quantcast
Channel: Service Bus forum
Viewing all articles
Browse latest Browse all 1916

Windows Service Bus LockDuration Property which value

$
0
0

Hy,

I have a question regarding the LockDuration Property. I have this receive function:

// Use the MessagingFactory to create a queue client for the orderqueue.
QueueClient queueClient = factory.CreateQueueClient("orderqueue");

// Receive messages from the queue with a 10 second timeout.
while (true)
{
    // Receive a message using a 10 second timeout
    BrokeredMessage msg = queueClient.Receive(TimeSpan.FromSeconds(10));
    
    if (msg != null)
    {
        // Deserialize the message body to an order data contract.
        Order order = msg.GetBody<Order>();
        // Output the order.
        Console.WriteLine("{0} {1} {2} {3} {4} ${5}",
        order.OrderNumber,
        order.Customer.FirstName,
        order.Customer.LastName,
        order.ShipTo.City,
        order.ShipTo.Province,
        order.Total);
        // Update the database
        try
        {
            // Add the order to the database.
            OrdersData.AddOrder(order);
            // Mark the message as complete.
            msg.Complete();
        }
        catch (Exception ex)
        {
            Console.WriteLine("Exception: {0}", ex.Message);
            // Something went wrong, abandon the message.
            msg.Abandon();
        }
    }
    else
    {
        // No message has been received, we will poll for more messages.
        Console.WriteLine("Polling, polling, polling...");
    }
}

If I receive a message like in the example above. I delete the message with the Complete() function if everything is ok. If something went wrong I call the Abondon() function, so the message gets unlocked. So my queustion:

There is the QueueDescription.LockDuration Property and SubscriptionDescription.LockDuration Property to set the lock duration of a message when I use the peeklock recevie mode. You can change it to 5 minutes. Somewhere I read you should set the value of this proberty carefully. Why I shouldn't set it to the 5 minutes, because the message is unlocked anyway if there is an error with the abandom() function (see the catch block in the code example).

Best regards




Viewing all articles
Browse latest Browse all 1916

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>