Пример #1
0
 public ConsumerFactory(IAmACommandProcessor commandProcessor, IAmAMessageMapperRegistry messageMapperRegistry, Connection connection, ILog logger)
 {
     this.commandProcessor      = commandProcessor;
     this.messageMapperRegistry = messageMapperRegistry;
     this.connection            = connection;
     this.logger = logger;
 }
 public INeedARequestContext TaskQueues(MessagingConfiguration configuration)
 {
     messageStore = configuration.MessageStore;
     messagingGateway = configuration.MessagingGateway;
     messageMapperRegistry = configuration.MessageMapperRegistry;
     return this;
 }
Пример #3
0
 /// <summary>
 /// The <see cref="CommandProcessor"/> wants to support <see cref="CommandProcessor.Post{T}(T)"/> or <see cref="CommandProcessor.Repost"/> using Task Queues.
 /// You need to provide a policy to specify how QoS issues, specifically <see cref="CommandProcessor.RETRYPOLICY "/> or <see cref="CommandProcessor.CIRCUITBREAKER "/>
 /// are handled by adding appropriate <see cref="Policies"/> when choosing this option.
 ///
 /// </summary>
 /// <param name="configuration">The Task Queues configuration.</param>
 /// <returns>INeedARequestContext.</returns>
 public INeedARequestContext TaskQueues(MessagingConfiguration configuration)
 {
     messageStore          = configuration.MessageStore;
     messagingGateway      = configuration.MessagingGateway;
     messageMapperRegistry = configuration.MessageMapperRegistry;
     return(this);
 }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Dispatcher"/> class.
 /// </summary>
 /// <param name="commandProcessor">The command processor.</param>
 /// <param name="messageMapperRegistry">The message mapper registry.</param>
 /// <param name="connections">The connections.</param>
 public Dispatcher(
     IAmACommandProcessor commandProcessor,
     IAmAMessageMapperRegistry messageMapperRegistry,
     IEnumerable <Connection> connections)
     : this(commandProcessor, messageMapperRegistry, connections, LogProvider.For <Dispatcher>())
 {
 }
Пример #5
0
 public ConsumerFactory(IAmACommandProcessorProvider commandProcessorProvider, IAmAMessageMapperRegistry messageMapperRegistry, Subscription subscription)
 {
     _commandProcessorProvider = commandProcessorProvider;
     _messageMapperRegistry    = messageMapperRegistry;
     _subscription             = subscription;
     _consumerName             = new ConsumerName($"{_subscription.Name}-{Guid.NewGuid()}");
 }
Пример #6
0
 public ConsumerFactory(IAmACommandProcessor commandProcessor, IAmAMessageMapperRegistry messageMapperRegistry, Connection connection)
 {
     _commandProcessor      = commandProcessor;
     _messageMapperRegistry = messageMapperRegistry;
     _connection            = connection;
     _consumerName          = new ConsumerName($"{_connection.Name}-{Guid.NewGuid()}");
 }
Пример #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
        /// Use this constructor when both rpc support is required
        /// </summary>
        /// <param name="subscriberRegistry">The subscriber registry.</param>
        /// <param name="handlerFactory">The handler factory.</param>
        /// <param name="requestContextFactory">The request context factory.</param>
        /// <param name="policyRegistry">The policy registry.</param>
        /// <param name="mapperRegistry">The mapper registry.</param>
        /// <param name="outBox">The outbox</param>
        /// <param name="producerRegistry">The register of producers via whom we send messages over the external bus</param>
        /// <param name="replySubscriptions">The Subscriptions for creating the reply queues</param>
        /// <param name="responseChannelFactory">If we are expecting a response, then we need a channel to listen on</param>
        /// <param name="outboxTimeout">How long should we wait to write to the outbox</param>
        /// <param name="featureSwitchRegistry">The feature switch config provider.</param>
        /// <param name="inboxConfiguration">Do we want to insert an inbox handler into pipelines without the attribute. Null (default = no), yes = how to configure</param>
        /// <param name="boxTransactionConnectionProvider">The Box Connection Provider to use when Depositing into the outbox.</param>
        public CommandProcessor(
            IAmASubscriberRegistry subscriberRegistry,
            IAmAHandlerFactory handlerFactory,
            IAmARequestContextFactory requestContextFactory,
            IPolicyRegistry <string> policyRegistry,
            IAmAMessageMapperRegistry mapperRegistry,
            IAmAnOutbox <Message> outBox,
            IAmAProducerRegistry producerRegistry,
            IEnumerable <Subscription> replySubscriptions,
            int outboxTimeout = 300,
            IAmAFeatureSwitchRegistry featureSwitchRegistry = null,
            IAmAChannelFactory responseChannelFactory       = null,
            InboxConfiguration inboxConfiguration           = null,
            IAmABoxTransactionConnectionProvider boxTransactionConnectionProvider = null)
            : this(subscriberRegistry, handlerFactory, requestContextFactory, policyRegistry)
        {
            _mapperRegistry                   = mapperRegistry;
            _featureSwitchRegistry            = featureSwitchRegistry;
            _responseChannelFactory           = responseChannelFactory;
            _inboxConfiguration               = inboxConfiguration;
            _boxTransactionConnectionProvider = boxTransactionConnectionProvider;
            _replySubscriptions               = replySubscriptions;

            InitExtServiceBus(policyRegistry, outBox, outboxTimeout, producerRegistry);

            ConfigureCallbacks(producerRegistry);
        }
