本文整理汇总了C#中Rhino.ServiceBus.Msmq.OpenedQueue.Send方法的典型用法代码示例。如果您正苦于以下问题:C# OpenedQueue.Send方法的具体用法?C# OpenedQueue.Send怎么用?C# OpenedQueue.Send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rhino.ServiceBus.Msmq.OpenedQueue
的用法示例。
在下文中一共展示了OpenedQueue.Send方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
示例2: AddWorkerToQueue
private void AddWorkerToQueue(OpenedQueue queue, ReadyToWork work)
{
var persistedWorker = new Message
{
Formatter = new XmlMessageFormatter(new[] { typeof(string) }),
Body = work.Endpoint.ToString(),
Label = ("Known worker: " + work.Endpoint).EnsureLabelLength()
};
logger.InfoFormat("New worker: {0}", work.Endpoint);
queue.Send(persistedWorker.SetSubQueueToSendTo(SubQueue.Workers));
SendToQueue(secondaryLoadBalancer, new NewWorkerPersisted
{
Endpoint = work.Endpoint
});
Raise(SentNewWorkerPersisted);
}
示例3: 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);
}
}
}
示例4: PersistEndpoint
private void PersistEndpoint(OpenedQueue queue, Message message)
{
var queueUri = MsmqUtil.GetQueueUri(message.ResponseQueue);
if (queueUri == null)
return;
bool needToPersist = knownEndpoints.Add(queueUri);
if (needToPersist == false)
return;
logger.InfoFormat("Adding new endpoint: {0}", queueUri);
var persistedEndPoint = new Message
{
Formatter = new XmlMessageFormatter(new[] { typeof(string) }),
Body = queueUri.ToString(),
Label = ("Known end point: " + queueUri).EnsureLabelLength()
};
queue.Send(persistedEndPoint.SetSubQueueToSendTo(SubQueue.Endpoints));
SendToQueue(secondaryLoadBalancer, new NewEndpointPersisted
{
PersistedEndpoint = queueUri
});
Raise(SentNewEndpointPersisted);
}
示例5: HandleMessageCompletion
private void HandleMessageCompletion(
Message message,
TransactionScope tx,
OpenedQueue messageQueue,
Exception exception,
Action<CurrentMessageInformation, Exception> messageCompleted)
{
if (exception == null)
{
try
{
if (tx != null)
{
tx.Complete();
tx.Dispose();
}
try
{
if (messageCompleted != null)
messageCompleted(currentMessageInformation, exception);
}
catch (Exception e)
{
logger.Error("An error occured when raising the MessageCompleted event, the error will NOT affect the message processing", e);
}
return;
}
catch (Exception e)
{
logger.Warn("Failed to complete transaction, moving to error mode", e);
exception = e;
}
}
if (message == null)
return;
try
{
if (messageCompleted != null)
messageCompleted(currentMessageInformation, exception);
}
catch (Exception e)
{
logger.Error("An error occured when raising the MessageCompleted event, the error will NOT affect the message processing", e);
}
try
{
var copy = MessageProcessingFailure;
if (copy != null)
copy(currentMessageInformation, exception);
}
catch (Exception moduleException)
{
logger.Error("Module failed to process message failure: " + exception.Message,
moduleException);
}
if (messageQueue.IsTransactional == false)// put the item back in the queue
{
messageQueue.Send(message);
}
}
示例6: ProcessMessage
private void ProcessMessage(
Message message,
OpenedQueue messageQueue,
TransactionScope tx,
Func<CurrentMessageInformation, bool> messageRecieved,
Action<CurrentMessageInformation> beforeMessageTransactionCommit,
Action<CurrentMessageInformation> beforeMessageTransactionRollback,
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
{
Action sendMessageBackToQueue = null;
if (message != null && (messageQueue.IsTransactional == false|| consumeInTransaction==false))
sendMessageBackToQueue = () => messageQueue.Send(message);
var messageHandlingCompletion = new MessageHandlingCompletion(tx, sendMessageBackToQueue, ex, messageCompleted, beforeMessageTransactionCommit, beforeMessageTransactionRollback, logger, MessageProcessingFailure, currentMessageInformation);
messageHandlingCompletion.HandleMessageCompletion();
currentMessageInformation = null;
}
}
示例7: 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 destinationQueue = new MessageQueue(GetTimeoutQueuePath(), QueueAccessMode.Receive))
{
destinationQueue.MessageReadPropertyFilter.SetAll();
var message = destinationQueue.ReceiveById(messageId);
message.AppSpecific = 0;//reset timeout flag
queue.Send(message);
}
}
示例8: HandleStandardMessage
private void HandleStandardMessage(OpenedQueue queue, Message message)
{
var worker = readyForWork.Dequeue();
if (worker == null) // handle message later
{
queue.Send(message);
}
else
{
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);
}
}
}
示例9: SendToErrorQueue
public void SendToErrorQueue(OpenedQueue queue, Message message)
{
queue.Send(message);
}