Ejemplo n.º 1
1
	    public SubscriptionClient(IServiceBus bus, SubscriptionRouter router, Uri subscriptionServiceUri,
		                          TimeSpan startTimeout)
		{
			_bus = bus;
			_router = router;
			_subscriptionServiceUri = subscriptionServiceUri;
			_startTimeout = startTimeout;
			_network = router.Network;

			if (_log.IsDebugEnabled)
				_log.DebugFormat("Starting SubscriptionClient using {0}", subscriptionServiceUri);

			VerifyClientAndServiceNotOnSameEndpoint(bus);

			_ready.Reset();

			var consumerInstance = new SubscriptionMessageConsumer(_router, _network);

			_unsubscribeAction = _bus.ControlBus.SubscribeInstance(consumerInstance);
		    _unsubscribeAction += _bus.ControlBus.SubscribeContextHandler<SubscriptionRefresh>(Consume);

		    _subscriptionEndpoint = _bus.GetEndpoint(subscriptionServiceUri);
		    _producer = new SubscriptionServiceMessageProducer(router, _subscriptionEndpoint);

			WaitForSubscriptionServiceResponse();
		}
        public DistributorPipeline(IServiceBus bus)
            : base(bus)
        {
            RegisterStage("Distribute")
                .WithEvent<OnGetMessage>()
                .WithEvent<OnDeserializeTransportMessage>()
                .WithEvent<OnAfterDeserializeTransportMessage>()
                .WithEvent<OnHandleDistributeMessage>()
                .WithEvent<OnAfterHandleDistributeMessage>()
                .WithEvent<OnSerializeTransportMessage>()
                .WithEvent<OnAfterSerializeTransportMessage>()
                .WithEvent<OnDispatchTransportMessage>()
                .WithEvent<OnAfterDispatchTransportMessage>()
                .WithEvent<OnAcknowledgeMessage>()
                .WithEvent<OnAfterAcknowledgeMessage>();

            RegisterObserver(new GetWorkMessageObserver());
            RegisterObserver(new DeserializeTransportMessageObserver());
            RegisterObserver(new DistributorMessageObserver());
            RegisterObserver(new SerializeTransportMessageObserver());
            RegisterObserver(new DispatchTransportMessageObserver());
            RegisterObserver(new AcknowledgeMessageObserver());

            RegisterObserver(new DistributorExceptionObserver()); // must be last
        }
 public SimpleEventStore(IStoreSettings<IDbConnection> settings, IServiceBus serviceBus, ISerialize serializer, ISnapshotStore snapshotStore)
 {
     _settings = settings;
     _serviceBus = serviceBus;
     _serializer = serializer;
     _snapshotStore = snapshotStore;
 }
Ejemplo n.º 4
0
		public ThreadPoolConsumerPool(IServiceBus bus, IObjectBuilder objectBuilder, Pipe eventAggregator, TimeSpan receiveTimeout)
		{
			_objectBuilder = objectBuilder;
			_receiveTimeout = receiveTimeout;
			_eventAggregator = eventAggregator;
			_bus = bus;
		}
        public void Initialize(IServiceBus bus)
        {
            if (ServiceBusConfiguration.ServiceBusSection == null || ServiceBusConfiguration.ServiceBusSection.ForwardingRoutes == null)
            {
                return;
            }

            var factory = new MessageRouteSpecificationFactory();

            foreach (MessageRouteElement mapElement in ServiceBusConfiguration.ServiceBusSection.ForwardingRoutes)
            {
                var map = messageRoutes.Find(mapElement.Uri);

                if (map == null)
                {
                    map = new MessageRoute(bus.Configuration.QueueManager.GetQueue(mapElement.Uri));

                    messageRoutes.Add(map);
                }

                foreach (SpecificationElement specificationElement in mapElement)
                {
                    map.AddSpecification(factory.Create(specificationElement.Name, specificationElement.Value));
                }
            }
        }