Пример #8
0
 public ConsumerFactory(IAmACommandProcessor commandProcessor, IAmAMessageMapperRegistry messageMapperRegistry, Connection connection)
 {
     _commandProcessor      = commandProcessor;
     _messageMapperRegistry = messageMapperRegistry;
     _connection            = connection;
     _consumerName          = new ConsumerName($"{_connection.Name}-{DateTime.Now.Ticks}");
 }
Пример #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessagingConfiguration"/> class.
 /// </summary>
 /// <param name="messageStore">The message store.</param>
 /// <param name="messagingGateway">The messaging gateway.</param>
 /// <param name="messageMapperRegistry">The message mapper registry.</param>
 public MessagingConfiguration(
     IAmAMessageStore <Message> messageStore,
     IAmAMessageProducer messagingGateway,
     IAmAMessageMapperRegistry messageMapperRegistry
     )
 {
     MessageStore          = messageStore;
     MessagingGateway      = messagingGateway;
     MessageMapperRegistry = messageMapperRegistry;
 }
Пример #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessagingConfiguration"/> class.
 /// </summary>
 /// <param name="messageStore">The message store.</param>
 /// <param name="messagingGateway">The messaging gateway.</param>
 /// <param name="messageMapperRegistry">The message mapper registry.</param>
 public MessagingConfiguration(
     IAmAMessageStore <Message> messageStore,
     IAmAClientRequestHandler messagingGateway,
     IAmAMessageMapperRegistry messageMapperRegistry
     )
 {
     MessageStore          = messageStore;
     MessagingGateway      = messagingGateway;
     MessageMapperRegistry = messageMapperRegistry;
 }
Пример #11
0
 public MessagingConfiguration(
     IAmAMessageStore<Message> messageStore, 
     IAmAMessagingGateway messagingGateway, 
     IAmAMessageMapperRegistry messageMapperRegistry
     )
 {
     MessageStore = messageStore;
     MessagingGateway = messagingGateway;
     MessageMapperRegistry = messageMapperRegistry;
 }
Пример #12
0
 /// <summary>
 /// The <see cref="CommandProcessor"/> wants to support <see cref="CommandProcessor.Post{T}(T)"/> or <see cref="CommandProcessor.Repost"/> using an external bus.
 /// You need to provide a policy to specify how QoS issues, specifically <see cref="CommandProcessor.RETRYPOLICY "/> or <see cref="CommandProcessor.CIRCUITBREAKER "/>
 /// are handled by adding appropriate <see cref="Policies"/> when choosing this option.
 ///
 /// </summary>
 /// <param name="configuration">The Task Queues configuration.</param>
 /// <param name="outbox">The Outbox.</param>
 /// <param name="boxTransactionConnectionProvider"></param>
 /// <returns>INeedARequestContext.</returns>
 public INeedARequestContext ExternalBus(ExternalBusConfiguration configuration, IAmAnOutbox <Message> outbox, IAmABoxTransactionConnectionProvider boxTransactionConnectionProvider = null)
 {
     _useExternalBus = true;
     _producers      = configuration.ProducerRegistry;
     _outbox         = outbox;
     _overridingBoxTransactionConnectionProvider = boxTransactionConnectionProvider;
     _messageMapperRegistry = configuration.MessageMapperRegistry;
     _outboxWriteTimeout    = configuration.OutboxWriteTimeout;
     return(this);
 }
