コード例 #1
0
 public async Task <Pong> HandleAsync(Ping request, IPipelineContext <Ping, Pong> pipelineContext, CancellationToken cancellationToken)
 {
     if (string.IsNullOrWhiteSpace(request.Message))
     {
         throw new InvalidOperationException("Message can't be null or empty!");
     }
     return(await pipelineContext.Next(request, cancellationToken));
 }
コード例 #2
0
        public async Task <Pong> HandleAsync(Ping request, IPipelineContext <Ping, Pong> pipelineContext, CancellationToken cancellationToken)
        {
            _logger.WriteLine("--Begin handle Ping request");
            var result = await pipelineContext.Next(request, cancellationToken);

            _logger.WriteLine("--End handle Ping request");

            return(result);
        }
コード例 #3
0
        public void Handle(IPipelineContext ctx, Object payload)
        {
            var msg = (ProducerMessage)payload;
            var topic = msg.Topic;
            if (string.IsNullOrEmpty(topic))
            {
                log.Error("Topic not set, won't send");
                return;
            }

            enrichPartitionKey(msg, Local.IPV4);
            enrichRefKey(msg);
            enrichMessageProperties(msg, Local.IPV4);

            ctx.Next(payload);
        }
コード例 #4
0
		public void Handle (IPipelineContext context, object payload)
		{
            var msg = payload as ProducerMessage;
            var topic = msg.Topic;
            var t = Cat.NewTransaction("Message.Produce.Tried", topic);
            t.AddData("key", msg.Key);

            var tree = Cat.GetThreadLocalMessageTree();
            try
            {
                

                var childMsgId = Cat.CreateMessageId();
                var rootMsgId = tree.RootMessageId;
                String msgId = Cat.GetThreadLocalMessageTree().MessageId;
                rootMsgId = rootMsgId == null ? msgId : rootMsgId;
                Cat.LogEvent("Message:" + topic, "Produced:" + Local.IPV4, CatConstants.SUCCESS, "key=" + msg.Key);
                Cat.LogEvent("Producer:" + Local.IPV4, topic, CatConstants.SUCCESS, "key=" + msg.Key);

                msg.AddDurableSysProperty(CatConstants.CURRENT_MESSAGE_ID, msgId);
                msg.AddDurableSysProperty(CatConstants.SERVER_MESSAGE_ID, childMsgId);
                msg.AddDurableSysProperty(CatConstants.ROOT_MESSAGE_ID, rootMsgId);
                Cat.LogEvent(CatConstants.TYPE_REMOTE_CALL, "", CatConstants.SUCCESS, childMsgId);

                context.Next(payload);

                t.Status = CatConstants.SUCCESS; 
            }
            catch (Exception ex)
            {
                Cat.LogError(ex);
                t.SetStatus(ex);
            }
            finally
            {
                t.Complete();
            }
		}