本文整理汇总了C#中SendOptions.DelayDeliveryWith方法的典型用法代码示例。如果您正苦于以下问题:C# SendOptions.DelayDeliveryWith方法的具体用法?C# SendOptions.DelayDeliveryWith怎么用?C# SendOptions.DelayDeliveryWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SendOptions
的用法示例。
在下文中一共展示了SendOptions.DelayDeliveryWith方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDeliveryDelay_Should_Return_The_Configured_Delay_TimeSpan
public void GetDeliveryDelay_Should_Return_The_Configured_Delay_TimeSpan()
{
var options = new SendOptions();
var delay = TimeSpan.FromMinutes(42);
options.DelayDeliveryWith(delay);
Assert.AreEqual(delay, options.GetDeliveryDelay());
}
示例2: DeferMessage
static void DeferMessage(IBus bus)
{
DeferredMessage message = new DeferredMessage();
SendOptions sendOptions = new SendOptions();
sendOptions.RouteToLocalEndpointInstance();
sendOptions.DelayDeliveryWith(TimeSpan.FromSeconds(10));
bus.Send(message, sendOptions);
Console.WriteLine();
Console.WriteLine("{0} - {1}", DateTime.Now.ToLongTimeString(), "Sent a message that is deferred for 10 seconds");
}
示例3: DeferTask
static Task DeferTask(TaskDefinition taskDefinition, IPipelineContext context)
{
var options = new SendOptions();
options.DelayDeliveryWith(taskDefinition.Every);
options.RouteToThisEndpoint();
return context.Send(new ScheduledTask
{
TaskId = taskDefinition.Id,
Name = taskDefinition.Name,
Every = taskDefinition.Every
}, options);
}
示例4: SendOrder
static async Task SendOrder(IEndpointInstance endpointInstance)
{
Console.WriteLine("Press '1' to send PlaceOrder - defer message handling");
Console.WriteLine("Press '2' to send PlaceDelayedOrder - defer message delivery");
Console.WriteLine("Press enter key to exit");
while (true)
{
ConsoleKeyInfo key = Console.ReadKey();
Console.WriteLine();
Guid id = Guid.NewGuid();
switch (key.Key)
{
case ConsoleKey.D1:
#region SendOrder
PlaceOrder placeOrder = new PlaceOrder
{
Product = "New shoes",
Id = id
};
await endpointInstance.Send("Samples.DelayedDelivery.Server", placeOrder);
Console.WriteLine("[Defer Message Handling] Sent a new PlaceOrder message with id: {0}", id.ToString("N"));
#endregion
continue;
case ConsoleKey.D2:
#region DeferOrder
PlaceDelayedOrder placeDelayedOrder = new PlaceDelayedOrder
{
Product = "New shoes",
Id = id
};
SendOptions options = new SendOptions();
options.SetDestination("Samples.DelayedDelivery.Server");
options.DelayDeliveryWith(TimeSpan.FromSeconds(5));
await endpointInstance.Send(placeDelayedOrder, options);
Console.WriteLine("[Defer Message Delivery] Deferred a new PlaceDelayedOrder message with id: {0}", id.ToString("N"));
#endregion
continue;
case ConsoleKey.Enter:
return;
default:
return;
}
}
}
示例5: SendDelayedMessage
public async Task SendDelayedMessage()
{
IBusSession busSession = null;
IMessageHandlerContext handlerContext = null;
#region delayed-delivery-timespan
SendOptions options = new SendOptions();
options.DelayDeliveryWith(TimeSpan.FromMinutes(30));
await handlerContext.Send(new MessageToBeSentLater(), options);
// OR
await busSession.Send(new MessageToBeSentLater(), options);
#endregion
}
示例6: SendDelayedMessage
async Task SendDelayedMessage(EndpointConfiguration endpointConfiguration, IEndpointInstance endpoint, IMessageHandlerContext handlerContext)
{
#region configure-persistence-timeout
endpointConfiguration.UsePersistence<InMemoryPersistence, StorageType.Timeouts>();
#endregion
#region delayed-delivery-timespan
SendOptions options = new SendOptions();
options.DelayDeliveryWith(TimeSpan.FromMinutes(30));
await handlerContext.Send(new MessageToBeSentLater(), options);
// OR
await endpoint.Send(new MessageToBeSentLater(), options);
#endregion
}
示例7: DelayedDelivery
async Task DelayedDelivery(IMessageHandlerContext handlerContext, object message)
{
#region 5to6delayed-delivery
SendOptions sendOptions = new SendOptions();
sendOptions.DelayDeliveryWith(TimeSpan.FromMinutes(30));
//OR
sendOptions.DoNotDeliverBefore(new DateTime(2016, 12, 25));
await handlerContext.Send(message, sendOptions);
#endregion
}
示例8: Schedule
static Task Schedule(IMessageSession session, TaskDefinition taskDefinition)
{
logger.DebugFormat("Task '{0}' (with id {1}) scheduled with timeSpan {2}", taskDefinition.Name, taskDefinition.Id, taskDefinition.Every);
var options = new SendOptions();
options.DelayDeliveryWith(taskDefinition.Every);
options.RouteToThisEndpoint();
options.Context.GetOrCreate<ScheduleBehavior.State>().TaskDefinition = taskDefinition;
var scheduledTask = new ScheduledTask
{
TaskId = taskDefinition.Id,
Name = taskDefinition.Name,
Every = taskDefinition.Every
};
return session.Send(scheduledTask, options);
}