Пример #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when only task queue support is required
 /// </summary>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="messageStore">The message store.</param>
 /// <param name="messageProducer">The messaging gateway.</param>
 /// <param name="messageStoreTimeout">How long should we wait to write to the message store</param>
 public CommandProcessor(
     IAmARequestContextFactory requestContextFactory,
     IAmAPolicyRegistry policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAMessageStore <Message> messageStore,
     IAmAMessageProducer messageProducer,
     int messageStoreTimeout = 300
     ) : this(requestContextFactory, policyRegistry, mapperRegistry, messageStore, messageProducer, LogProvider.GetCurrentClassLogger(), messageStoreTimeout)
 {
 }
Пример #14
0
 /// <summary>
 /// The <see cref="CommandProcessor"/> wants to support <see cref="CommandProcessor.Post{T}(T)"/> or <see cref="CommandProcessor.Repost"/> using Task Queues.
 /// You need to provide a policy to specify how QoS issues, specifically <see cref="CommandProcessor.RETRYPOLICY "/> or <see cref="CommandProcessor.CIRCUITBREAKER "/>
 /// are handled by adding appropriate <see cref="Policies"/> when choosing this option.
 ///
 /// </summary>
 /// <param name="configuration">The Task Queues configuration.</param>
 /// <returns>INeedARequestContext.</returns>
 public INeedARequestContext TaskQueues(MessagingConfiguration configuration)
 {
     _useTaskQueues               = true;
     _messageStore                = configuration.MessageStore;
     _messagingGateway            = configuration.MessageProducer;
     _messageMapperRegistry       = configuration.MessageMapperRegistry;
     _messageStoreWriteTimeout    = configuration.MessageStoreWriteTimeout;
     _messagingGatewaySendTimeout = configuration.MessagingGatewaySendTimeout;
     return(this);
 }
Пример #15
0
        /// <summary>
        /// The <see cref="CommandProcessor"/> wants to support <see cref="CommandProcessor.Call{T}(T)"/> using RPC between client and server
        /// </summary>
        /// <param name="messagingConfiguration"></param>
        /// <returns></returns>
        public INeedARequestContext RequestReplyQueues(MessagingConfiguration configuration)
        {
            _useRequestReplyQueues       = true;
            _messagingGateway            = configuration.MessageProducer;
            _asyncMessagingGateway       = configuration.MessageProducerAsync;
            _messageMapperRegistry       = configuration.MessageMapperRegistry;
            _outboxWriteTimeout          = configuration.OutboxWriteTimeout;
            _messagingGatewaySendTimeout = configuration.MessagingGatewaySendTimeout;
            _responseChannelFactory      = configuration.ResponseChannelFactory;

            return(this);
        }
Пример #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Dispatcher"/> class.
        /// </summary>
        /// <param name="commandProcessor">The command processor.</param>
        /// <param name="messageMapperRegistry">The message mapper registry.</param>
        /// <param name="connections">The connections.</param>
        /// <param name="logger">The logger.</param>
        public Dispatcher(IAmACommandProcessor commandProcessor, IAmAMessageMapperRegistry messageMapperRegistry, IEnumerable <Connection> connections, ILog logger)
        {
            this.commandProcessor      = commandProcessor;
            this.messageMapperRegistry = messageMapperRegistry;
            this.Connections           = connections;
            this.logger = logger;
            State       = DispatcherState.DS_NOTREADY;

            Consumers = new SynchronizedCollection <Consumer>();

            State = DispatcherState.DS_AWAITING;
        }
Пример #17
0
 /// <summary>
 /// The <see cref="CommandProcessor"/> wants to support <see cref="CommandProcessor.Post{T}(T)"/> or <see cref="CommandProcessor.Repost"/> using Task Queues.
 /// You need to provide a policy to specify how QoS issues, specifically <see cref="CommandProcessor.RETRYPOLICY "/> or <see cref="CommandProcessor.CIRCUITBREAKER "/>
 /// are handled by adding appropriate <see cref="Policies"/> when choosing this option.
 ///
 /// </summary>
 /// <param name="configuration">The Task Queues configuration.</param>
 /// <returns>INeedARequestContext.</returns>
 public INeedARequestContext TaskQueues(MessagingConfiguration configuration)
 {
     _useTaskQueues               = true;
     _outbox                      = configuration.OutBox;
     _asyncOutbox                 = configuration.OutboxAsync;
     _messagingGateway            = configuration.MessageProducer;
     _asyncMessagingGateway       = configuration.MessageProducerAsync;
     _messageMapperRegistry       = configuration.MessageMapperRegistry;
     _outboxWriteTimeout          = configuration.OutboxWriteTimeout;
     _messagingGatewaySendTimeout = configuration.MessagingGatewaySendTimeout;
     return(this);
 }
