本文整理汇总了C#中Rhino.ServiceBus.Msmq.OpenedQueue.TryGetMessageFromQueue方法的典型用法代码示例。如果您正苦于以下问题:C# OpenedQueue.TryGetMessageFromQueue方法的具体用法?C# OpenedQueue.TryGetMessageFromQueue怎么用?C# OpenedQueue.TryGetMessageFromQueue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rhino.ServiceBus.Msmq.OpenedQueue
的用法示例。
在下文中一共展示了OpenedQueue.TryGetMessageFromQueue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandlePeekedMessage
protected override void HandlePeekedMessage(OpenedQueue queue, Message message)
{
try
{
using (var tx = new TransactionScope(TransactionScopeOption.Required, TransportUtil.GetTransactionTimeout()))
{
message = queue.TryGetMessageFromQueue(message.Id);
if (message == null)
return;
if ((MessageType) message.AppSpecific == MessageType.LoadBalancerMessageMarker)
{
HandleLoadBalancerMessage(queue, message);
}
tx.Complete();
}
}
catch (Exception e)
{
logger.Error("Fail to process load balanced message properly", e);
}
}
示例2: HandlePeekedMessage
protected override void HandlePeekedMessage(OpenedQueue queue, Message message)
{
try
{
using (var tx = new TransactionScope(TransactionScopeOption.Required, TransportUtil.GetTransactionTimeout()))
{
message = queue.TryGetMessageFromQueue(message.Id);
if (message == null)
return;
PersistEndpoint(queue, message);
switch ((MessageType)message.AppSpecific)
{
case MessageType.ShutDownMessageMarker:
//silently cnsume the message
break;
case MessageType.LoadBalancerMessageMarker:
HandleLoadBalancerMessage(queue, message);
break;
case MessageType.AdministrativeMessageMarker:
SendToAllWorkers(message, "Dispatching administrative message from {0} to load balancer {1}");
break;
default:
HandleStandardMessage(queue, message);
break;
}
tx.Complete();
}
}
catch (Exception e)
{
logger.Error("Fail to process load balanced message properly", e);
}
}
示例3: ReceiveMessageInTransaction
public void ReceiveMessageInTransaction(OpenedQueue queue, string messageId, Func<CurrentMessageInformation, bool> messageArrived, Action<CurrentMessageInformation, Exception> messageProcessingCompleted)
{
var transactionOptions = new TransactionOptions
{
IsolationLevel = queueIsolationLevel,
Timeout = TransportUtil.GetTransactionTimeout(),
};
using (var tx = new TransactionScope(TransactionScopeOption.Required, transactionOptions))
{
var message = queue.TryGetMessageFromQueue(messageId);
if (message == null)
return;// someone else got our message, better luck next time
ProcessMessage(message, queue, tx, messageArrived, messageProcessingCompleted);
}
}
示例4: ReceiveMessage
private void ReceiveMessage(OpenedQueue queue, string messageId, Func<CurrentMessageInformation, bool> messageArrived, Action<CurrentMessageInformation, Exception> messageProcessingCompleted)
{
var message = queue.TryGetMessageFromQueue(messageId);
if (message == null)
return;
ProcessMessage(message, queue, null, messageArrived, null, null, messageProcessingCompleted);
}