예제 #1
0
        /// <summary>
        /// 接收消息
        /// </summary>
        /// <param name="msg"></param>
        public static void Subscribe(Message msg, IProcessMessage ipro)
        {
            //// 创建消息bus
            //using (IBus bus = BusBuilder.CreateMessageBus())
            //{
            //    try
            //    {
            //        bus.Subscribe<Message>(msg.MessageRouter, message => ipro.ProcessMsg(message), x => x.WithTopic(msg.MessageRouter));
            //    }
            //    catch (EasyNetQException ex)
            //    {
            //        //处理连接消息服务器异常
            //    }

            //}

            //// 创建消息bus
            IBus bus = BusBuilder.CreateMessageBus();

            try
            {
                bus.Subscribe <Message>(msg.MessageRouter, message => ipro.ProcessMsg(message), x => x.WithTopic(msg.MessageRouter));
            }
            catch (EasyNetQException ex)
            {
                //处理连接消息服务器异常
            }
        }
예제 #2
0
 public ProcessEventHubParallelized(TelemetryConfiguration configuration,
                                    ILogger <ProcessEventHubParallelized> log,
                                    IProcessMessage processMessage)
 {
     _clientTMetry   = new TelemetryClient(configuration);
     _logger         = log;
     _processMessage = processMessage;
 }
예제 #3
0
 public ProcessEventHubTriggerGeneratedByDefault(TelemetryConfiguration configuration,
                                                 ILogger <ProcessEventHubTriggerGeneratedByDefault> log,
                                                 IProcessMessage processMessage)
 {
     _clientTMetry   = new TelemetryClient(configuration);
     _logger         = log;
     _processMessage = processMessage;
 }
예제 #4
0
        public ProcessingServiceTests()
        {
            LogManager.OutputToTrace();
            _storage = Substitute.For<IStoreUnhandledMessages>();
            _processor = Substitute.For<IProcessMessage>();
            _errors = Substitute.For<IFailedMessagesQueue>();

            _sut =new ProcessingService(_storage,()=>_processor,new BusAuditor(new InMemoryAuditStorage()), _errors);
            _sut.PollingEnabled = false;
            _sut.Start();
        }
예제 #5
0
        public ProcessingServiceTests()
        {
            //LogManager.OutputToTrace();
            _storage   = Substitute.For <IStoreUnhandledMessages>();
            _processor = Substitute.For <IProcessMessage>();
            _errors    = Substitute.For <IFailedMessagesQueue>();

            _sut = new ProcessingService(_storage, () => _processor, new BusAuditor(new InMemoryAuditStorage()), _errors);
            _sut.PollingEnabled = false;
            _sut.Start();
        }
        public ClientSubscription(IConfiguration configuration, IProcessMessage processData)
        {
            this.configuration = configuration;
            //subscriptionClient = new SubscriptionClient(
            //    configuration.GetConnectionString("ServiceBusConnectionString"),
            //    TOPIC_PATH,
            //  SUBSCRIPTION_NAME);
            _processData = processData;
            // _processData = new MessageConsumer();

            topicSubscription = new ServiceBusTopicSubscription(processData, configuration);// busTopicSubscription;
            //handler = ProcessMessageAsync;
        }
