private static void InitializeMessenging()
        {
            var messagingManager = new MessagingManager("localhost");
            var events = _kernel.Get<FinanceEvents>();
            var financeCustomerAdded = events.GetCustomerAddedHandler();
            var financeCustomerDeleted = events.GetCustomerDeletedHandler();
            var financeCustomerModified = events.GetCustomerModifiedHandler();

            messagingManager.Subscribe("Finance.Customer.Added", financeCustomerAdded);
            messagingManager.Subscribe("Finance.Customer.Deleted", financeCustomerDeleted);
            messagingManager.Subscribe("Finance.Customer.Modified", financeCustomerModified);
        }
Beispiel #2
0
        public Program(SharedIntegrationEvents integrationEvents)
        {
            var integrationEvents1 = integrationEvents;

            var messagingManager = new MessagingManager("localhost");

            var customerAddedHandler = integrationEvents1.GetCustomerAddedHandler();
            var customerDeletedHandler = integrationEvents1.GetCustomerDeletedHandler();
            var customerModifiedHandler = integrationEvents1.GetCustomerModifiedHandler();

            messagingManager.Subscribe("Shared.Customer.Added", customerAddedHandler);
            messagingManager.Subscribe("Shared.Customer.Deleted", customerDeletedHandler);
            messagingManager.Subscribe("Shared.Customer.Modified", customerModifiedHandler);
        }
        public void CanPostAndSubscribe()
        {
            //Arrange
            var messagingManager = new MessagingManager(_hostName);
            var queueName = "testQueue";
            var message = "Test";
            var messageReceived = "";
            var handler = new EventHandler<BasicDeliverEventArgs>((model, ea) => messageReceived = Encoding.UTF8.GetString(ea.Body));

            messagingManager.CreateQueue(queueName);
            messagingManager.Subscribe(queueName, handler);

            //Act
            messagingManager.PublishCommand(queueName, message);

            //Assert
            Poller poller = new Poller(() =>
            {
                Assert.That(messageReceived, Is.EqualTo(message));
            });
            poller.PollFor(2000);
            
        }