本文整理汇总了C#中Rhino.ServiceBus.Msmq.OpenedQueue类的典型用法代码示例。如果您正苦于以下问题:C# OpenedQueue类的具体用法?C# OpenedQueue怎么用?C# OpenedQueue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OpenedQueue类属于Rhino.ServiceBus.Msmq命名空间,在下文中一共展示了OpenedQueue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeforeStart
protected override void BeforeStart(OpenedQueue queue)
{
foreach (var messageAction in transportActions)
{
messageAction.Init(this, queue);
}
}
示例2: BeforeStart
protected override void BeforeStart(OpenedQueue queue)
{
try
{
queueStrategy.InitializeQueue(Endpoint, QueueType.LoadBalancer);
}
catch (Exception e)
{
throw new TransportException(
"Could not open queue for load balancer: " + Endpoint + Environment.NewLine +
"Queue path: " + MsmqUtil.GetQueuePath(Endpoint), e);
}
try
{
ReadUrisFromSubQueue(KnownWorkers, SubQueue.Workers);
}
catch (Exception e)
{
throw new InvalidOperationException("Could not read workers subqueue", e);
}
try
{
ReadUrisFromSubQueue(KnownEndpoints, SubQueue.Endpoints);
}
catch (Exception e)
{
throw new InvalidOperationException("Could not read endpoints subqueue", e);
}
RemoveAllReadyToWorkMessages();
}
示例3: AfterStart
protected override void AfterStart(OpenedQueue queue)
{
base.AfterStart(queue);
SendToQueue(primaryLoadBalancer, new QueryForAllKnownWorkersAndEndpoints());
SendToQueue(primaryLoadBalancer, new QueryReadyForWorkQueueUri());
StartTrackingHeartbeats();
}
示例4: MoveTimeoutToMainQueue
/// <summary>
/// Moves the message from the timeout queue to the main queue.
/// </summary>
/// <param name="queue">The queue.</param>
/// <param name="messageId">The message id.</param>
public void MoveTimeoutToMainQueue(OpenedQueue queue, string messageId)
{
using (var timeoutQueue = queue.OpenSubQueue(SubQueue.Timeout, QueueAccessMode.Receive))
{
var message = timeoutQueue.ReceiveById(messageId);
message.AppSpecific = 0;//reset timeout flag
queue.Send(message);
}
}
示例5: Open
public OpenedQueue Open(QueueAccessMode access, IMessageFormatter formatter)
{
var messageQueue = new MessageQueue(QueuePath, access);
if (formatter != null)
messageQueue.Formatter = formatter;
var openedQueue = new OpenedQueue(this, messageQueue, QueueUri.ToString(),Transactional)
{
Formatter = formatter
};
if (SubQueue != null)
return openedQueue.OpenSubQueue(SubQueue.Value, access);
return openedQueue;
}
示例6: TryMoveMessage
public bool TryMoveMessage(OpenedQueue queue, Message message, SubQueue subQueue, out string msgId)
{
try
{
queue.MoveToSubQueue(subQueue, message);
msgId = message.Id;
return true;
}
catch (TransportException)
{
msgId = null;
return false;
}
}
示例7: HandleLoadBalancerMessage
private void HandleLoadBalancerMessage(OpenedQueue queue, Message message)
{
foreach (var msg in DeserializeMessages(queue, message, null))
{
var work = msg as ReadyToWork;
if (work != null)
{
var copy = ReadyToWorkMessageArrived;
if(copy != null)
{
copy(work);
}
}
}
}
示例8: GetTimeoutMessages
/// <summary>
/// Gets a listing of all timeout messages.
/// </summary>
/// <returns></returns>
public IEnumerable<TimeoutInfo> GetTimeoutMessages(OpenedQueue queue)
{
using (var timeoutQueue = queue.OpenSiblngQueue(SubQueue.Timeout, QueueAccessMode.Receive))
{
var enumerator2 = timeoutQueue.GetMessageEnumerator2();
while (enumerator2.MoveNext())
{
var message = enumerator2.Current;
if (message == null)
continue;
yield return new TimeoutInfo
{
Id = message.Id,
Time = DateTime.FromBinary(BitConverter.ToInt64(message.Extension, 0))
};
}
}
}
示例9: 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);
}
}
示例10: AfterStart
protected override void AfterStart(OpenedQueue queue)
{
if (_readyForWorkListener != null)
{
_readyForWorkListener.ReadyToWorkMessageArrived += readyForWorkMessage => HandleReadyForWork(queue, readyForWorkMessage);
_readyForWorkListener.Start();
}
if (secondaryLoadBalancer != null)
{
foreach (var queueUri in KnownEndpoints.GetValues())
{
logger.InfoFormat("Notifying {0} that primary load balancer {1} is taking over from secondary",
queueUri,
Endpoint.Uri
);
SendToQueue(queueUri, new Reroute
{
NewEndPoint = Endpoint.Uri,
OriginalEndPoint = Endpoint.Uri
});
}
SendHeartBeatToSecondaryServer(null);
heartBeatTimer.Change(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1));
Reroute reroute;
if (_readyForWorkListener != null)
reroute = new Reroute
{
NewEndPoint = _readyForWorkListener.Endpoint.Uri,
OriginalEndPoint = _readyForWorkListener.Endpoint.Uri
};
else
reroute = new Reroute
{
NewEndPoint = Endpoint.Uri,
OriginalEndPoint = Endpoint.Uri
};
SendToAllWorkers(
GenerateMsmqMessageFromMessageBatch(reroute),
"Rerouting {1} back to {0}"
);
}
if (ShouldNotifyWorkersLoaderIsReadyToAcceptWorkOnStartup)
NotifyWorkersThatLoaderIsReadyToAcceptWork();
}
示例11: ProcessMessage
private void ProcessMessage(
Message message,
OpenedQueue messageQueue,
TransactionScope tx,
Func<CurrentMessageInformation, bool> messageRecieved,
Action<CurrentMessageInformation, Exception> messageCompleted)
{
Exception ex = null;
currentMessageInformation = CreateMessageInformation(messageQueue, message, null, null);
try
{
//deserialization errors do not count for module events
object[] messages = DeserializeMessages(messageQueue, message, MessageSerializationException);
try
{
foreach (object msg in messages)
{
currentMessageInformation = CreateMessageInformation(messageQueue, message, messages, msg);
if (TransportUtil.ProcessSingleMessage(currentMessageInformation, messageRecieved) == false)
Discard(currentMessageInformation.Message);
}
}
catch (Exception e)
{
ex = e;
logger.Error("Failed to process message", e);
}
}
catch (Exception e)
{
ex = e;
logger.Error("Failed to deserialize message", e);
}
finally
{
HandleMessageCompletion(message, tx, messageQueue, ex, messageCompleted);
currentMessageInformation = null;
}
}
示例12: HandlePeekedMessage
protected abstract void HandlePeekedMessage(OpenedQueue queue, Message message);
示例13: BeforeStart
protected virtual void BeforeStart(OpenedQueue queue)
{
}
示例14: HandleReadyForWork
private void HandleReadyForWork(OpenedQueue queue, ReadyToWork work)
{
logger.DebugFormat("{0} is ready to work", work.Endpoint);
var needToAddToQueue = KnownWorkers.Add(work.Endpoint);
if (needToAddToQueue)
AddWorkerToQueue(queue, work);
readyForWork.Enqueue(work.Endpoint);
}
示例15: HandleStandardMessage
private void HandleStandardMessage(OpenedQueue queue, Message message)
{
var worker = readyForWork.Dequeue();
if (worker == null) // handle message later
{
queue.Send(message);
continuousDeliveryFailures++;
if (continuousDeliveryFailures >= 100)
{
System.Threading.Thread.Sleep(1000);
continuousDeliveryFailures = 0;
}
}
else
{
continuousDeliveryFailures = 0;
var workerEndpoint = endpointRouter.GetRoutedEndpoint(worker);
using (var workerQueue = MsmqUtil.GetQueuePath(workerEndpoint).Open(QueueAccessMode.Send))
{
logger.DebugFormat("Dispatching message '{0}' to {1}", message.Id, workerEndpoint.Uri);
workerQueue.Send(message);
}
}
}