Пример #1
0
        // SAMPLE: what-else-can-the-in-memory-bus-do
        public static async Task WhatElseCanItDo(RegisterUser user, ICommandBus bus)
        {
            // Execute the command *right this instance*,
            // and because we didn't ask for the UserRegistered event,
            // Jasper enqueues *that* message for execution
            await bus.Invoke(user);


            // Enqueues the command locally for execution
            // on a background thread
            await bus.Enqueue(user);


            // Enqueues the command locally for execution,
            // but specify a pre-configured worker queue
            // name if you want to give some messages a
            // higher or lower priority
            await bus.Enqueue(user, "important");


            // Enqueue the command locally, but first persist
            // the command to durable storage for "guaranteed
            // execution"
            await bus.EnqueueDurably(user);


            // Schedule the command to be executed in 5 minutes
            await bus.Schedule(user, 5.Minutes());


            // Schedule the command to be executed at 1AM tomorrow
            await bus.Schedule(user, DateTimeOffset.UtcNow.Date.AddDays(1).AddHours(1));
        }