Пример #18
0
        /// <summary>
        /// The <see cref="CommandProcessor"/> wants to support <see cref="CommandProcessor.Call{T}(T)"/> using RPC between client and server
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="outbox">The outbox</param>
        /// <param name="subscriptions">Subscriptions for creating reply queues</param>
        /// <returns></returns>
        public INeedARequestContext ExternalRPC(ExternalBusConfiguration configuration, IAmAnOutbox <Message> outbox, IEnumerable <Subscription> subscriptions)
        {
            _useRequestReplyQueues  = true;
            _replySubscriptions     = subscriptions;
            _producers              = configuration.ProducerRegistry;
            _messageMapperRegistry  = configuration.MessageMapperRegistry;
            _outboxWriteTimeout     = configuration.OutboxWriteTimeout;
            _responseChannelFactory = configuration.ResponseChannelFactory;
            _outbox = outbox;

            return(this);
        }
Пример #19
0
        public Dispatcher(IAmACommandProcessor commandProcessor, IAmAMessageMapperRegistry messageMapperRegistry, IEnumerable<Connection> connections, ILog logger)
        {
            this.commandProcessor = commandProcessor;
            this.messageMapperRegistry = messageMapperRegistry;
            this.logger = logger;
            State = DispatcherState.DS_NOTREADY;

            Consumers = new SynchronizedCollection<Consumer>();
            CreateConsumers(connections).Each(consumer => Consumers.Add(consumer));
            
            State = DispatcherState.DS_AWAITING;
            logger.Debug(m => m("Dispatcher is ready to recieve"));
        }
Пример #20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Dispatcher"/> class.
        /// </summary>
        /// <param name="commandProcessor">The command processor.</param>
        /// <param name="messageMapperRegistry">The message mapper registry.</param>
        /// <param name="connections">The connections.</param>
        /// <param name="logger">The logger.</param>
        public Dispatcher(IAmACommandProcessor commandProcessor, IAmAMessageMapperRegistry messageMapperRegistry, IEnumerable <Connection> connections, ILog logger)
        {
            this.commandProcessor      = commandProcessor;
            this.messageMapperRegistry = messageMapperRegistry;
            this.logger = logger;
            State       = DispatcherState.DS_NOTREADY;

            Consumers = new SynchronizedCollection <Consumer>();
            CreateConsumers(connections).Each(consumer => Consumers.Add(consumer));

            State = DispatcherState.DS_AWAITING;
            logger.Debug(m => m("Dispatcher is ready to recieve"));
        }
Пример #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when only task queue support is required
 /// </summary>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="asyncMessageStore">The message store supporting async/await.</param>
 /// <param name="asyncMessageProducer">The messaging gateway supporting async/await.</param>
 /// <param name="messageStoreTimeout">How long should we wait to write to the message store</param>
 public CommandProcessor(
     IAmARequestContextFactory requestContextFactory,
     IAmAPolicyRegistry policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAMessageStoreAsync <Message> asyncMessageStore,
     IAmAMessageProducerAsync asyncMessageProducer,
     int messageStoreTimeout = 300
     )
     : this(
         requestContextFactory, policyRegistry, mapperRegistry, asyncMessageStore, asyncMessageProducer,
         LogProvider.For <CommandProcessor>(), messageStoreTimeout)
 {
 }
Пример #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when both task queue and command processor support is required
 /// </summary>
 /// <param name="subscriberRegistry">The subscriber registry.</param>
 /// <param name="handlerFactory">The handler factory.</param>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="messageStore">The message store.</param>
 /// <param name="messageProducer">The messaging gateway.</param>
 /// <param name="messageStoreTimeout">How long should we wait to write to the message store</param>
 /// <param name="messageGatewaySendTimeout">How long should we wait to post to the message store</param>
 public CommandProcessor(
     IAmASubscriberRegistry subscriberRegistry,
     IAmAHandlerFactory handlerFactory,
     IAmARequestContextFactory requestContextFactory,
     IAmAPolicyRegistry policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAMessageStore <Message> messageStore,
     IAmAMessageProducer messageProducer,
     int messageStoreTimeout = 300
     )
     : this(subscriberRegistry, handlerFactory, requestContextFactory, policyRegistry, mapperRegistry, messageStore, messageProducer, LogProvider.For <CommandProcessor>(), messageStoreTimeout)
 {
 }
