示例#1
0
        public Task HandleReceive(RabbitContext rabbitContext, RabbitMessageHandler next)
        {
            var service = rabbitContext.ContextServiceProvider.GetRequiredService(subscriptionType);
            var @event  = rabbitContext.ReceivedMessage.ToEventMessage().MessageReader.Read <T>();

            return(((IEventHandler <T>)service).Handle(@event));
        }
        private Task EventBusListener_OnMessageReceived(object sender, RabbitContext rabbitContext)
        {
            var subscription = this.subscriptionManager.GetSubscription(rabbitContext.EventName);

            if (subscription == null)
            {
                return(Task.CompletedTask);
            }
            return(subscription.Handler(rabbitContext, rabbitContext.ReceivedMessage.ToEventMessage()));
        }
示例#3
0
 public Task Handler(RabbitContext rabbitContext, EventMessage eventMessage)
 {
     return(Task.Run(async() =>
     {
         using (rabbitContext)
         {
             await this.receiveExecutionPipe.Execute(rabbitContext, eventMessage);
         }
     }));
 }
示例#4
0
        private RabbitContext CreateContext(Event @event, IModel channel, MessageStream messageStream)
        {
            var context = new RabbitContext(
                @event.EventName,
                rabbitMessageSerializer,
                channel,
                messageStream,
                serviceProvider.CreateScope()
                );

            return(context);
        }
示例#5
0
 public Task HandlePublish(RabbitContext rabbitContext, RabbitMessageHandler next)
 {
     return(next());
 }