Source/EasyNetQ/BusExtensions.cs
/// <summary>
/// Schedule a message to be published at some time in the future.
/// This required the EasyNetQ.Scheduler service to be running.
/// </summary>
/// <typeparam name="T">The message type</typeparam>
/// <param name="bus">The IBus instance to publish on</param>
/// <param name="futurePublishDate">The time at which the message should be sent (UTC)</param>
/// <param name="message">The message to response with</param>
Schedule a message to be published at some time in the future.
This required the EasyNetQ.Scheduler service to be running.
Schedule a message to be published at some time in the future . This required the EasyNetQ . Scheduler service to be running .
public static void FuturePublish<T>(this IBus bus, DateTime futurePublishDate, T message) where T : class
        {
            Preconditions.CheckNotNull(message, "message");
            var advancedBus = bus.Advanced;
            var typeNameSerializer = advancedBus.Container.Resolve<ITypeNameSerializer>();
            var serializer = advancedBus.Container.Resolve<ISerializer>();
            var typeName = typeNameSerializer.Serialize(typeof(T));
            var messageBody = serializer.MessageToBytes(message);
            bus.Publish(new ScheduleMe
            {
                WakeTime = futurePublishDate,
                BindingKey = typeName,
                InnerMessage = messageBody
            });
        }
public static void FuturePublish < T > ( this IBus bus , DateTime futurePublishDate , T message ) where T : class { Preconditions . CheckNotNull ( message , " " ) ; var advancedBus = bus . Advanced ; var typeNameSerializer = advancedBus . Container . Resolve < ITypeNameSerializer > ( ) ; var serializer = advancedBus . Container . Resolve < ISerializer > ( ) ; var typeName = typeNameSerializer . Serialize ( typeof ( T ) ) ; var messageBody = serializer . MessageToBytes ( message ) ; bus . Publish ( new ScheduleMe { WakeTime = futurePublishDate , BindingKey = typeName , InnerMessage = messageBody } ) ; }
Schedule a message to be published at some time in the future.
Schedule a message to be published at some time in the future .
IBus
this
futurePublishDate
DateTime
The time at which the message should be sent (UTC)
The time at which the message should be sent ( UTC )
message
T
The message to response with
The message to response with
bus
The IBus instance to publish on
The IBus instance to publish on
typeparam
The message type
The message type