Пример #23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessagingConfiguration"/> class.
 /// </summary>
 /// <param name="asyncMessageProducer">The messaging gateway that supports async/await.</param>
 /// <param name="messageMapperRegistry">The message mapper registry.</param>
 /// <param name="outboxWriteTimeout">How long to wait when writing to the outbox</param>
 /// <param name="messagingGatewaySendTimeout">How long to wait when sending via the gateway</param>
 /// <param name="useInbox">Do we want to create an inbox globally i.e. on every handler (as opposed to by hand). Defaults to null, by hand</param>
 public MessagingConfiguration(
     IAmAMessageProducerAsync asyncMessageProducer,
     IAmAMessageMapperRegistry messageMapperRegistry,
     int outboxWriteTimeout          = 300,
     int messagingGatewaySendTimeout = 300,
     InboxConfiguration useInbox     = null
     )
 {
     MessageProducerAsync        = asyncMessageProducer;
     MessageMapperRegistry       = messageMapperRegistry;
     OutboxWriteTimeout          = outboxWriteTimeout;
     MessagingGatewaySendTimeout = messagingGatewaySendTimeout;
     UseInbox = useInbox;
 }
Пример #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExternalBusConfiguration"/> class.
 /// </summary>
 /// <param name="producerRegistry">Clients for the external bus by topic they send to. The client details are specialised by transport</param>
 /// <param name="messageMapperRegistry">The message mapper registry.</param>
 /// <param name="outboxWriteTimeout">How long to wait when writing to the outbox</param>
 /// <param name="responseChannelFactory">in a request-response scenario how do we build response pipelie</param>
 /// <param name="useInbox">Do we want to create an inbox globally i.e. on every handler (as opposed to by hand). Defaults to null, ,by hand</param>
 public ExternalBusConfiguration(
     IAmAProducerRegistry producerRegistry,
     IAmAMessageMapperRegistry messageMapperRegistry,
     int outboxWriteTimeout = 300,
     IAmAChannelFactory responseChannelFactory = null,
     InboxConfiguration useInbox = null
     )
 {
     ProducerRegistry       = producerRegistry;
     MessageMapperRegistry  = messageMapperRegistry;
     OutboxWriteTimeout     = outboxWriteTimeout;
     ResponseChannelFactory = responseChannelFactory;
     UseInbox = useInbox;
 }
Пример #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessagingConfiguration"/> class.
 /// </summary>
 /// <param name="messageStore">The message store.</param>
 /// <param name="messagingGateway">The messaging gateway.</param>
 /// <param name="messageMapperRegistry">The message mapper registry.</param>
 /// <param name="messageStoreWriteTimeout">How long to wait when writing to the message store</param>
 /// <param name="messagingGatewaySendTimeout">How long to wait when sending via the gateway</param>
 public MessagingConfiguration(
     IAmAMessageStore <Message> messageStore,
     IAmAMessageProducer messagingGateway,
     IAmAMessageMapperRegistry messageMapperRegistry,
     int messageStoreWriteTimeout    = 300,
     int messagingGatewaySendTimeout = 300
     )
 {
     MessageStore                = messageStore;
     MessagingGateway            = messagingGateway;
     MessageMapperRegistry       = messageMapperRegistry;
     MessageStoreWriteTimeout    = messageStoreWriteTimeout;
     MessagingGatewaySendTimeout = messagingGatewaySendTimeout;
 }
Пример #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessagingConfiguration"/> class.
 /// </summary>
 /// <param name="messageStore">The message store.</param>
 /// <param name="messageProducer">The messaging gateway.</param>
 /// <param name="messageMapperRegistry">The message mapper registry.</param>
 /// <param name="messageStoreWriteTimeout">How long to wait when writing to the message store</param>
 /// <param name="messagingGatewaySendTimeout">How long to wait when sending via the gateway</param>
 public MessagingConfiguration(
     IAmAMessageStore<Message> messageStore,
     IAmAMessageProducer messageProducer,
     IAmAMessageMapperRegistry messageMapperRegistry,
     int messageStoreWriteTimeout = 300,
     int messagingGatewaySendTimeout = 300
     )
 {
     MessageStore = messageStore;
     MessageProducer = messageProducer;
     MessageMapperRegistry = messageMapperRegistry;
     MessageStoreWriteTimeout = messageStoreWriteTimeout;
     MessagingGatewaySendTimeout = messagingGatewaySendTimeout;
 }
