示例#1
0
 public MessageContext(MessageMetaData meta, IEndpoint endpoint, MessagingService messagingService, MessageTypeProperties props = null)
 {
     MetaData         = meta;
     Endpoint         = endpoint;
     MessagingService = messagingService;
     Props            = props;
 }
示例#2
0
        public static IServiceRegistrar AddMessaging(this IServiceCollection services,
                                                     Profile profile,
                                                     EndpointBindings bindings,
                                                     Action <MessagingConfiguration> config,
                                                     params Assembly[] messageAndHandlerAssemblies)
        {
            MessagingService.InitializeTypes(messageAndHandlerAssemblies);
            if (bindings != null)
            {
                profile.AddBindings(bindings);
            }
            var messagingConfig = new MessagingConfiguration();

            if (config != null)
            {
                config.Invoke(messagingConfig);
            }

            services.AddSingleton(messagingConfig);
            services.AddTransient <IServiceFactory>(x => new MicrosoftDependencyInjectionServiceFactory(x));
            services.AddSingleton(profile);
            services.AddSingleton <MessagingService>();
            services.AddTransient <IMessagingClient, MessagingClient>();

            //setup user message handlers
            services.Scan(c =>
            {
                c.FromAssemblies(messageAndHandlerAssemblies)
                .AddClasses(t => t.AssignableTo(typeof(IMessageHandler <>)))
                .AsImplementedInterfaces()
                .WithTransientLifetime()
                .AddClasses(t => t.AssignableTo(typeof(ICustomMessageHandler <>)))
                .AsImplementedInterfaces()
                .WithTransientLifetime()
                .AddClasses(t => t.AssignableTo(typeof(ISaga <,>)))
                .AsImplementedInterfaces()
                .AsSelf()
                .WithTransientLifetime()
                .AddClasses(t => t.AssignableTo(typeof(ISagaPersistence <,>)))
                .AsImplementedInterfaces()
                .WithTransientLifetime()
                ;
            });

            return(new ServiceRegistrar(services));
        }
示例#3
0
 public MessagingClient(MessagingService messagingService, IOutboxSession outbox)
 {
     _messagingService = messagingService;
     _outbox           = outbox;
 }
示例#4
0
        public Task Reply(IIntegrationReply reply, MessageMetaData replyMetaData = null)
        {
            var replyToEndpoint = this.GetEndpointForReply();

            return(MessagingService.Reply(reply, replyToEndpoint, this.OutboxSession, replyMetaData, this.MetaData));
        }