{"action":"created","issue":{"url":"https://api.github.com/repos/elliotritchie/NES/issues/40","repository_url":"https://api.github.com/repos/elliotritchie/NES","labels_url":"https://api.github.com/repos/elliotritchie/NES/issues/40/labels{/name}","comments_url":"https://api.github.com/repos/elliotritchie/NES/issues/40/comments","events_url":"https://api.github.com/repos/elliotritchie/NES/issues/40/events","html_url":"https://github.com/elliotritchie/NES/issues/40","id":136672885,"number":40,"title":"Command doesn't send to CommandHandler","user":{"login":"mojamcpds","id":3146262,"avatar_url":"https://avatars.githubusercontent.com/u/3146262?v=3","gravatar_id":"","url":"https://api.github.com/users/mojamcpds","html_url":"https://github.com/mojamcpds","followers_url":"https://api.github.com/users/mojamcpds/followers","following_url":"https://api.github.com/users/mojamcpds/following{/other_user}","gists_url":"https://api.github.com/users/mojamcpds/gists{/gist_id}","starred_url":"https://api.github.com/users/mojamcpds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mojamcpds/subscriptions","organizations_url":"https://api.github.com/users/mojamcpds/orgs","repos_url":"https://api.github.com/users/mojamcpds/repos","events_url":"https://api.github.com/users/mojamcpds/events{/privacy}","received_events_url":"https://api.github.com/users/mojamcpds/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":25,"created_at":"2016-02-26T11:36:36Z","updated_at":"2016-02-28T02:32:55Z","closed_at":null,"body":"Dear @marinkobabic:/ @elliotritchie \r\n\r\nMy Command Class is as follows:\r\n```\r\npublic class RegisterToConference : ICommand, IValidatableObject\r\n    {\r\n        public RegisterToConference()\r\n        {\r\n            this.Id = Guid.NewGuid();\r\n            this.Seats = new Collection<SeatQuantity>();\r\n        }\r\n\r\n        public Guid Id { get; set; }\r\n\r\n        public Guid OrderId { get; set; }\r\n\r\n        public Guid ConferenceId { get; set; }\r\n\r\n        public ICollection<SeatQuantity> Seats { get; set; }\r\n\r\n        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)\r\n        {\r\n            if (this.Seats == null || !this.Seats.Any(x => x.Quantity > 0))\r\n            {\r\n                 return new[] { new ValidationResult(\"One or more items are required.\", new[] { \"Seats\" }) };\r\n            }\r\n            else if (this.Seats.Any(x => x.Quantity < 0))\r\n            {\r\n                return new[] { new ValidationResult(\"Invalid registration.\", new[] { \"Seats\" }) };\r\n            }\r\n\r\n            return Enumerable.Empty<ValidationResult>();\r\n        }\r\n    }\r\n```\r\nI send above command from my controllers action method as follows:\r\n```\r\n [HttpPost]\r\n        public ActionResult StartRegistration(RegisterToConference command, int orderVersion)\r\n        {\r\n            var existingOrder = orderVersion != 0 ? this.orderDao.FindDraftOrder(command.OrderId) : null;\r\n            var viewModel = this.CreateViewModel();\r\n            if (existingOrder != null)\r\n            {\r\n                UpdateViewModel(viewModel, existingOrder);\r\n            }\r\n\r\n            viewModel.OrderId = command.OrderId;\r\n\r\n            if (!ModelState.IsValid)\r\n            {\r\n                return View(viewModel);\r\n            }\r\n\r\n            // checks that there are still enough available seats, and the seat type IDs submitted are valid.\r\n            ModelState.Clear();\r\n            bool needsExtraValidation = false;\r\n            foreach (var seat in command.Seats)\r\n            {\r\n                var modelItem = viewModel.Items.FirstOrDefault(x => x.SeatType.Id == seat.SeatType);\r\n                if (modelItem != null)\r\n                {\r\n                    if (seat.Quantity > modelItem.MaxSelectionQuantity)\r\n                    {\r\n                        modelItem.PartiallyFulfilled = needsExtraValidation = true;\r\n                        modelItem.OrderItem.ReservedSeats = modelItem.MaxSelectionQuantity;\r\n                    }\r\n                }\r\n                else\r\n                {\r\n                    // seat type no longer exists for conference.\r\n                    needsExtraValidation = true;\r\n                }\r\n            }\r\n\r\n            if (needsExtraValidation)\r\n            {\r\n                return View(viewModel);\r\n            }\r\n\r\n            command.ConferenceId = this.ConferenceAlias.Id;\r\n            this.commandBus.Send(command);\r\n            //var address = new Address(@\"RegistrationEndPoint\", \"localhost\");\r\n            //this.commandBus.Send(address, command);\r\n\r\n            return RedirectToAction(\r\n                \"SpecifyRegistrantAndPaymentDetails\",\r\n                new { conferenceCode = this.ConferenceCode, orderId = command.OrderId, orderVersion = orderVersion });\r\n        }\r\n```\r\n\r\nLogically when I click on register button it had to send the command to registered command handler and executes further actions.  But it doesn't. For kind consideration I am giving my all related codes with this action.\r\n\r\nNote: Messages are saves in Queue properly.\r\n\r\nFollowing is my command handler class:\r\n\r\n```\r\npublic class OrderCommandHandler :\r\n        IHandleMessages<RegisterToConference>\r\n    {\r\n        private readonly IRepository repository;\r\n        private readonly IPricingService pricingService;\r\n\r\n        public OrderCommandHandler(IRepository repository, IPricingService pricingService)\r\n        {\r\n            this.repository = repository;\r\n            this.pricingService = pricingService;\r\n        }\r\n\r\n        public void Handle(RegisterToConference command)\r\n        {\r\n            var items = command.Seats.Select(t => new OrderItem(t.SeatType, t.Quantity)).ToList();\r\n            var order = repository.Get<Registration.Order>(command.OrderId);\r\n            if (order == null)\r\n            {\r\n                order = new Registration.Order(command.OrderId, command.ConferenceId, items, pricingService);\r\n            }\r\n            else\r\n            {\r\n                order.UpdateSeats(items, pricingService);\r\n            }\r\n\r\n            repository.Add<Registration.Order>(order);\r\n        }\r\n        \r\n    }\r\n```\r\n\r\nThe aggregate is as follows:\r\n```\r\npublic class Order : AggregateBase<Guid>\r\n    {\r\n\r\n        private static readonly TimeSpan ReservationAutoExpiration = TimeSpan.FromMinutes(15);\r\n\r\n        private List<SeatQuantity> seats;\r\n        private bool isConfirmed;\r\n        private Guid conferenceId;\r\n\r\n        \r\n        static Order()\r\n        {\r\n            Mapper.CreateMap<OrderPaymentConfirmed, OrderConfirmed>();\r\n        }\r\n\r\n        protected Order(Guid id)\r\n        {\r\n            this.Id = id;\r\n            \r\n        }\r\n        private void Handle(OrderTotalsCalculated @event)\r\n        {\r\n            this.Id = @event.SourceId;\r\n            this.OnOrderTotalsCalculated(@event);\r\n        }\r\n        private void Handle(OrderRegistrantAssigned @event)\r\n        {\r\n            this.Id = @event.SourceId;\r\n            this.OnOrderRegistrantAssigned(@event);\r\n        }\r\n\r\n        private void Handle(OrderConfirmed @event)\r\n        {\r\n            this.Id = @event.SourceId;\r\n            this.OnOrderConfirmed(@event);\r\n        }\r\n\r\n        private void Handle(OrderPaymentConfirmed @event)\r\n        {\r\n            this.Id = @event.SourceId;\r\n            this.OnOrderConfirmed(Mapper.Map<OrderConfirmed>(@event));\r\n        }\r\n\r\n        private void Handle(OrderExpired @event)\r\n        {\r\n            this.Id = @event.SourceId;\r\n            this.OnOrderExpired(@event);\r\n        }\r\n\r\n        private void Handle(OrderReservationCompleted @event)\r\n        {\r\n            this.Id = @event.SourceId;\r\n            this.OnOrderReservationCompleted(@event);\r\n        }\r\n\r\n        private void Handle(OrderPlaced @event)\r\n        {\r\n            this.Id = @event.SourceId;\r\n            this.OnOrderPlaced(@event);\r\n        }\r\n\r\n        private void Handle(OrderUpdated @event)\r\n        {\r\n            this.Id = @event.SourceId;\r\n            this.OnOrderUpdated(@event);\r\n        }\r\n\r\n        private void Handle(OrderPartiallyReserved @event)\r\n        {\r\n            this.Id = @event.SourceId;\r\n            this.OnOrderPartiallyReserved(@event);\r\n        }\r\n\r\n        \r\n        public Order(Guid id, Guid conferenceId, IEnumerable<OrderItem> items, IPricingService pricingService)\r\n            : this(id)\r\n        {\r\n            var all = ConvertItems(items);\r\n            var totals = pricingService.CalculateTotal(conferenceId, all.AsReadOnly());\r\n\r\n            this.Apply<OrderPlaced>(e =>\r\n            {\r\n                e.ConferenceId = conferenceId;\r\n                e.Seats = all;\r\n                e.ReservationAutoExpiration = DateTime.UtcNow.Add(ReservationAutoExpiration);\r\n                e.AccessCode = HandleGenerator.Generate(6);\r\n            });\r\n\r\n            this.Apply<OrderTotalsCalculated>(e =>\r\n            {\r\n                e.Total = totals.Total;\r\n                e.Lines = totals.Lines != null ? totals.Lines.ToArray() : null;\r\n                e.IsFreeOfCharge = totals.Total == 0m;\r\n            });\r\n\r\n        }\r\n\r\n      \r\n        public void UpdateSeats(IEnumerable<OrderItem> items, IPricingService pricingService)\r\n        {\r\n            var all = ConvertItems(items);\r\n            var totals = pricingService.CalculateTotal(this.conferenceId, all.AsReadOnly());\r\n\r\n            this.Apply<OrderUpdated>(e =>\r\n            {\r\n                e.Seats = all;\r\n            });\r\n\r\n            this.Apply<OrderTotalsCalculated>(e =>\r\n            {\r\n                e.Total = totals.Total;\r\n                e.Lines = totals.Lines != null ? totals.Lines.ToArray() : null;\r\n                e.IsFreeOfCharge = totals.Total == 0m;\r\n            });\r\n        }\r\n\r\n        public void MarkAsReserved(IPricingService pricingService, DateTime expirationDate, IEnumerable<SeatQuantity> reservedSeats)\r\n        {\r\n            if (this.isConfirmed)\r\n                throw new InvalidOperationException(\"Cannot modify a confirmed order.\");\r\n\r\n            var reserved = reservedSeats.ToList();\r\n\r\n            // Is there an order item which didn't get an exact reservation?\r\n            if (this.seats.Any(item => item.Quantity != 0 && !reserved.Any(seat => seat.SeatType == item.SeatType && seat.Quantity == item.Quantity)))\r\n            {\r\n                var totals = pricingService.CalculateTotal(this.conferenceId, reserved.AsReadOnly());\r\n\r\n                this.Apply<OrderPartiallyReserved>(e =>\r\n                {\r\n                    e.ReservationExpiration = expirationDate;\r\n                    e.Seats = reserved.ToArray();\r\n                });\r\n\r\n                this.Apply<OrderTotalsCalculated>(e =>\r\n                {\r\n                    e.Total = totals.Total;\r\n                    e.Lines = totals.Lines != null ? totals.Lines.ToArray() : null;\r\n                    e.IsFreeOfCharge = totals.Total == 0m;\r\n                });\r\n            }\r\n            else\r\n            {\r\n                this.Apply<OrderReservationCompleted>(e =>\r\n                {\r\n                    e.ReservationExpiration = expirationDate;\r\n                    e.Seats = reserved.ToArray();\r\n                });\r\n            }\r\n        }\r\n\r\n        public void Expire()\r\n        {\r\n            if (this.isConfirmed)\r\n                throw new InvalidOperationException(\"Cannot expire a confirmed order.\");\r\n\r\n            this.Apply<OrderExpired>(e =>\r\n            {\r\n                e.SourceId = this.Id;\r\n            });\r\n\r\n        }\r\n\r\n        public void Confirm()\r\n        {\r\n            \r\n            this.Apply<OrderConfirmed>(e =>\r\n            {\r\n                e.SourceId = this.Id;\r\n            });\r\n        }\r\n\r\n        public void AssignRegistrant(string firstName, string lastName, string email)\r\n        {\r\n\r\n            this.Apply<OrderRegistrantAssigned>(e =>\r\n            {\r\n                e.FirstName = firstName;\r\n                e.LastName = lastName;\r\n                e.Email = email;\r\n            });\r\n\r\n        }\r\n\r\n        public SeatAssignments CreateSeatAssignments()\r\n        {\r\n            if (!this.isConfirmed)\r\n                throw new InvalidOperationException(\"Cannot create seat assignments for an order that isn't confirmed yet.\");\r\n\r\n            return new SeatAssignments(this.Id, this.seats.AsReadOnly());\r\n        }\r\n\r\n        private static List<SeatQuantity> ConvertItems(IEnumerable<OrderItem> items)\r\n        {\r\n            return items.Select(x => new SeatQuantity(x.SeatType, x.Quantity)).ToList();\r\n        }\r\n\r\n        private void OnOrderPlaced(OrderPlaced e)\r\n        {\r\n            this.conferenceId = e.ConferenceId;\r\n            this.seats = e.Seats.ToList();\r\n        }\r\n\r\n        private void OnOrderUpdated(OrderUpdated e)\r\n        {\r\n            this.seats = e.Seats.ToList();\r\n        }\r\n\r\n        private void OnOrderPartiallyReserved(OrderPartiallyReserved e)\r\n        {\r\n            this.seats = e.Seats.ToList();\r\n        }\r\n\r\n        private void OnOrderReservationCompleted(OrderReservationCompleted e)\r\n        {\r\n            this.seats = e.Seats.ToList();\r\n        }\r\n\r\n        private void OnOrderExpired(OrderExpired e)\r\n        {\r\n        }\r\n\r\n        private void OnOrderConfirmed(OrderConfirmed e)\r\n        {\r\n            this.isConfirmed = true;\r\n        }\r\n\r\n        private void OnOrderRegistrantAssigned(OrderRegistrantAssigned e)\r\n        {\r\n        }\r\n\r\n        private void OnOrderTotalsCalculated(OrderTotalsCalculated e)\r\n        {\r\n        }\r\n    }\r\n```\r\nEvents are as follows:\r\n\r\n```\r\npublic interface IVersionedEvent : IEvent\r\n    {\r\n        /// <summary>\r\n        /// Gets the version or order of the event in the stream.\r\n        /// </summary>\r\n        Guid SourceId { get; set; }\r\n        int Version { get; set; }\r\n    }\r\n\r\npublic interface OrderPlaced : IVersionedEvent\r\n    {\r\n        Guid ConferenceId { get; set; }\r\n\r\n        IEnumerable<SeatQuantity> Seats { get; set; }\r\n\r\n        /// <summary>\r\n        /// The expected expiration time if the reservation is not explicitly confirmed later.\r\n        /// </summary>\r\n        DateTime ReservationAutoExpiration { get; set; }\r\n\r\n        string AccessCode { get; set; }\r\n    }\r\n\r\n\r\npublic interface OrderTotalsCalculated : IVersionedEvent\r\n    {\r\n        decimal Total { get; set; }\r\n\r\n        OrderLine[] Lines { get; set; }\r\n\r\n        bool IsFreeOfCharge { get; set; }\r\n    }\r\n```\r\n\r\nEvents are handled as follows:\r\n\r\n```\r\npublic class PricedOrderViewModelGenerator :\r\n        IHandleMessages<OrderPlaced>,\r\n        IHandleMessages<OrderTotalsCalculated>\r\n    {\r\n        private readonly Func<ConferenceRegistrationDbContext> contextFactory;\r\n        private readonly ObjectCache seatDescriptionsCache;\r\n\r\n        public PricedOrderViewModelGenerator(Func<ConferenceRegistrationDbContext> contextFactory)\r\n        {\r\n            this.contextFactory = contextFactory;\r\n            this.seatDescriptionsCache = MemoryCache.Default;\r\n        }\r\n\r\n        public void Handle(OrderPlaced @event)\r\n        {\r\n            using (var context = this.contextFactory.Invoke())\r\n            {\r\n                var dto = new PricedOrder\r\n                {\r\n                    OrderId = @event.SourceId,\r\n                    ReservationExpirationDate = @event.ReservationAutoExpiration,\r\n                    OrderVersion = @event.Version\r\n                };\r\n                context.Set<PricedOrder>().Add(dto);\r\n                try\r\n                {\r\n                    context.SaveChanges();\r\n                }\r\n                catch (DbUpdateException)\r\n                {\r\n                    Trace.TraceWarning(\r\n                        \"Ignoring OrderPlaced message with version {1} for order id {0}. This could be caused because the message was already handled and the PricedOrder entity was already created.\",\r\n                        dto.OrderId,\r\n                        @event.Version);\r\n                }\r\n            }\r\n        }\r\n\r\n        public void Handle(OrderTotalsCalculated @event)\r\n        {\r\n            var seatTypeIds = @event.Lines.OfType<SeatOrderLine>().Select(x => x.SeatType).Distinct().ToArray();\r\n            using (var context = this.contextFactory.Invoke())\r\n            {\r\n                var dto = context.Query<PricedOrder>().Include(x => x.Lines).First(x => x.OrderId == @event.SourceId);\r\n                if (!WasNotAlreadyHandled(dto, @event.Version))\r\n                {\r\n                    // message already handled, skip.\r\n                    return;\r\n                }\r\n\r\n                var linesSet = context.Set<PricedOrderLine>();\r\n                foreach (var line in dto.Lines.ToList())\r\n                {\r\n                    linesSet.Remove(line);\r\n                }\r\n\r\n                var seatTypeDescriptions = GetSeatTypeDescriptions(seatTypeIds, context);\r\n\r\n                for (int i = 0; i < @event.Lines.Length; i++)\r\n                {\r\n                    var orderLine = @event.Lines[i];\r\n                    var line = new PricedOrderLine\r\n                    {\r\n                        LineTotal = orderLine.LineTotal,\r\n                        Position = i,\r\n                    };\r\n\r\n                    var seatOrderLine = orderLine as SeatOrderLine;\r\n                    if (seatOrderLine != null)\r\n                    {\r\n                        // should we update the view model to avoid losing the SeatTypeId?\r\n                        line.Description = seatTypeDescriptions.Where(x => x.SeatTypeId == seatOrderLine.SeatType).Select(x => x.Name).FirstOrDefault();\r\n                        line.UnitPrice = seatOrderLine.UnitPrice;\r\n                        line.Quantity = seatOrderLine.Quantity;\r\n                    }\r\n\r\n                    dto.Lines.Add(line);\r\n                }\r\n\r\n                dto.Total = @event.Total;\r\n                dto.IsFreeOfCharge = @event.IsFreeOfCharge;\r\n                dto.OrderVersion = @event.Version;\r\n\r\n                context.SaveChanges();\r\n            }\r\n        }\r\n\r\n  }\r\n\r\n\r\npublic class DraftOrderViewModelGenerator :\r\n        IEventHandler<OrderPlaced>\r\n    {\r\n        private readonly Func<ConferenceRegistrationDbContext> contextFactory;\r\n\r\n        static DraftOrderViewModelGenerator()\r\n        {\r\n            // Mapping old version of the OrderPaymentConfirmed event to the new version.\r\n            // Currently it is being done explicitly by the consumer, but this one in particular could be done\r\n            // at the deserialization level, as it is just a rename, not a functionality change.\r\n            Mapper.CreateMap<OrderPaymentConfirmed, OrderConfirmed>();\r\n        }\r\n\r\n        public DraftOrderViewModelGenerator(Func<ConferenceRegistrationDbContext> contextFactory)\r\n        {\r\n            this.contextFactory = contextFactory;\r\n        }\r\n\r\n        public void Handle(OrderPlaced @event)\r\n        {\r\n            using (var context = this.contextFactory.Invoke())\r\n            {\r\n                var dto = new DraftOrder(@event.SourceId, @event.ConferenceId, DraftOrder.States.PendingReservation, @event.Version)\r\n                {\r\n                    AccessCode = @event.AccessCode,\r\n                };\r\n                dto.Lines.AddRange(@event.Seats.Select(seat => new DraftOrderItem(seat.SeatType, seat.Quantity)));\r\n\r\n                context.Save(dto);\r\n            }\r\n        }\r\n\r\n        \r\n    }\r\n\r\n\r\npublic class OrderEventHandler :\r\n        IHandleMessages<OrderPlaced>,\r\n        IHandleMessages<OrderTotalsCalculated>\r\n    {\r\n        private Func<ConferenceContext> contextFactory;\r\n\r\n        public OrderEventHandler(Func<ConferenceContext> contextFactory)\r\n        {\r\n            this.contextFactory = contextFactory;\r\n        }\r\n\r\n        public void Handle(OrderPlaced @event)\r\n        {\r\n            using (var context = this.contextFactory.Invoke())\r\n            {\r\n                context.Orders.Add(new Order(@event.ConferenceId, @event.SourceId, @event.AccessCode));\r\n                context.SaveChanges();\r\n            }\r\n        }\r\n\r\n       \r\n        public void Handle(OrderTotalsCalculated @event)\r\n        {\r\n            if (!ProcessOrder(order => order.Id == @event.SourceId, order => order.TotalAmount = @event.Total))\r\n            {\r\n                Trace.TraceError(\"Failed to locate the order with id {0} to apply calculated totals\", @event.SourceId);\r\n            }\r\n        }\r\n\r\n    }\r\n```\r\n\r\nMy EndPoint Configuration is as follows:\r\n\r\n```\r\npublic class EndpointConfig : IConfigureThisEndpoint, AsA_Server, IWantToRunWhenBusStartsAndStops, IWantToRunWhenConfigurationIsComplete\r\n    {\r\n        public void Init()\r\n        {\r\n            LogManager.Use<Log4NetFactory>();\r\n        }\r\n\r\n        public void Start()\r\n        {\r\n            Wireup.Init()\r\n                .UsingInMemoryPersistence()\r\n                .EnlistInAmbientTransaction()\r\n                .NES()\r\n                .Build();\r\n        }\r\n\r\n        public void Stop()\r\n        {\r\n        }\r\n\r\n        public void Customize(BusConfiguration configuration)\r\n        {\r\n            configuration.UseSerialization<Json>();\r\n            configuration.EnableInstallers();\r\n            configuration.UsePersistence<InMemoryPersistence>();\r\n            configuration.UseTransport<MsmqTransport>();\r\n            configuration.PurgeOnStartup(false);\r\n            configuration.RegisterComponents(c =>\r\n            {\r\n                c.ConfigureComponent<Repository>(DependencyLifecycle.InstancePerUnitOfWork);\r\n                c.ConfigureComponent<SqlBlobStorage>(DependencyLifecycle.InstancePerUnitOfWork);\r\n                c.ConfigureComponent<RegistrationProcessManagerRouter>(DependencyLifecycle.InstancePerUnitOfWork);\r\n                c.ConfigureComponent<RegistrationProcessManager>(DependencyLifecycle.InstancePerUnitOfWork);\r\n                c.ConfigureComponent<ConferenceViewModelGenerator>(DependencyLifecycle.InstancePerUnitOfWork);\r\n                c.ConfigureComponent<DraftOrderViewModelGenerator>(DependencyLifecycle.InstancePerUnitOfWork);\r\n                c.ConfigureComponent<OrderCommandHandler>(DependencyLifecycle.InstancePerUnitOfWork);\r\n                c.ConfigureComponent<PricedOrderViewModelGenerator>(DependencyLifecycle.InstancePerUnitOfWork);\r\n                c.ConfigureComponent<SeatAssignmentsHandler>(DependencyLifecycle.InstancePerUnitOfWork);\r\n                c.ConfigureComponent<SeatAssignmentsViewModelGenerator>(DependencyLifecycle.InstancePerUnitOfWork);\r\n                c.ConfigureComponent<SeatsAvailabilityHandler>(DependencyLifecycle.InstancePerUnitOfWork);\r\n                c.ConfigureComponent<ValidationService>(DependencyLifecycle.SingleInstance);\r\n                c.ConfigureComponent<ValidateIncomingMessages>(DependencyLifecycle.InstancePerCall);\r\n            });\r\n        }\r\n\r\n        public void Run(Configure config)\r\n        {\r\n            config.NES();\r\n        }\r\n    }\r\n```\r\n\r\nInside my web.config I configured as follows:\r\n\r\n ```\r\n<configSections>\r\n    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->\r\n    <section name=\"TransportConfig\" type=\"NServiceBus.Config.TransportConfig, NServiceBus.Core\" />\r\n    <section name=\"UnicastBusConfig\" type=\"NServiceBus.Config.UnicastBusConfig, NServiceBus.Core\" />\r\n    <section name=\"MessageForwardingInCaseOfFaultConfig\" type=\"NServiceBus.Config.MessageForwardingInCaseOfFaultConfig, NServiceBus.Core\" />\r\n    <section name=\"entityFramework\" type=\"System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" requirePermission=\"false\" />\r\n  </configSections>\r\n\r\n <TransportConfig MaxRetries=\"5\" MaximumConcurrencyLevel=\"1\" MaximumMessageThroughputPerSecond=\"0\" />\r\n  <UnicastBusConfig>\r\n    <MessageEndpointMappings>\r\n      <add Messages=\"Registration\" Endpoint=\"Registration\" />\r\n    </MessageEndpointMappings>\r\n  </UnicastBusConfig>\r\n  <MessageForwardingInCaseOfFaultConfig ErrorQueue=\"RegistrationEndPoint.Errors\" />\r\n```\r\n\r\nInside Global.asax I registered Bus as follows:\r\n\r\n ```\r\n public static ISendOnlyBus Bus { get; private set; }\r\n        private void RegisterBus()\r\n        {\r\n            var busConfiguration = new BusConfiguration();\r\n            busConfiguration.UseSerialization<JsonSerializer>();\r\n            busConfiguration.UseTransport<MsmqTransport>();\r\n            busConfiguration.EndpointName(\"Conference.Web.Public\");\r\n            busConfiguration.Transactions().Disable();\r\n            busConfiguration.PurgeOnStartup(false);\r\n\r\n            LogManager.Use<NServiceBus.Log4Net.Log4NetFactory>();\r\n\r\n            Bus = NServiceBus.Bus.CreateSendOnly(busConfiguration);\r\n        }\r\n```\r\n\r\nNote: I am using Unity Container for Resolve Dependencies as follows:\r\n\r\n```\r\nprivate static UnityContainer CreateContainer()\r\n        {\r\n            var container = new UnityContainer();\r\n            try\r\n            {\r\n                // repositories used by the application\r\n\r\n                container.RegisterType<ConferenceRegistrationDbContext>(new TransientLifetimeManager(), new InjectionConstructor(\"ConferenceRegistration\"));\r\n                container.RegisterType<PaymentsReadDbContext>(new TransientLifetimeManager(), new InjectionConstructor(\"Payments\"));\r\n\r\n                var cache = new MemoryCache(\"ReadModel\");\r\n                container.RegisterType<IOrderDao, OrderDao>();\r\n                container.RegisterType<IConferenceDao, CachingConferenceDao>(\r\n                    new ContainerControlledLifetimeManager(),\r\n                    new InjectionConstructor(new ResolvedParameter<ConferenceDao>(), cache));\r\n                container.RegisterType<IPaymentDao, PaymentDao>();\r\n\r\n                // configuration specific settings\r\n\r\n                OnCreateContainer(container);\r\n\r\n                return container;\r\n            }\r\n            catch\r\n            {\r\n                container.Dispose();\r\n                throw;\r\n            }\r\n        }\r\n```\r\n\r\nNow I am really confused where I am making mistake. \r\n\r\nPlease help me to fix the issue."},"comment":{"url":"https://api.github.com/repos/elliotritchie/NES/issues/comments/189766824","html_url":"https://github.com/elliotritchie/NES/issues/40#issuecomment-189766824","issue_url":"https://api.github.com/repos/elliotritchie/NES/issues/40","id":189766824,"user":{"login":"mojamcpds","id":3146262,"avatar_url":"https://avatars.githubusercontent.com/u/3146262?v=3","gravatar_id":"","url":"https://api.github.com/users/mojamcpds","html_url":"https://github.com/mojamcpds","followers_url":"https://api.github.com/users/mojamcpds/followers","following_url":"https://api.github.com/users/mojamcpds/following{/other_user}","gists_url":"https://api.github.com/users/mojamcpds/gists{/gist_id}","starred_url":"https://api.github.com/users/mojamcpds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mojamcpds/subscriptions","organizations_url":"https://api.github.com/users/mojamcpds/orgs","repos_url":"https://api.github.com/users/mojamcpds/repos","events_url":"https://api.github.com/users/mojamcpds/events{/privacy}","received_events_url":"https://api.github.com/users/mojamcpds/received_events","type":"User","site_admin":false},"created_at":"2016-02-28T02:32:55Z","updated_at":"2016-02-28T02:32:55Z","body":"Any update?"}}