Пример #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when both task queue and command processor support is required
 /// </summary>
 /// <param name="subscriberRegistry">The subscriber registry.</param>
 /// <param name="handlerFactory">The handler factory.</param>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="messageStore">The message store.</param>
 /// <param name="messageProducer">The messaging gateway.</param>
 /// <param name="messageStoreTimeout">How long should we wait to write to the message store</param>
 /// <param name="messageGatewaySendTimeout">How long should we wait to post to the message store</param>
 public CommandProcessor(
     IAmASubscriberRegistry subscriberRegistry,
     IAmAHandlerFactory handlerFactory,
     IAmARequestContextFactory requestContextFactory,
     IAmAPolicyRegistry policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAMessageStore <Message> messageStore,
     IAmAMessageProducer messageProducer,
     int messageStoreTimeout       = 300,
     int messageGatewaySendTimeout = 300
     )
     : this(subscriberRegistry, handlerFactory, requestContextFactory, policyRegistry, mapperRegistry, messageStore, messageProducer, LogProvider.GetCurrentClassLogger())
 {
 }
Пример #28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessagingConfiguration"/> class.
 /// </summary>
 /// <param name="asyncMessageStore">The message store that supports async/await.</param>
 /// <param name="asyncmessageProducer">The messaging gateway that supports async/await.</param>
 /// <param name="messageMapperRegistry">The message mapper registry.</param>
 /// <param name="messageStoreWriteTimeout">How long to wait when writing to the message store</param>
 /// <param name="messagingGatewaySendTimeout">How long to wait when sending via the gateway</param>
 public MessagingConfiguration(
     IAmAMessageStoreAsync <Message> asyncMessageStore,
     IAmAMessageProducerAsync asyncmessageProducer,
     IAmAMessageMapperRegistry messageMapperRegistry,
     int messageStoreWriteTimeout    = 300,
     int messagingGatewaySendTimeout = 300
     )
 {
     AsyncMessageStore           = asyncMessageStore;
     AsyncMessageProducer        = asyncmessageProducer;
     MessageMapperRegistry       = messageMapperRegistry;
     MessageStoreWriteTimeout    = messageStoreWriteTimeout;
     MessagingGatewaySendTimeout = messagingGatewaySendTimeout;
 }
Пример #29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when both task queue and command processor support is required
 /// </summary>
 /// <param name="subscriberRegistry">The subscriber registry.</param>
 /// <param name="handlerFactory">The handler factory.</param>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="messageStore">The message store.</param>
 /// <param name="messagingGateway">The messaging gateway.</param>
 /// <param name="logger">The logger.</param>
 public CommandProcessor(
     IAmASubscriberRegistry subscriberRegistry,
     IAmAHandlerFactory handlerFactory,
     IAmARequestContextFactory requestContextFactory,
     IAmAPolicyRegistry policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAMessageStore <Message> messageStore,
     IAmAMessageProducer messagingGateway,
     ILog logger)
     : this(subscriberRegistry, handlerFactory, requestContextFactory, policyRegistry, logger)
 {
     this.mapperRegistry   = mapperRegistry;
     this.messageStore     = messageStore;
     this.messagingGateway = messagingGateway;
 }
Пример #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when only task queue support is required
 /// </summary>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="messageStore">The message store.</param>
 /// <param name="messagingGateway">The messaging gateway.</param>
 /// <param name="logger">The logger.</param>
 public CommandProcessor(
     IAmARequestContextFactory requestContextFactory,
     IAmAPolicyRegistry policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAMessageStore <Message> messageStore,
     IAmAMessageProducer messagingGateway,
     ILog logger)
 {
     this.requestContextFactory = requestContextFactory;
     this.policyRegistry        = policyRegistry;
     this.logger           = logger;
     this.mapperRegistry   = mapperRegistry;
     this.messageStore     = messageStore;
     this.messagingGateway = messagingGateway;
 }
Пример #31
0
 /// <summary>
 /// The <see cref="CommandProcessor"/> wants to support <see cref="CommandProcessor.Post{T}(T)"/> or <see cref="CommandProcessor.Repost"/> using Task Queues.
 /// You need to provide a policy to specify how QoS issues, specifically <see cref="CommandProcessor.RETRYPOLICY "/> or <see cref="CommandProcessor.CIRCUITBREAKER "/>
 /// are handled by adding appropriate <see cref="Policies"/> when choosing this option.
 ///
 /// </summary>
 /// <param name="configuration">The Task Queues configuration.</param>
 /// <returns>INeedARequestContext.</returns>
 public INeedARequestContext TaskQueues(MessagingConfiguration configuration, IAmAnOutbox <Message> outbox)
 {
     _useTaskQueues    = true;
     _messagingGateway = configuration.MessageProducer;
     _outbox           = outbox;
     if (outbox is IAmAnOutboxAsync <Message> )
     {
         _asyncOutbox = (IAmAnOutboxAsync <Message>)outbox;
     }
     _asyncMessagingGateway       = configuration.MessageProducerAsync;
     _messageMapperRegistry       = configuration.MessageMapperRegistry;
     _outboxWriteTimeout          = configuration.OutboxWriteTimeout;
     _messagingGatewaySendTimeout = configuration.MessagingGatewaySendTimeout;
     return(this);
 }
