コード例 #1
0
 public DistributableCommandBus(ICommandHandlerProvider handlerProvider,
     ILinearCommandManager linearCommandManager,
     IMessageConsumer commandConsumer,
     string receiveEndPoint,
     bool inProc)
     : base(handlerProvider, linearCommandManager, receiveEndPoint, inProc)
 {
     _commandConsumer = commandConsumer as IInProcMessageConsumer;
     _commandDistributor = _commandConsumer;
     _isDistributor = _commandDistributor is IMessageDistributor;
 }
コード例 #2
0
 public CommandBus(IMessageQueueClient messageQueueClient,
                   ILinearCommandManager linearCommandManager,
                   string consumerId,
                   string replyTopicName,
                   string replySubscriptionName,
                   ConsumerConfig consumerConfig = null)
     : base(messageQueueClient)
 {
     _consumerConfig        = consumerConfig ?? ConsumerConfig.DefaultConfig;
     _consumerId            = consumerId;
     _commandStateQueues    = new ConcurrentDictionary <string, MessageState>();
     _linearCommandManager  = linearCommandManager;
     _replyTopicName        = Configuration.Instance.FormatAppName(replyTopicName);
     _replySubscriptionName = Configuration.Instance.FormatAppName(replySubscriptionName);
     // _commandQueueNames = commandQueueNames;
     _messageProcessor = new MailboxProcessor(new DefaultProcessingMessageScheduler(),
                                              new OptionsWrapper <MailboxOption>(new MailboxOption
     {
         BatchCount = _consumerConfig.MailboxProcessBatchCount
     }),
                                              ObjectProviderFactory.GetService <ILoggerFactory>().CreateLogger <MailboxProcessor>());
 }
コード例 #3
0
 public CommandBus(string name, ICommandHandlerProvider handlerProvider,
                   ILinearCommandManager linearCommandManager,
                   string brokerAddress,
                   int producerBrokerPort,
                   EQueueClientsConsumers.ConsumerSetting consumerSetting,
                   string groupName,
                   string replyTopic,
                   string commandTopic,
                   bool inProc)
     : base(name, consumerSetting, groupName, replyTopic)
 {
     CommandStateQueue    = Hashtable.Synchronized(new Hashtable());
     ToBeSentCommandQueue = new BlockingCollection <MessageContext>();
     HandlerProvider      = handlerProvider;
     LinearCommandManager = linearCommandManager;
     CommandTopic         = commandTopic;
     ReplyTopic           = replyTopic;
     InProc          = inProc;
     ProducerSetting = new EQueueClientsProducers.ProducerSetting();
     ProducerSetting.BrokerAddress = brokerAddress;
     ProducerSetting.BrokerPort    = producerBrokerPort;
     ProducerName = name;
 }
コード例 #4
0
ファイル: CommandBus.cs プロジェクト: paulrao99/IFramework
        public CommandBus(ICommandHandlerProvider handlerProvider,
                          ILinearCommandManager linearCommandManager,
                          string receiveEndPoint,
                          bool inProc,
                          string[] targetEndPoints)
            : this(handlerProvider, linearCommandManager, receiveEndPoint, inProc)
        {
            _toBeSentCommandQueue = new BlockingCollection <IMessageContext>();
            CommandSenders        = new List <ZmqSocket>();

            targetEndPoints.ForEach(targetEndPoint =>
            {
                try
                {
                    var commandSender = ZeroMessageQueue.ZmqContext.CreateSocket(SocketType.PUSH);
                    commandSender.Connect(targetEndPoint);
                    CommandSenders.Add(commandSender);
                }
                catch (Exception ex)
                {
                    _Logger.Error(ex.GetBaseException().Message, ex);
                }
            });
        }
コード例 #5
0
        public static Configuration UseCommandBus(this Configuration configuration, string consumerId, string replyTopic = "replyTopic", string replySubscription = "replySubscription", ILinearCommandManager linerCommandManager = null)
        {
            var container = IoCFactory.Instance.CurrentContainer;

            if (linerCommandManager == null)
            {
                linerCommandManager = new LinearCommandManager();
            }
            var messageQueueClient = IoCFactory.Resolve <IMessageQueueClient>();
            var commandBus         = new CommandBus(messageQueueClient, linerCommandManager, consumerId, replyTopic, replySubscription);

            container.RegisterInstance <ICommandBus>(commandBus);
            return(configuration);
        }