예제 #7
0
        /// <summary>
        /// 异步接受消息
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="ipro"></param>
        public static void SubscribeAsync(Message msg, IProcessMessage ipro)
        {
            IBus bus = BusBuilder.CreateMessage();

            try
            {
                bus.SubscribeAsync <Message>(msg.MessageRouter, m => ipro.ProcessMsgAsync(m));
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #8
0
        //private readonly ILogger _logger;

        public ServiceBusTopicSubscription(IProcessMessage processData,
                                           IConfiguration configuration
                                           //ILogger<ServiceBusTopicSubscription> logger
                                           )
        {
            _processData   = processData;
            _configuration = configuration;
            //_logger = logger;

            _subscriptionClient = new SubscriptionClient(
                _configuration.GetConnectionString("ServiceBusConnectionString"),
                TOPIC_PATH,
                SUBSCRIPTION_NAME);
        }
예제 #9
0
        /// <summary>
        /// 接收消息
        /// </summary>
        /// <param name="msg"></param>
        public static void Subscribe(BaseMessage msg, IProcessMessage ipro)
        {
            //// 创建消息bus
            IBus bus = BusBuilder.CreateMessageBus();

            try
            {
                bus.Subscribe <BaseMessage>(msg.MessageRouter, message => ipro.ProcessMsg(message), x => x.WithTopic(msg.MessageRouter));
            }
            catch (EasyNetQException ex)
            {
                throw ex;
            }
        }
예제 #10
0
        //public static void PublishFanout(Message msg)
        //{
        //    var bus = BusBuilder.CreateMessage();
        //    try
        //    {
        //        if (bus.IsConnected)
        //        {
        //            var exchange=bus.
        //        }
        //    }
        //    catch (Exception e)
        //    {

        //        throw;
        //    }
        //}

        /// <summary>
        /// 接受消息
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="ipro"></param>
        public static void Subscribe(Message msg, IProcessMessage ipro)
        {
            //创建消息Bus
            IBus bus = BusBuilder.CreateMessage();

            try
            {
                bus.Subscribe <Message>(msg.MessageRouter, m => ipro.ProcessMsg(m), x => x.WithTopic(msg.MessageRouter));
            }
            catch (Exception)
            {
                //错误消息处理
            }
        }
예제 #11
0
파일: MQHelper.cs 프로젝트: nilyang/wisex
        /// <summary>
        /// 接收消息
        /// </summary>
        /// <param name="msg"></param>
        public static void Subscribe(Message msg, IProcessMessage ipro)
        {
            //// 创建消息bus
            IBus bus = BusBuilder.CreateMessageBus();

            try
            {
                bus.Subscribe <Message>(msg.MessageID, message => ipro.ProcessMsg(message), x => x.WithTopic(msg.MessageRouter).WithArgument("x-ha-policy", "all"));
            }
            catch (EasyNetQException)
            {
                //处理连接消息服务器异常
                //  MessageHelper.WriteFuntionExceptionLog("Subscribe", ex.Message + " | " + ex.StackTrace);
            }
        }
 private void CreateShareMemoryMessage(bool read)
 {
     if (read)
     {
         if (readMessage == null)
         {
             readMessage = new MemoryMessage(processKey, read);
             readMessage.AcceptMessage += OnMessage;
         }
     }
     else
     {
         if (sendMessage == null)
         {
             sendMessage = new MemoryMessage(processKey, read);
         }
     }
 }
 private void CreateNamedPipeMessage(bool read)
 {
     if (read)
     {
         if (readMessage == null)
         {
             readMessage = new NamedPipeMessage(processKey, read);
             readMessage.AcceptMessage += OnMessage;
         }
     }
     else
     {
         if (sendMessage == null)
         {
             sendMessage = new NamedPipeMessage(processKey, read);
         }
     }
 }
예제 #14
0
 /// <summary>
 /// Renvois la liste des types de message traiter par la classe de l'objet
 /// </summary>
 /// <param name="Target"></param>
 /// <param name="typeOfMsg"></param>
 /// <returns></returns>
 static public List <Type> GetProcessedMessages(this IProcessMessage Target, Type typeOfMsg = null)
 {
     return(((object)Target).GetProcessedMessages(typeOfMsg));
 }
예제 #15
0
 /// <summary>
 /// Envois le message TMSG à un objet qui support l'interface IProcessMessage<TMSG>.
 /// C'est a dire qu'il dispose d'une methode OnReceiveMessage(TMSG)
 /// </summary>
 static public void SendMessage <TMSG>(this IProcessMessage <TMSG> objTarget, TMSG msg)
     where TMSG : IMessage
 {
     objTarget.OnReceiveMessage(msg);
 }
 public MessageHandler(IProcessMessage <T> messageProcessor)
 {
     this.messageProcessor = messageProcessor;
 }
예제 #17
0
    public string ProcessRequest(string action, string message)
    {
        IProcessMessage processor = MessageProcessorFactory.Instance.GetProcessor(action);

        return(processor.ProcessMessage(message));
    }
 /// <summary>
 /// 停止
 /// </summary>
 public void Stop()
 {
     readMessage = null;
     sendMessage = null;
 }
예제 #19
0
 public BankInteligentBot(IGreetingMessage greetingMessage,
                          IProcessMessage processMessage)
 {
     this.greetingMessage = greetingMessage;
     this.processMessage  = processMessage;
 }
예제 #20
0
 //装饰者模式必须要传入上一个装饰者对象,如果没有则传null ,这里是IProcessMessage
 public ProcessMessageDecorator(IProcessMessage <TMessageBase> messageProcessor, ProcessMessageLockHandler distributedLockHandler)
 {
     _messageProcessor       = messageProcessor;
     _distributedLockHandler = distributedLockHandler;
 }
예제 #21
0
파일: Functions.cs 프로젝트: tzkwizard/ELS
 // This function will get triggered/executed when a new message is written 
 // on an Azure Queue called queue.
 static Functions()
 {
     var iDbService = new DbService();
     var iQueueService=new QueueService();
     _iProcessMessage = new ProcessMessage.ProcessMessage(iDbService, iQueueService);
 }
예제 #22
0
 public ValiateData(IValidate validate, IProcessMessage processor)
 {
     this.validator = validate;
     //this.processor = processor;
 }