Hy,Windows 서비스 버스 LockDuration 속성 값이
LockDuration 속성에 관한 질문이 있습니다. 나는이 기능을 가지고있다 :
// 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...");
}
}
위의 예와 같은 메시지가 나는 경우. 모든 것이 정상이면 Complete() 함수를 사용하여 메시지를 삭제합니다. 문제가 발생하면 Abondon() 함수를 호출하여 메시지가 잠금 해제됩니다. 그래서 내 퀴즈 :
peeklock recevie 모드를 사용할 때 메시지의 잠금 기간을 설정하려면 QueueDescription.LockDuration 속성과 SubscriptionDescription.LockDuration 속성이 있습니다. 5 분으로 변경할 수 있습니다. 내가 읽은 곳 어디에서나이 신실함의 가치를주의 깊게 설정해야합니다. abandom() 함수에 오류가있는 경우 메시지가 잠기지 않기 때문에 5 분으로 설정하지 않아야합니다 (코드 예제의 catch 블록 참조). 잠금 기간을 결정하는
안부
나는 어디에서 읽었는지 모르겠다. 5 분 동안 TimeSpan을 잠그지 마라. 그리고 너는 그것을 사용하는 것을 귀찮게한다. PeekLock을 사용할 때의 함축적 인 의미가 있으며 "reliable message receive loops 구현"이라는 멋진 글의 개요가 있습니다. http://msdn.microsoft.com/en-us/library/hh851750.aspx – astaykov