Exemplo n.º 1
0
 @Override
 public boolean runCmd(String[] args) throws Exception {
   if (args.length < 4) {
     return false;
   }
   long lastConsumedId = 0;
   SubscriptionData subData =
       admin.getSubscription(ByteString.copyFromUtf8(args[1]), ByteString.copyFromUtf8(args[2]));
   if (null == subData) {
     System.err.println(
         "Failed to read subscription for topic: " + args[1] + " subscriber: " + args[2]);
     return true;
   }
   lastConsumedId = subData.getState().getMsgId().getLocalComponent();
   long numMessagesToConsume = Long.parseLong(args[3]);
   long idToConsumed = lastConsumedId + numMessagesToConsume;
   System.out.println(
       "Try to move subscriber("
           + args[2]
           + ") consume ptr of topic("
           + args[1]
           + ") from "
           + lastConsumedId
           + " to "
           + idToConsumed);
   MessageSeqId consumeId = MessageSeqId.newBuilder().setLocalComponent(idToConsumed).build();
   ByteString topic = ByteString.copyFromUtf8(args[1]);
   ByteString subId = ByteString.copyFromUtf8(args[2]);
   try {
     subscriber.consume(topic, subId, consumeId);
   } catch (Exception e) {
     System.err.println("CONSUME FAILED");
   }
   return true;
 }
Exemplo n.º 2
0
 @Override
 public boolean runCmd(String[] args) throws Exception {
   if (args.length < 2) {
     return false;
   }
   ReadTopic rt;
   ByteString topic = ByteString.copyFromUtf8(args[1]);
   if (args.length == 2) {
     rt = new ReadTopic(admin, topic, inConsole);
   } else {
     rt = new ReadTopic(admin, topic, Long.parseLong(args[2]), inConsole);
   }
   rt.readTopic();
   return true;
 }
Exemplo n.º 3
0
 @Override
 public boolean runCmd(String[] args) throws Exception {
   if (args.length < 4) {
     return false;
   }
   ByteString topic = ByteString.copyFromUtf8(args[1]);
   ByteString subId = ByteString.copyFromUtf8(args[2]);
   long msgId = Long.parseLong(args[3]);
   MessageSeqId consumeId = MessageSeqId.newBuilder().setLocalComponent(msgId).build();
   try {
     subscriber.consume(topic, subId, consumeId);
   } catch (Exception e) {
     System.err.println("CONSUMETO FAILED");
   }
   return true;
 }