public void Cancel(SendMessageCommand cmd)
 {
     lock (syncRoot)
     {
         Pair<SendMessageCommand, SettableFuture<bool>> pair = null;
         commands.TryRemove(cmd.Header.CorrelationId, out pair);
     }
 }
 public IFuture<bool> Monitor(SendMessageCommand command)
 {
     lock (syncRoot)
     {
         SettableFuture<bool> future = SettableFuture<bool>.Create();
         commands[command.Header.CorrelationId] = new Pair<SendMessageCommand, SettableFuture<bool>>(command, future);
         return future;
     }
 }
        private void Tracking(SendMessageCommand sendMessageCommand, bool success)
        {

            string status = success ? CatConstants.SUCCESS : "Timeout";

            foreach (List<ProducerMessage> msgs in sendMessageCommand.ProducerMessages)
            {
                foreach (ProducerMessage msg in msgs)
                {
                    ITransaction t = Cat.NewTransaction("Message.Produce.Acked", msg.Topic);
                    IMessageTree tree = Cat.GetThreadLocalMessageTree();

                    String msgId = msg.GetDurableSysProperty(CatConstants.SERVER_MESSAGE_ID);
                    String parentMsgId = msg.GetDurableSysProperty(CatConstants.CURRENT_MESSAGE_ID);
                    String rootMsgId = msg.GetDurableSysProperty(CatConstants.ROOT_MESSAGE_ID);

                    tree.MessageId = msgId;
                    tree.ParentMessageId = parentMsgId;
                    tree.RootMessageId = rootMsgId;

                    ITransaction elapseT = Cat.NewTransaction("Message.Produce.Elapse", msg.Topic);
                    if (elapseT is DefaultTransaction)
                    {
                        // cat needs local mill of ticks
                        ((DefaultTransaction)elapseT).Timestamp = (ticksOfLocalMinusUtc + TimeExtension.UnixTimestampToTicks(msg.BornTime)) / TimeSpan.TicksPerMillisecond;
                        elapseT.AddData("command.message.count", sendMessageCommand.MessageCount);
                    }
                    elapseT.Status = status;
                    elapseT.Complete();

                    t.Status = status;
                    t.Complete();
                }

            }
        }