Пример #32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when only task queue support is required
 /// </summary>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="asyncMessageStore">The message store supporting async/await.</param>
 /// <param name="asyncMessageProducer">The messaging gateway supporting async/await.</param>
 /// <param name="messageStoreTimeout">How long should we wait to write to the message store</param>
 public CommandProcessor(
     IAmARequestContextFactory requestContextFactory,
     IAmAPolicyRegistry policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAMessageStoreAsync <Message> asyncMessageStore,
     IAmAMessageProducerAsync asyncMessageProducer,
     int messageStoreTimeout = 300)
 {
     _requestContextFactory = requestContextFactory;
     _policyRegistry        = policyRegistry;
     _messageStoreTimeout   = messageStoreTimeout;
     _mapperRegistry        = mapperRegistry;
     _asyncMessageStore     = asyncMessageStore;
     _asyncMessageProducer  = asyncMessageProducer;
 }
Пример #33
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when both task queue and command processor support is required
 /// </summary>
 /// <param name="subscriberRegistry">The subscriber registry.</param>
 /// <param name="asyncHandlerFactory">The async handler factory.</param>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="asyncMessageStore">The message store supporting async/await.</param>
 /// <param name="asyncMessageProducer">The messaging gateway supporting async/await.</param>
 /// <param name="messageStoreTimeout">How long should we wait to write to the message store</param>
 public CommandProcessor(
     IAmASubscriberRegistry subscriberRegistry,
     IAmAHandlerFactoryAsync asyncHandlerFactory,
     IAmARequestContextFactory requestContextFactory,
     IAmAPolicyRegistry policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAMessageStoreAsync <Message> asyncMessageStore,
     IAmAMessageProducerAsync asyncMessageProducer,
     int messageStoreTimeout = 300)
     : this(subscriberRegistry, asyncHandlerFactory, requestContextFactory, policyRegistry)
 {
     _mapperRegistry       = mapperRegistry;
     _asyncMessageStore    = asyncMessageStore;
     _asyncMessageProducer = asyncMessageProducer;
     _messageStoreTimeout  = messageStoreTimeout;
 }
Пример #34
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessagingConfiguration"/> class.
 /// </summary>
 /// <param name="messageProducer">The messaging gateway.</param>
 /// <param name="messageMapperRegistry">The message mapper registry.</param>
 /// <param name="outboxWriteTimeout">How long to wait when writing to the outbox</param>
 /// <param name="messagingGatewaySendTimeout">How long to wait when sending via the gateway</param>
 /// <param name="responseChannelFactory">in a request-response scenario how do we build response pipelie</param>
 /// <param name="useInbox">Do we want to create an inbox globally i.e. on every handler (as opposed to by hand). Defaults to null, ,by hand</param>
 public MessagingConfiguration(
     IAmAMessageProducer messageProducer,
     IAmAMessageMapperRegistry messageMapperRegistry,
     int outboxWriteTimeout                    = 300,
     int messagingGatewaySendTimeout           = 300,
     IAmAChannelFactory responseChannelFactory = null,
     InboxConfiguration useInbox               = null
     )
 {
     MessageProducer             = messageProducer;
     MessageMapperRegistry       = messageMapperRegistry;
     OutboxWriteTimeout          = outboxWriteTimeout;
     MessagingGatewaySendTimeout = messagingGatewaySendTimeout;
     ResponseChannelFactory      = responseChannelFactory;
     UseInbox = useInbox;
 }