Ejemplo n.º 6
0
		public override IServiceBus GetDecoratedBus(IServiceBus bus)
		{
			if (_realBus == bus)
				return _bus;

			return base.GetDecoratedBus(bus);
		}
		public SubscriptionRouterService(IServiceBus bus, string network)
		{
			_peerUri = bus.ControlBus.Endpoint.Address.Uri;

			_network = network;

			_peerId = CombGuid.Generate();

			_observers = new List<SubscriptionObserver>();
			_listeners = new List<BusSubscriptionEventListener>();

			_unregister = () => true;

			_peerUri = bus.ControlBus.Endpoint.Address.Uri;

			var connector = new BusSubscriptionConnector(bus);

			_peerCache = ActorFactory.Create<PeerCache>(x =>
				{
					x.ConstructedBy((fiber, scheduler, inbox) =>
					                new PeerCache(fiber, scheduler, connector, _peerId, _peerUri));
					x.UseSharedScheduler();
					x.HandleOnPoolFiber();
				})
				.GetActor();
		}
Ejemplo n.º 8
0
        public bool Start(HostControl hostControl)
        {
            _bus = ServiceBusFactory.New(x =>
                {
                    x.UseRabbitMq();
                    x.ReceiveFrom("rabbitmq://localhost/demo/member-service");

                    x.Subscribe(s =>
                        {
                            s.Consumer(() => new SaveMemberAddressConsumer());
                            s.Consumer(() => new AddressValidationConsumer());

                            s.StateMachineSaga(_stateMachine, _stateMachineRepository, c =>
                                {
                                    c.Correlate(_stateMachine.AddressAdded,
                                        (state, message) => state.OriginatingCommandId == message.CommandId)
                                     .SelectCorrelationId(message => message.EventId);

                                    c.Correlate(_stateMachine.AddressApproved,
                                        (state, message) => state.MemberId == message.MemberId);
                                });
                        });
                });

            return true;
        }
		public MulticastSubscriptionClient(IServiceBus subscriptionBus, Uri uri, string networkKey)
		{
			_subscriptionBus = subscriptionBus;
			_uri = uri;

			_networkKey = networkKey;
		}
 public void Promoted(IServiceBus bus)
 {
     if (_scheduler != null && !_scheduler.IsShutdown) _scheduler.Shutdown();
     _scheduler = _schedulerFactory();
     _scheduler.JobFactory = new ServiceBusJobFactory(bus);
     _scheduler.Start();
 }
        public bool Start(HostControl hostControl)
        {
            var container = new Container(cfg => cfg.Scan(scan =>
                {
                    scan.TheCallingAssembly();
                    scan.AssembliesFromApplicationBaseDirectory();
                    scan.AddAllTypesOf(typeof (IConsumer));
                }));

            try
            {
                _Bus = ServiceBusFactory.New(sbc =>
                    {
                        sbc.UseRabbitMq();
                        sbc.ReceiveFrom(ConfigurationManager.AppSettings["RabbitMQEndPoint"]);
                        sbc.Subscribe(x => x.LoadFrom(container));
                        sbc.Validate();
                    });

                container.Inject(_Bus);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return false;
            }
            return true;
        }
Ejemplo n.º 12
0
		public void Stop()
		{
			_unsubscribe();

			_controlBus = null;
			_bus = null;
		}
Ejemplo n.º 13
0
 public TaskMonitoringSource(HealthMonitoringSettings settings, ILogger logger, IServiceBus serviceBus, ISubscriptionRepository repository)
 {
     _settings = settings;
     _logger = logger;
     _serviceBus = serviceBus;
     _repository = repository;
 }
