예제 #1
0
        public Task Handle(InvoiceCreated created)
        {
            var invoice = new Invoice {
                Id = created.InvoiceId
            };

            _session.Store(invoice);

            return(_session.SaveChangesAsync());
        }
예제 #2
0
        // ENDSAMPLE

        // SAMPLE: IServiceBus.Enqueue
        public Task Enqueue(IServiceBus bus)
        {
            var @event = new InvoiceCreated
            {
                Time      = DateTime.UtcNow,
                Purchaser = "Guy Fieri",
                Amount    = 112.34,
                Item      = "Cookbook"
            };

            return(bus.Enqueue(@event));
        }
예제 #3
0
        // ENDSAMPLE

        // SAMPLE: sending-message-with-send-and-await
        public async Task SendMessageAndAwait(IServiceBus bus)
        {
            var @event = new InvoiceCreated
            {
                Time      = DateTime.UtcNow,
                Purchaser = "Guy Fieri",
                Amount    = 112.34,
                Item      = "Cookbook"
            };

            await bus.SendAndWait(@event);
        }
예제 #4
0
        // SAMPLE: IServiceBus.Invoke
        public Task Invoke(IMessageContext bus)
        {
            var @event = new InvoiceCreated
            {
                Time      = DateTime.UtcNow,
                Purchaser = "Guy Fieri",
                Amount    = 112.34,
                Item      = "Cookbook"
            };

            return(bus.Invoke(@event));
        }
예제 #5
0
        // ENDSAMPLE


        // SAMPLE: sending-message-with-servicebus
        public Task SendMessage(IServiceBus bus)
        {
            // In this case, we're sending an "InvoiceCreated"
            // message
            var @event = new InvoiceCreated
            {
                Time      = DateTime.UtcNow,
                Purchaser = "Guy Fieri",
                Amount    = 112.34,
                Item      = "Cookbook"
            };

            return(bus.Send(@event));
        }
예제 #6
0
        // ENDSAMPLE

        // SAMPLE: IServiceBus.Enqueue-to-specific-worker-queue
        public Task EnqueueToQueue(IMessageContext bus)
        {
            var @event = new InvoiceCreated
            {
                Time      = DateTime.UtcNow,
                Purchaser = "Guy Fieri",
                Amount    = 112.34,
                Item      = "Cookbook"
            };

            // Put this message in a local worker
            // queue named 'highpriority'
            return(bus.Enqueue(@event, "highpriority"));
        }
예제 #7
0
        // ENDSAMPLE


        // SAMPLE: publishing-message-with-servicebus
        public Task PublishMessage(IMessageContext bus)
        {
            // In this case, we're sending an "InvoiceCreated"
            // message
            var @event = new InvoiceCreated
            {
                Time      = DateTime.UtcNow,
                Purchaser = "Guy Fieri",
                Amount    = 112.34,
                Item      = "Cookbook"
            };

            return(bus.Publish(@event));
        }
예제 #8
0
        // ENDSAMPLE


        // SAMPLE: send-message-to-specific-destination
        public async Task SendMessageToSpecificDestination(IMessageContext bus)
        {
            var @event = new InvoiceCreated
            {
                Time      = DateTime.UtcNow,
                Purchaser = "Guy Fieri",
                Amount    = 112.34,
                Item      = "Cookbook"
            };

            await bus.Send(new Uri("tcp://server1:2222"), @event);

            // or

            await bus.Send(@event, e => { e.Destination = new Uri("tcp://server1:2222"); });
        }
예제 #9
0
 public void Handle(InvoiceCreated created)
 {
     // do something here with the created variable...
 }
예제 #10
0
 public void Handle(InvoiceCreated message, Envelope envelope)
 {
     var howOldIsThisMessage =
         DateTime.UtcNow.Subtract(envelope.SentAt);
 }