Пример #35
0
 /// <summary>
 /// The <see cref="CommandProcessor"/> wants to support <see cref="CommandProcessor.Post{T}(T)"/> or <see cref="CommandProcessor.Repost"/> using Task Queues.
 /// You need to provide a policy to specify how QoS issues, specifically <see cref="CommandProcessor.RETRYPOLICY "/> or <see cref="CommandProcessor.CIRCUITBREAKER "/> 
 /// are handled by adding appropriate <see cref="Policies"/> when choosing this option.
 /// 
 /// </summary>
 /// <param name="configuration">The Task Queues configuration.</param>
 /// <returns>INeedARequestContext.</returns>
 public INeedARequestContext TaskQueues(MessagingConfiguration configuration)
 {
     _useTaskQueues = true;
     _messageStore = configuration.MessageStore;
     _messagingGateway = configuration.MessagingGateway;
     _messageMapperRegistry = configuration.MessageMapperRegistry;
     _messageStoreWriteTimeout = configuration.MessageStoreWriteTimeout;
     _messagingGatewaySendTimeout = configuration.MessagingGatewaySendTimeout;
     return this;
 }
Пример #36
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessagingConfiguration"/> class.
 /// </summary>
 /// <param name="asyncMessageStore">The message store that supports async/await.</param>
 /// <param name="asyncmessageProducer">The messaging gateway that supports async/await.</param>
 /// <param name="messageMapperRegistry">The message mapper registry.</param>
 /// <param name="messageStoreWriteTimeout">How long to wait when writing to the message store</param>
 /// <param name="messagingGatewaySendTimeout">How long to wait when sending via the gateway</param>
 public MessagingConfiguration(
     IAmAMessageStoreAsync<Message> asyncMessageStore,
     IAmAMessageProducerAsync asyncmessageProducer,
     IAmAMessageMapperRegistry messageMapperRegistry,
     int messageStoreWriteTimeout = 300,
     int messagingGatewaySendTimeout = 300
     )
 {
     AsyncMessageStore = asyncMessageStore;
     AsyncMessageProducer = asyncmessageProducer;
     MessageMapperRegistry = messageMapperRegistry;
     MessageStoreWriteTimeout = messageStoreWriteTimeout;
     MessagingGatewaySendTimeout = messagingGatewaySendTimeout;
 }
Пример #37
0
 /// <summary>
 /// The message mappers used to map between commands, events, and on-the-wire handlers.
 /// </summary>
 /// <param name="theMessageMapperRegistry">The message mapper registry.</param>
 /// <returns>INeedAChannelFactory.</returns>
 public INeedAChannelFactory MessageMappers(IAmAMessageMapperRegistry theMessageMapperRegistry)
 {
     _messageMapperRegistry = theMessageMapperRegistry;
     return this;
 }
Пример #38
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Dispatcher"/> class.
        /// </summary>
        /// <param name="commandProcessor">The command processor.</param>
        /// <param name="messageMapperRegistry">The message mapper registry.</param>
        /// <param name="connections">The connections.</param>
        public Dispatcher(
            IAmACommandProcessor commandProcessor, 
            IAmAMessageMapperRegistry messageMapperRegistry,
            IEnumerable<Connection> connections)
        {
            CommandProcessor = commandProcessor;
            Connections = connections;
            _messageMapperRegistry = messageMapperRegistry;

            State = DispatcherState.DS_NOTREADY;

            _tasks = new ConcurrentDictionary<int, Task>();
            _consumers = new ConcurrentDictionary<string, IAmAConsumer>();

            State = DispatcherState.DS_AWAITING;
        }
Пример #39
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Dispatcher"/> class.
 /// </summary>
 /// <param name="commandProcessor">The command processor.</param>
 /// <param name="messageMapperRegistry">The message mapper registry.</param>
 /// <param name="connections">The connections.</param>
 public Dispatcher(
     IAmACommandProcessor commandProcessor, 
     IAmAMessageMapperRegistry messageMapperRegistry,
     IEnumerable<Connection> connections)
     :this(commandProcessor, messageMapperRegistry, connections, LogProvider.GetCurrentClassLogger())
 {}
Пример #40
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Dispatcher"/> class.
        /// Use this if you need to inject a logger, for example for testing
        /// </summary>
        /// <param name="commandProcessor">The command processor.</param>
        /// <param name="messageMapperRegistry">The message mapper registry.</param>
        /// <param name="connections">The connections.</param>
        /// <param name="logger">The logger.</param>
        public Dispatcher(
            IAmACommandProcessor commandProcessor, 
            IAmAMessageMapperRegistry messageMapperRegistry, 
            IEnumerable<Connection> connections,
            ILog logger)
        {
            CommandProcessor = commandProcessor;
            _messageMapperRegistry = messageMapperRegistry;
            this.Connections = connections;
            _logger = logger;
            State = DispatcherState.DS_NOTREADY;

            Consumers = new SynchronizedCollection<IAmAConsumer>();

            State = DispatcherState.DS_AWAITING;
        }