Skip to content

Commit 74585b5

Browse files
authored
[improve][cli] CmdConsume print publishTime And eventTime info. (#22308)
Co-authored-by: atomchchen <atomchchen@tencent.com>
1 parent 71598c1 commit 74585b5

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/AbstractCmdConsume.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ protected String interpretMessage(Message<?> message, boolean displayHex) throws
108108
data = value.toString();
109109
}
110110

111+
sb.append("publishTime:[").append(message.getPublishTime()).append("], ");
112+
sb.append("eventTime:[").append(message.getEventTime()).append("], ");
113+
111114
String key = null;
112115
if (message.hasKey()) {
113116
key = message.getKey();

tests/integration/src/test/java/org/apache/pulsar/tests/integration/cli/ClientToolTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,14 @@ private List<String> consume(ChaosContainer<?> container, String url, String top
8686
+ "\nError output:\n" + result.getStderr());
8787
}
8888
String output = result.getStdout();
89-
Pattern message = Pattern.compile("----- got message -----\nkey:\\[null\\], properties:\\[\\], content:(.*)");
89+
Pattern message = Pattern.compile(
90+
"----- got message -----\npublishTime:\\[(.*)\\], eventTime:\\[(.*)\\], key:\\[null\\], "
91+
+ "properties:\\[\\], content:(.*)");
9092
Matcher matcher = message.matcher(output);
9193
List<String> received = new ArrayList<>(MESSAGE_COUNT);
9294
while (matcher.find()) {
93-
received.add(matcher.group(1));
95+
received.add(matcher.group(3));
9496
}
9597
return received;
9698
}
97-
9899
}

0 commit comments

Comments
 (0)