コード例 #1
0
ファイル: NSBExtensions.cs プロジェクト: darrenferne/stuff
 public static void Subscribe(this IStartableBus factory, IList <MessageMetadata> messageDefinitions)
 {
     foreach (var md in messageDefinitions.Where(md => md.MessageAction == MessageAction.Event && md.HandlerType != null))
     {
         factory.Subscribe(md.MessageType);
     }
 }
コード例 #2
0
ファイル: NSBMessageBus.cs プロジェクト: darrenferne/stuff
        public NSBMessageBus(IMessageBusContainer container, IMessageBusConfiguration configuration)
        {
            NSBGlobalConfiguration.Config = configuration;

            _nsbConfiguration = new BusConfiguration();
            _nsbConfiguration.UseContainer <NSBContainer>(c => c.Configure(container, configuration));
            _nsbConfiguration.UseSerialization(typeof(NSBSerialiser));
            _nsbConfiguration.EndpointName(configuration.EndpointName);
            _nsbConfiguration.EnableInstallers();
            _nsbConfiguration.DisableFeature <AutoSubscribe>();
            _nsbConfiguration.UsePersistence <InMemoryPersistence>();
            //_nsbConfiguration.LoadMessageHandlers(configuration);
            _nsbConfiguration.CustomConfigurationSource(new NSBRouteConfiguration(configuration));
            _nsbConfiguration.RegisterComponents(c => c.ConfigureComponents(this, configuration));

            ConventionsBuilder builder = _nsbConfiguration.Conventions();

            builder.DefiningCommandsAs(t => configuration.MessageDefinitions.SingleOrDefault(md => md.MessageType == t && md.MessageAction == Core.MessageAction.Command) != null);
            builder.DefiningEventsAs(t => configuration.MessageDefinitions.SingleOrDefault(md => md.MessageType == t && md.MessageAction == Core.MessageAction.Event) != null);
            builder.DefiningMessagesAs(t => configuration.MessageDefinitions.SingleOrDefault(md => md.MessageType == t && md.MessageAction == Core.MessageAction.Message) != null);
            builder.DefiningExpressMessagesAs(t => configuration.MessageDefinitions.SingleOrDefault(md => md.MessageType == t && md.ExpressMe == true) != null);

            _factory = Bus.Create(_nsbConfiguration);
            _factory.Subscribe(configuration.MessageDefinitions);
        }
コード例 #3
0
        ///////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// marketing admin
        /// </summary>
        /// <returns></returns>
        public Result CheckTBSMarketingAdminEventsAlive()
        {
            Result result = new Result().Init(false, "Timed out");
            var    token  = new CancellationTokenSource();

            MarketingAdminAliveMessageHandler.Callback = msg =>
            {
                MarketingAdminAliveMessageHandler.Callback = null;
                result.Init(true, "Alive");
                token.Cancel();
            };

            _bus.Subscribe <TBS.MarketingAdmin.Events.Alive>();

            WaitForAlive(token.Token);

            _bus.Unsubscribe <TBS.MarketingAdmin.Events.Alive>();
            MarketingAdminAliveMessageHandler.Callback = null;

            return(result);
        }