コード例 #1
0
 protected override void ToBytes0(IoBuffer buf)
 {
     HermesPrimitiveCodec codec = new HermesPrimitiveCodec(buf);
     codec.WriteString(Topic);
     codec.WriteInt(Partition);
     codec.WriteString(GroupId);
 }
コード例 #2
0
        protected override void  ToBytes0(IoBuffer buf)
        {
            var codec = new HermesPrimitiveCodec(buf);

            codec.WriteInt(PullType);
            codec.WriteString(Topic);
            codec.WriteInt(Partition);
            codec.WriteString(GroupId);
            codec.WriteOffset(Offset);
            codec.WriteInt(Size);
            codec.WriteLong(ExpireTime);
        }
コード例 #3
0
        private void writeMsgSeqMap(HermesPrimitiveCodec codec,
                                    ConcurrentDictionary<Triple<Tpp, String, Boolean>, List<AckContext>> msgSeqMap)
        {
            if (msgSeqMap == null)
            {
                codec.WriteInt(0);
            }
            else
            {
                codec.WriteInt(msgSeqMap.Count);
                foreach (Triple<Tpp, String, Boolean> tppgr in msgSeqMap.Keys)
                {
                    Tpp tpp = tppgr.First;
                    codec.WriteString(tpp.Topic);
                    codec.WriteInt(tpp.Partition);
                    codec.WriteInt(tpp.Priority ? 0 : 1);
                    codec.WriteString(tppgr.Middle);
                    codec.WriteBoolean(tppgr.Last);
                }
                foreach (Triple<Tpp, String, Boolean> tppgr in msgSeqMap.Keys)
                {
                    List<AckContext> contexts = msgSeqMap[tppgr];

                    if (contexts == null || contexts.Count == 0)
                    {
                        codec.WriteInt(0);
                    }
                    else
                    {
                        codec.WriteInt(contexts.Count);
                        foreach (AckContext context in contexts)
                        {
                            codec.WriteLong(context.MsgSeq);
                            codec.WriteInt(context.RemainingRetries);
                            codec.WriteLong(context.OnMessageStartTimeMillis);
                            codec.WriteLong(context.OnMessageEndTimeMillis);
                        }
                    }
                }
            }

        }
コード例 #4
0
 protected override void ToBytes0(IoBuffer buf)
 {
     var codec = new HermesPrimitiveCodec(buf);
     codec.WriteInt(msgCounter.ReadFullFence());
     codec.WriteString(Topic);
     codec.WriteInt(Partition);
     WriteDatas(buf, codec, messages);
 }
コード例 #5
0
        private void Encode(ProducerMessage message, IoBuffer buf, byte[] body, string codecType)
        {
            var codec = new HermesPrimitiveCodec(buf);
            var indexBeginning = buf.Position;
            codec.WriteInt(-1); // placeholder for whole length
            var indexAfterWholeLen = buf.Position;
            codec.WriteInt(-1); // placeholder for header length
            codec.WriteInt(-1); // placeholder for body length
            var indexBeforeHeader = buf.Position;

            // header begin
            codec.WriteString(message.Key);
            codec.WriteLong(message.BornTime);
            codec.WriteInt(0); //remaining retries
            codec.WriteString(codecType);

            var propertiesHolder = message.PropertiesHolder;
            WriteProperties(propertiesHolder.DurableProperties, buf, codec);
            WriteProperties(propertiesHolder.VolatileProperties, buf, codec);
            // header end

            var headerLen = buf.Position - indexBeforeHeader;

            //body begin
            var indexBeforeBody = buf.Position;
            buf.Put(body);
            var bodyLen = buf.Position - indexBeforeBody;
            //body end

            //crc
            codec.WriteLong(ChecksumUtil.Crc32(buf.GetSlice(indexBeforeHeader, headerLen + bodyLen)));
            var indexEnd = buf.Position;

            var wholeLen = indexEnd - indexAfterWholeLen;

            // refill whole length
            buf.Position = indexBeginning;
            codec.WriteInt(wholeLen);

            // refill header length
            codec.WriteInt(headerLen);

            // refill body length
            codec.WriteInt(bodyLen);

            buf.Position = indexEnd;
        }