Ejemplo n.º 14
0
        public DistributedHashTable(
            string database,
            Uri url,
            IEndpointRouter endpointRouter,
            IServiceBus bus,
            Node metadata)
        {
            Url = url;
            this.endpointRouter = endpointRouter;
            this.bus = bus;
            Metadata = metadata;

            if (Metadata != null) // sole node in the network, probably
            {
                Metadata.ExecuteSync(uri =>
                {
                    ServiceUtil.Execute<IDistributedHashTableMetaDataProvider>(uri, srv =>
                    {
                        failOver = srv.GetNodeByUri(url);
                    });
                });
            }
            try
            {
                hashTable = new PersistentHashTable(database);
                hashTable.Initialize();
            }
            catch (Exception)
            {
                hashTable.Dispose();
                throw;
            }
        }
        public void SetUp()
        {
            // Need to do something about this.  Little ridiculous
            FubuTransport.SetupForInMemoryTesting();
            TestMessageRecorder.Clear();
            MessageHistory.ClearAll();
            InMemoryQueueManager.ClearAll();

            runtime = FubuTransport.For<DelayedRegistry>().StructureMap(new Container())
                                       .Bootstrap();

            theServiceBus = runtime.Factory.Get<IServiceBus>();

            theClock = runtime.Factory.Get<ISystemTime>().As<SettableClock>();

            message1 = new OneMessage();
            message2 = new OneMessage();
            message3 = new OneMessage();
            message4 = new OneMessage();

            theServiceBus.DelaySend(message1, theClock.UtcNow().AddHours(1));
            theServiceBus.DelaySend(message2, theClock.UtcNow().AddHours(1));
            theServiceBus.DelaySend(message3, theClock.UtcNow().AddHours(2));
            theServiceBus.DelaySend(message4, theClock.UtcNow().AddHours(2));
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BusSubscriptionConnector"/> class.
        /// </summary>
        /// <param name="bus">The bus.</param>
        public BusSubscriptionConnector(IServiceBus bus)
        {
            _dataBusSubscriptionCache = new EndpointSubscriptionConnectorCache(bus);
            _controlBusSubscriptionCache = new EndpointSubscriptionConnectorCache(bus.ControlBus);

            _connectionCache = new ConcurrentCache<Guid, UnsubscribeAction>();
        }
Ejemplo n.º 17
0
        public TodoModule(IAppSettings appSettings, ITodoService todoService, IServiceBus bus)
        {
            _todoService = todoService;
            _bus = bus;

            Post["/todo"] = _ =>
            {
                var slashCommand = this.Bind<SlashCommand>();
                if (slashCommand == null ||
                    slashCommand.command.Missing())
                {
                    Log.Info("Rejected an incoming slash command (unable to parse request body).");
                    return HttpStatusCode.BadRequest.WithReason("Unable to parse slash command.");
                }
                if (!appSettings.Get("todo:slackSlashCommandToken").Equals(slashCommand.token))
                {
                    Log.Info("Blocked an unauthorized slash command.");
                    return HttpStatusCode.Unauthorized.WithReason("Missing or invalid token.");
                }
                if (!slashCommand.command.Equals("/todo", StringComparison.InvariantCultureIgnoreCase))
                {
                    Log.Info("Rejected an incoming slash command ({0} is not handled by this module).", slashCommand.command);
                    return HttpStatusCode.BadRequest.WithReason("Unsupported slash command.");
                }

                var responseText = HandleTodo(slashCommand);
                if (responseText.Missing())
                {
                    return HttpStatusCode.OK;
                }
                return responseText;
            };
        }
        public void Initialize(IServiceBus serviceBus)
        {
            Guard.AgainstNull(serviceBus, "serviceBus");

            AddAssertion("BeforeDequeueStream", Assertion);
            AddAssertion("AfterDequeueStream", Assertion);
            AddAssertion("AfterMessageDeserialization", Assertion);
            AddAssertion("BeforeEnqueueStream", Assertion);
            AddAssertion("AfterEnqueueStream", Assertion);
            AddAssertion("BeforeHandleMessage", Assertion);
            AddAssertion("AfterHandleMessage", Assertion);
            AddAssertion("BeforeRemoveMessage", Assertion);
            AddAssertion("AfterRemoveMessage", Assertion);

            serviceBus.Events.BeforeDequeueStream += (sender, e) => ThrowException("BeforeDequeueStream");
            serviceBus.Events.AfterDequeueStream += (sender, e) => ThrowException("AfterDequeueStream");
            serviceBus.Events.AfterMessageDeserialization += (sender, e) => ThrowException("AfterMessageDeserialization");
            serviceBus.Events.BeforeEnqueueStream += (sender, e) => ThrowException("BeforeEnqueueStream");
            serviceBus.Events.AfterEnqueueStream += (sender, e) => ThrowException("AfterEnqueueStream");
            serviceBus.Events.BeforeHandleMessage += (sender, e) => ThrowException("BeforeHandleMessage");
            serviceBus.Events.AfterHandleMessage += (sender, e) => ThrowException("AfterHandleMessage");
            serviceBus.Events.BeforeRemoveMessage += (sender, e) => ThrowException("BeforeRemoveMessage");
            serviceBus.Events.AfterRemoveMessage += (sender, e) => ThrowException("AfterRemoveMessage");

            serviceBus.Events.PipelineReleased += PipelineReleased;
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="serviceBus">The service bus on which commands are received</param>
        /// <param name="controlBus">The control bus for the synchronization messages between nodes</param>
        public void Start(IServiceBus serviceBus, IServiceBus controlBus)
        {
            _serviceBus = serviceBus;
            _controlBus = controlBus;

            _nodeState.ChangeTo<FollowerBehavior>();
        }
Ejemplo n.º 20
0
        public static void RegisterHandlers(IReadOnlyStore readOnlyStore, IServiceBus serviceBus)
        {
            _serviceBus = serviceBus;

            RegisterCommandHandler(new ProductListCommandHandlers());
            RegisterEventHandler(new ProductListEventHandlers(readOnlyStore));
        }
Ejemplo n.º 21
0
    public override bool OnStart()
    {
      // Set the maximum number of concurrent connections
      ServicePointManager.DefaultConnectionLimit = 12;

      // For information on handling configuration changes
      // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

      bool result = base.OnStart();

      if(result)
      {
        _bus = AzureBusInitializer.CreateBus("TestCloudSubscriber", sbc =>
        {
          sbc.SetConcurrentConsumerLimit(64);
          sbc.Subscribe(subs =>
          {
            subs.Consumer<SomethingHappenedConsumer>().Permanent();
          });
        });
      }
      
      Trace.TraceInformation("TestCloudSubscriberWorker has been started");

      return result;
    }
		public GamingSummaryViewModel(GameController controller, IGameControlService controlService, IRegistrationService registrationService, IContestDao contestDao, IEventAggregator eventAggregator)
		{
			_controller = controller;
			_controlService = controlService;
			_registrationService = registrationService;
			_contestDao = contestDao;

			this.OpenGameSelectionCommand = _controller.OpenGameSelectionCommand;
			this.StartGameCommand = DelegateCommand<SequencingItem>.FromAsyncHandler(StartGame);
			this.MakeShotCommand = DelegateCommand<string>.FromAsyncHandler(MakeShot);
			this.EditShotCommand = new DelegateCommand<string>(EditShot);
			this.NewGameCommand = DelegateCommand.FromAsyncHandler(NewGame, CanNewGame);

			eventAggregator.GetEvent<GameSelected>().Subscribe((payload) => this.CurrentGame = payload);

			_liveBus = ServiceBusFactory.New(sbc =>
			{
				sbc.UseMsmq(msmq =>
				{
					msmq.UseMulticastSubscriptionClient();
					msmq.VerifyMsmqConfiguration();
				});
				sbc.ReceiveFrom("msmq://localhost/ramp-festival_live_sender");
				sbc.SetNetwork("WORKGROUP");
			});
		}
Ejemplo n.º 23
0
		/// <summary>
		/// Call to initialize the service bus instance, including any configuration.
		/// </summary>
		/// <param name="configure">A lambda/action that does the bus configugration.</param>
		/// <exception cref="ConfigurationException">
		/// If the bus has already been initialized by a call
		/// to this method.</exception>
		public static void Initialize(Action<ServiceBusConfigurator> configure)
		{
			if (_instance != null)
				throw new ConfigurationException("Bus.Instance has already been initialized. Call Shutdown first.");

			_instance = ServiceBusFactory.New(configure);
		}
 public LoginController(IUserRepository userRepository, IServiceBus bus, ITranslationService translationService, IPasswordPolicy passwordPolicy)
 {
     _userRepository = userRepository;
     _bus = bus;
     _translationService = translationService;
     _passwordPolicy = passwordPolicy;
 }
        public void Initialize()
        {
            XmlConfigurator.Configure();

            bus = ServiceBusFactory.New(sbc =>
            {

                sbc.UseMsmq();
                sbc.VerifyMsmqConfiguration();

                sbc.UseSubscriptionService(RuntimeServicesQueueName);

                sbc.UseControlBus();
                sbc.UseJsonSerializer();

                sbc.ReceiveFrom(QueueName);

                sbc.BeforeConsumingMessage(() => { });
                sbc.AfterConsumingMessage(() => { });

                sbc.SetConcurrentConsumerLimit(1);

                sbc.UseLog4Net();

                sbc.Subscribe(subs =>
                {
                    subs.Consumer<Consumer>();
                });
            });
        }
Ejemplo n.º 26
0
        public SubscriptionRouterService(IServiceBus bus, SubscriptionRepository repository, string network)
        {
            _peerUri = bus.ControlBus.Endpoint.Address.Uri;

            _repository = repository;
            _network = network;

            _peerId = NewId.NextGuid();

            _observers = new List<SubscriptionObserver>();
            _listeners = new List<BusSubscriptionEventListener>();

            _unregister = () => true;

            _peerUri = bus.ControlBus.Endpoint.Address.Uri;

            var connector = new BusSubscriptionConnector(bus);

            _peerCache = ActorFactory.Create<PeerCache>(x =>
                {
                    x.ConstructedBy((fiber, scheduler, inbox) =>
                                    new PeerCache(connector, _peerId, _peerUri, repository));
                    x.UseSharedScheduler();
                    x.HandleOnPoolFiber();
                })
                .GetActor();

            // at this point, existing subscriptions need to be loaded...

            _repository.Load(this);
        }
 public CreateCustomerViewModel(IServiceBus bus, IEventAggregator eventAggregator)
 {
     _Bus = bus;
     _EventAggregator = eventAggregator;
     Command = new CreateNewCustomer(CombGuid.Generate(),
         "unknown", "unknown", "unknown", "unknown", "unknown", "305533333");
 }
Ejemplo n.º 28
0
        void Form1_Load(object sender, EventArgs e)
        {
            richTextBox1.Text += "Starting...\r\n";

            _context = SynchronizationContext.Current;

            bus = ServiceBusFactory.New(sbc =>
                {
                    sbc.UseRabbitMqRouting();
                    sbc.ReceiveFrom("rabbitmq://localhost/mtreqresptest_server");
                    sbc.SetConcurrentConsumerLimit(1);

                    sbc.Subscribe(sc =>
                        {
                            sc.Consumer(() =>
                                {
                                    var consumer = new BasicConsumer();
                                    consumer.Completed += ConsumerCompletedCallback;

                                    return consumer;
                                });
                        });
                });

            richTextBox1.Text += "Started.\r\n";
        }
Ejemplo n.º 29
0
        public SendMessagePipeline(IServiceBus bus)
            : base(bus)
        {
            RegisterStage("Send")
                .WithEvent<OnPrepareMessage>()
                .WithEvent<OnAfterPrepareMessage>()
                .WithEvent<OnFindRouteForMessage>()
                .WithEvent<OnAfterFindRouteForMessage>()
                .WithEvent<OnSerializeMessage>()
                .WithEvent<OnAfterSerializeMessage>()
                .WithEvent<OnEncryptMessage>()
                .WithEvent<OnAfterEncryptMessage>()
                .WithEvent<OnCompressMessage>()
                .WithEvent<OnAfterCompressMessage>()
                .WithEvent<OnSerializeTransportMessage>()
                .WithEvent<OnAfterSerializeTransportMessage>()
                .WithEvent<OnSendMessage>()
                .WithEvent<OnAfterSendMessage>();

            RegisterObserver(new PrepareMessageObserver());
            RegisterObserver(new FindMessageRouteObserver());
            RegisterObserver(new SerializeMessageObserver());
            RegisterObserver(new SerializeTransportMessageObserver());
            RegisterObserver(new CompressMessageObserver());
            RegisterObserver(new EncryptMessageObserver());
            RegisterObserver(new SendMessageObserver());
        }
 public WebSocketHandler(IServiceBus bus, WebSocket ws, IEventSerializator serializer, ILogger log)
 {
     _ws = ws;
     _queue = bus;
     _log = log;
     _serializer = serializer;
 }
Ejemplo n.º 31
0
        public ControlInboxProcessorFactory(IServiceBus bus)
        {
            Guard.AgainstNull(bus, "bus");

            _bus = bus;
        }
Ejemplo n.º 32
0
 public void Start(IServiceBus bus)
 {
     _serviceBus       = bus;
     _unsubscribeToken = _serviceBus.Subscribe(this);
 }
Ejemplo n.º 33
0
 public EmailCommunicationCommand(IServiceBus serviceBus) : base(serviceBus)
 {
 }
Ejemplo n.º 34
0
 public TimeoutTester(IServiceBus bus)
 {
     _bus = bus;
     _bus.Subscribe(this);
     _ticket = Guid.NewGuid();
 }
Ejemplo n.º 35
0
 /// <summary>
 /// Creates the peer with it's name in metadata.
 /// </summary>
 /// <param name="bus">The bus.</param>
 /// <param name="context">Context to put peer into</param>
 /// <param name="peerName">Name of the peer.</param>
 /// <returns>Created peer</returns>
 public static IPeer CreatePeer(this IServiceBus bus, string context, string peerName)
 {
     return(CreatePeer(bus, context, peerName, new Dictionary <string, string>()));
 }
Ejemplo n.º 36
0
 /// <summary>
 /// Creates the peer with default configuration.
 /// </summary>
 /// <param name="bus">The bus.</param>
 /// <param name="context">Context to put peer into</param>
 /// <returns>Created peer</returns>
 public static IPeer CreatePeer(this IServiceBus bus, string context)
 {
     return(bus.CreatePeer(new PeerConfiguration(context)));
 }
Ejemplo n.º 37
0
 /// <summary>
 /// Creates the peer with default configuration.
 /// </summary>
 /// <param name="bus">The bus.</param>
 /// <returns>Created peer</returns>
 public static IPeer CreatePeer(this IServiceBus bus)
 {
     return(bus.CreatePeer(new PeerConfiguration(string.Empty)));
 }
Ejemplo n.º 38
0
 public static IEnumerable <IPipelineSink <TMessage> > ShouldHaveSubscriptionFor <TMessage>(this IServiceBus bus)
     where TMessage : class
 {
     return(bus.OutboundPipeline.ShouldHaveSubscriptionFor <TMessage>());
 }
Ejemplo n.º 39
0
 public SpotController(IServiceBus serviceBus) : base(serviceBus)
 {
 }
Ejemplo n.º 40
0
 public static IEnumerable <IPipelineSink <TMessage> > ShouldHaveSagaSubscriptionFor <TSaga, TMessage>(this IServiceBus bus, Type policyType)
     where TMessage : class
     where TSaga : class, ISaga
 {
     return(bus.OutboundPipeline.ShouldHaveSubscriptionFor <TMessage>()
            .Where(sink => sink.GetType().Implements(typeof(SagaMessageSinkBase <TSaga, TMessage>)))
            .Where(sink => ((ISagaMessageSink <TSaga, TMessage>)sink).Policy.GetType().GetGenericTypeDefinition() == policyType));
 }
 public IBusService Create(IServiceBus bus)
 {
     return(new IntrospectionBusService());
 }
Ejemplo n.º 42
0
 public ControllerBase(IActionBus actionBus, IServiceBus serviceBus)
 {
     ActionBus  = actionBus;
     ServiceBus = serviceBus;
 }
Ejemplo n.º 43
0
 public void Stop(ITransport transport, IServiceBus serviceBus)
 {
     transport.MessageArrived             -= TransportOnMessageArrived;
     transport.MessageProcessingCompleted -= TransportOnMessageProcessingCompleted;
 }
Ejemplo n.º 44
0
 public NodeInstaller(IServiceBus bus, ISagaRepository <NodeSetupSaga> installerSagaRepo)
 {
     this.bus = bus;
     this.installerSagaRepo = installerSagaRepo ?? new InMemorySagaRepository <NodeSetupSaga>();
 }
Ejemplo n.º 45
0
 public CampaignController(IServiceBus serviceBus) : base(serviceBus)
 {
 }
Ejemplo n.º 46
0
 public PingConsumer(IServiceBus bus)
 {
     this.bus = bus;
 }
Ejemplo n.º 47
0
 public MemberApplicationService(IServiceBus bus)
 {
     _bus = bus;
 }
Ejemplo n.º 48
0
 public MessageSender(IServiceBus bus)
     : this(bus, null)
 {
 }
Ejemplo n.º 49
0
 public SessionController(IServiceBus bus, PrincipalFactory principalFactory)
 {
     this.bus = bus;
     this.principalFactory = principalFactory;
 }
Ejemplo n.º 50
0
 public CashierService(IServiceBus bus, ISagaRepository <CashierSaga> sagaRepository)
 {
     _bus            = bus;
     _sagaRepository = sagaRepository;
 }
Ejemplo n.º 51
0
 public ProducerService(ISignalRNotifier notifier, ISignalRPublisher publisher, IServiceBus serviceBus)
 {
     _notifier   = notifier;
     _publisher  = publisher;
     _serviceBus = serviceBus;
 }
Ejemplo n.º 52
0
        public void TestServiceBusWithRemoteKafka()
        {
            IServiceBus serviceBus = ServiceBus.Configure()
                                     .WithKafkaEndpoints <ITestMessage1>()
                                     .Named("Obvs.TestService")
                                     .AppendMessageProperties(message => new Dictionary <string, string> {
                { "TestProperty", "123" }
            })
                                     .FilterReceivedMessages(properties => true)
                                     .ConnectToKafka(_seed2Addresses)
                                     .SerializedAsJson()
                                     .AsClientAndServer()
                                     .PublishLocally()
                                     .OnlyMessagesWithNoEndpoints()
                                     .UsingConsoleLogging()
                                     .Create();

            ConcurrentBag <IMessage> messages = new ConcurrentBag <IMessage>();

            // create some actions that will act as a fake services acting on incoming commands and requests
            Action <TestCommand> fakeService1 = command => serviceBus.PublishAsync(new TestEvent {
                Id = command.Id
            });
            Action <TestRequest> fakeService2 = request => serviceBus.ReplyAsync(request, new TestResponse {
                Id = request.Id
            });
            AnonymousObserver <IMessage> observer = new AnonymousObserver <IMessage>(x =>
            {
                Console.WriteLine("********* " + x);
                messages.Add(x);
            }, Console.WriteLine, () => Console.WriteLine("OnCompleted"));

            // subscribe to all messages on the ServiceBus
            CompositeDisposable subscriptions = new CompositeDisposable
            {
                serviceBus.Events.Subscribe(observer),
                serviceBus.Commands.Subscribe(observer),
                serviceBus.Requests.Subscribe(observer),
                serviceBus.Commands.OfType <TestCommand>().Subscribe(fakeService1),
                serviceBus.Requests.OfType <TestRequest>().Subscribe(fakeService2)
            };

            // send some messages
            serviceBus.SendAsync(new TestCommand {
                Id = 123
            });
            serviceBus.SendAsync(new TestCommand2 {
                Id = 123
            });
            serviceBus.SendAsync(new TestCommand3 {
                Id = 123
            });
            serviceBus.GetResponses(new TestRequest {
                Id = 456
            }).Subscribe(observer);

            // wait some time until we think all messages have been sent and received over AMQ
            Thread.Sleep(TimeSpan.FromSeconds(10));

            // test we got everything we expected
            Assert.That(messages.OfType <TestCommand>().Count() == 1, "TestCommand not received");
            Assert.That(messages.OfType <TestCommand2>().Count() == 1, "TestCommand2 not received");
            Assert.That(messages.OfType <TestCommand3>().Count() == 1, "TestCommand3 not received");
            Assert.That(messages.OfType <TestEvent>().Count() == 1, "TestEvent not received");
            Assert.That(messages.OfType <TestRequest>().Count() == 1, "TestRequest not received");
            Assert.That(messages.OfType <TestResponse>().Count() == 1, "TestResponse not received");

            subscriptions.Dispose();
            ((IDisposable)serviceBus).Dispose();
            // win!
        }
Ejemplo n.º 53
0
 public void Start(IServiceBus bus)
 {
     _bus = bus;
     _unregisterAction = _bus.InboundPipeline.Configure(x => x.Register(this));
 }
Ejemplo n.º 54
0
 public NodeService(IServiceBus bus, ISagaRepository <TSaga> sagaRepository)
 {
     _bus            = bus;
     _sagaRepository = sagaRepository;
 }
Ejemplo n.º 55
0
 public Consumer(IServiceBus bus)
 {
     _bus = bus;
 }
Ejemplo n.º 56
0
 public DefaultHostedService(IServiceBus bus)
 {
     Bus = bus.ThrowIfNull(nameof(bus));
 }
 public virtual IServiceBus GetDecoratedBus(IServiceBus bus)
 {
     return(new ServiceBusTestDecorator(bus, this));
 }
Ejemplo n.º 58
0
 public void Dispose()
 {
     _bus     = null;
     _service = null;
 }
        public InboxProcessorFactory(IServiceBus bus)
        {
            Guard.AgainstNull(bus, "bus");

            this.bus = bus;
        }
Ejemplo n.º 60
0
 public ServiceBus(IServiceBus <IMessage, ICommand, IEvent, IRequest, IResponse> serviceBus)
 {
     _serviceBus = serviceBus;
 }