本文整理汇总了C#中SendOptions类的典型用法代码示例。如果您正苦于以下问题:C# SendOptions类的具体用法?C# SendOptions怎么用?C# SendOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SendOptions类属于命名空间,在下文中一共展示了SendOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Audit
public void Audit(SendOptions sendOptions, TransportMessage transportMessage)
{
// Revert the original body if needed (if any mutators were applied, forward the original body as received)
transportMessage.RevertToOriginalBodyIfNeeded();
// Create a new transport message which will contain the appropriate headers
var messageToForward = new TransportMessage(transportMessage.Id, transportMessage.Headers)
{
Body = transportMessage.Body,
Recoverable = transportMessage.Recoverable,
TimeToBeReceived = sendOptions.TimeToBeReceived.HasValue ? sendOptions.TimeToBeReceived.Value : transportMessage.TimeToBeReceived
};
messageToForward.Headers[Headers.ProcessingMachine] = RuntimeEnvironment.MachineName;
messageToForward.Headers[Headers.ProcessingEndpoint] = EndpointName;
if (transportMessage.ReplyToAddress != null)
{
messageToForward.Headers[Headers.OriginatingAddress] = transportMessage.ReplyToAddress.ToString();
}
// Send the newly created transport message to the queue
MessageSender.Send(messageToForward, new SendOptions(sendOptions.Destination)
{
ReplyToAddress = Configure.PublicReturnAddress
});
}
示例2: SendMessage
void SendMessage(TransportMessage message, SendOptions sendOptions, IModel channel)
{
var destination = sendOptions.Destination;
string callbackAddress;
if (sendOptions.GetType().FullName.EndsWith("ReplyOptions") &&
message.Headers.TryGetValue(CallbackHeaderKey, out callbackAddress))
{
destination = Address.Parse(callbackAddress);
}
//set our callback address
if (!string.IsNullOrEmpty(CallbackQueue))
{
message.Headers[CallbackHeaderKey] = CallbackQueue;
}
var properties = channel.CreateBasicProperties();
RabbitMqTransportMessageExtensions.FillRabbitMqProperties(message, sendOptions, properties);
RoutingTopology.Send(channel, destination, message, properties);
}
示例3: ToDeliveryOptions
public static DeliveryOptions ToDeliveryOptions(this Dictionary<string, string> options)
{
var operation = options["Operation"].ToLower();
switch (operation)
{
case "publish":
return new PublishOptions(Type.GetType(options["EventType"]))
{
ReplyToAddress = Address.Parse(options["ReplyToAddress"])
};
case "send":
case "audit":
var sendOptions = new SendOptions(options["Destination"]);
ApplySendOptionSettings(sendOptions, options);
return sendOptions;
case "reply":
var replyOptions = new ReplyOptions(Address.Parse(options["Destination"]), options["CorrelationId"])
{
ReplyToAddress = Address.Parse(options["ReplyToAddress"])
};
ApplySendOptionSettings(replyOptions, options);
return replyOptions;
default:
throw new Exception("Unknown operation: " + operation);
}
}
示例4: ToBrokeredMessage
public static BrokeredMessage ToBrokeredMessage(this TransportMessage message, SendOptions options, SettingsHolder settings, bool expectDelay, Configure config)
{
var brokeredMessage = BrokeredMessageBodyConversion.InjectBody(message.Body);
SetHeaders(message, options, settings, config, brokeredMessage);
var timeToSend = DelayIfNeeded(options, expectDelay);
if (timeToSend.HasValue)
brokeredMessage.ScheduledEnqueueTimeUtc = timeToSend.Value;
TimeSpan? timeToLive = null;
if (message.TimeToBeReceived < TimeSpan.MaxValue)
{
timeToLive = message.TimeToBeReceived;
}
else if (options.TimeToBeReceived.HasValue && options.TimeToBeReceived < TimeSpan.MaxValue)
{
timeToLive = options.TimeToBeReceived.Value;
}
if (timeToLive.HasValue)
{
if (timeToLive.Value <= TimeSpan.Zero) return null;
brokeredMessage.TimeToLive = timeToLive.Value;
}
GuardMessageSize(brokeredMessage);
return brokeredMessage;
}
示例5: Send
public void Send(TransportMessage message, SendOptions sendOptions)
{
Address destination = null;
try
{
destination = DetermineDestination(sendOptions);
var connectionInfo = connectionStringProvider.GetForDestination(sendOptions.Destination);
var queue = new TableBasedQueue(destination, connectionInfo.Schema);
if (sendOptions.EnlistInReceiveTransaction)
{
SqlTransaction currentTransaction;
if (connectionStore.TryGetTransaction(connectionInfo.ConnectionString, out currentTransaction))
{
queue.Send(message, sendOptions, currentTransaction.Connection, currentTransaction);
}
else
{
SqlConnection currentConnection;
if (connectionStore.TryGetConnection(connectionInfo.ConnectionString, out currentConnection))
{
queue.Send(message, sendOptions, currentConnection);
}
else
{
using (var connection = sqlConnectionFactory.OpenNewConnection(connectionInfo.ConnectionString))
{
queue.Send(message, sendOptions, connection);
}
}
}
}
else
{
// Suppress so that even if DTC is on, we won't escalate
using (var tx = new TransactionScope(TransactionScopeOption.Suppress))
{
using (var connection = sqlConnectionFactory.OpenNewConnection(connectionInfo.ConnectionString))
{
queue.Send(message, sendOptions, connection);
}
tx.Complete();
}
}
}
catch (SqlException ex)
{
if (ex.Number == 208)
{
ThrowQueueNotFoundException(destination, ex);
}
ThrowFailedToSendException(destination, ex);
}
catch (Exception ex)
{
ThrowFailedToSendException(destination, ex);
}
}
示例6: RequiresImmediateDispatch_Should_Return_True_When_Immediate_Dispatch_Requested
public void RequiresImmediateDispatch_Should_Return_True_When_Immediate_Dispatch_Requested()
{
var options = new SendOptions();
options.RequireImmediateDispatch();
Assert.IsTrue(options.RequiredImmediateDispatch());
}
示例7: Defer
public void Defer(TransportMessage message, SendOptions sendOptions)
{
message.Headers[TimeoutManagerHeaders.RouteExpiredTimeoutTo] = sendOptions.Destination.ToString();
DateTime deliverAt;
if (sendOptions.DelayDeliveryWith.HasValue)
{
deliverAt = DateTime.UtcNow + sendOptions.DelayDeliveryWith.Value;
}
else
{
if (sendOptions.DeliverAt.HasValue)
{
deliverAt = sendOptions.DeliverAt.Value;
}
else
{
throw new ArgumentException("A delivery time needs to be specified for Deferred messages");
}
}
message.Headers[TimeoutManagerHeaders.Expire] = DateTimeExtensions.ToWireFormattedString(deliverAt);
try
{
MessageSender.Send(message, new SendOptions(TimeoutManagerAddress));
}
catch (Exception ex)
{
Log.Error("There was a problem deferring the message. Make sure that DisableTimeoutManager was not called for your endpoint.", ex);
throw;
}
}
示例8: SendTestMessage
public async Task<ActionResult> SendTestMessage(SendTestMessage sendTestMessage)
{
try
{
var sendOptions = new SendOptions
{
ContentType = sendTestMessage.ContentType,
Importance = sendTestMessage.Importance
};
var message = new TestMessage
{
Text = sendTestMessage.MessageText
};
var bus = await _busManager.GetBus();
var sentMessage = await bus.Send(message, sendOptions);
return View("Index", new SendTestMessage
{
MessageSent = true,
SentMessageId = sentMessage.MessageId
});
}
catch (Exception ex)
{
sendTestMessage.ErrorsOccurred = true;
sendTestMessage.ErrorMessage = ex.ToString();
}
return View("Index", sendTestMessage);
}
示例9: RequestImmediateDispatch
async Task RequestImmediateDispatch(IPipelineContext context)
{
#region RequestImmediateDispatch
SendOptions options = new SendOptions();
options.RequireImmediateDispatch();
await context.Send(new MyMessage(), options);
#endregion
}
示例10: SendEnumMessage
public async Task<ActionResult> SendEnumMessage()
{
EnumMessage message = new EnumMessage();
SendOptions sendOptions = new SendOptions();
sendOptions.SetDestination("Samples.Callbacks.Receiver");
Task<Status> statusTask = MvcApplication.BusSession.Request<Status>(message, sendOptions);
return View("SendEnumMessage", await statusTask);
}
示例11: SendOptions_GetCorrelationId_Should_Return_Null_When_No_CorrelationId_Configured
public void SendOptions_GetCorrelationId_Should_Return_Null_When_No_CorrelationId_Configured()
{
var options = new SendOptions();
var correlationId = options.GetCorrelationId();
Assert.IsNull(correlationId);
}
示例12: Simple
async void Simple(IEndpointInstance endpoint, SendOptions sendOptions, ILog log)
{
#region EnumCallback
Message message = new Message();
Status response = await endpoint.Request<Status>(message, sendOptions);
log.Info("Callback received with response:" + response);
#endregion
}
示例13: GetDeliveryDate_Should_Return_The_Configured_Delivery_Date
public void GetDeliveryDate_Should_Return_The_Configured_Delivery_Date()
{
var options = new SendOptions();
DateTimeOffset deliveryDate = new DateTime(2012, 12, 12, 12, 12, 12);
options.DoNotDeliverBefore(deliveryDate);
Assert.AreEqual(deliveryDate, options.GetDeliveryDate());
}
示例14: IsRoutingToThisEndpoint_Should_Return_True_When_Routed_To_This_Endpoint
public void IsRoutingToThisEndpoint_Should_Return_True_When_Routed_To_This_Endpoint()
{
var options = new SendOptions();
options.RouteToThisEndpoint();
Assert.IsTrue(options.IsRoutingToThisEndpoint());
}
示例15: SendEnumMessage
public async Task<ActionResult> SendEnumMessage()
{
var message = new EnumMessage();
var sendOptions = new SendOptions();
sendOptions.SetDestination("Samples.Callbacks.Receiver");
Task<Status> statusTask = MvcApplication.EndpointInstance.Request<Status>(message, sendOptions);
return View("SendEnumMessage", await statusTask.ConfigureAwait(false));
}