/// <summary>
        ///     Write an event asynchronously.
        /// </summary>
        /// <param name="eventInstance">Event Instance</param>
        /// <returns></returns>
        public async Task WriteEventAsync(IEvent eventInstance)
        {
            // No event, no send.
            if (eventInstance == null)
                return;

            var message = new EventBusMessage(eventInstance);
            await Bus.Advanced.PublishAsync(Exchange, String.Empty, false, false, new Message<EventBusMessage>(message));
        }
        /// <summary>
        ///     Create the transport item wrapper for this instance of an event
        /// </summary>
        /// <param name="eventInstance">Event Instance</param>
        /// <returns>Transport item</returns>
        protected BrokeredMessage CreateTransportItem(IEvent eventInstance)
        {
            var item = new EventBusMessage(eventInstance);

            var message = new BrokeredMessage(item);
            message.Properties.Add(AzureFrameworkConstants.ContextMessageProperty, Context.ContextName);
            message.Properties.Add(AzureFrameworkConstants.EventTypeMessageProperty, item.EventType);

            return message;
        }
        /// <summary>
        ///     Write an event to the RabbitMQ instance.
        /// </summary>
        /// <param name="eventInstance">Event instance</param>
        public void WriteEvent(IEvent eventInstance)
        {
            // No event, no send.
            if (eventInstance == null)
                return;

            var message = new EventBusMessage(eventInstance);

            Bus.Advanced.Publish(Exchange, String.Empty, false, false, new Message<EventBusMessage>(message));
        }
        /// <summary>
        ///     Process the recieved messsage
        /// </summary>
        /// <param name="message">Message from the subscription</param>
        protected void HandleEventBusMessage(EventBusMessage message)
        {
            if (message == null)
                return;

            // Find the type - If not part of our bounded context, ignore.
            var targetType =
                BoundedContext.EventTypes.Where(x => string.Equals(x.Name, message.EventType)).FirstOrDefault();
            if (targetType == null)
                return;

            // Unpack JSON into event data
            var eventInstance = targetType.UnpackJsonEvent(message.EventJson, TypeResolver);

            // Execute event handlers
            Dispatcher.Dispatch(eventInstance);
        }