Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public class RocketMQSink extends RichSinkFunction<Message> implements Checkpoin
private boolean batchFlushOnCheckpoint; // false by default
private int batchSize = 32;
private List<Message> batchList;
private long batchMessageSize;

private Meter sinkInTps;
private Meter outTps;
Expand Down Expand Up @@ -112,6 +113,7 @@ public void invoke(Message input, Context context) throws Exception {

if (batchFlushOnCheckpoint) {
batchList.add(input);
batchMessageSize += input.getBody().length;
if (batchList.size() >= batchSize) {
flushSync();
}
Expand Down Expand Up @@ -220,8 +222,13 @@ private void flushSync() throws Exception {
if (batchFlushOnCheckpoint) {
synchronized (batchList) {
if (batchList.size() > 0) {
long startSinkTime = System.currentTimeMillis();
producer.send(batchList);
latencyGauge.report(System.currentTimeMillis() - startSinkTime, 1);
outTps.markEvent();
outBps.markEvent(batchMessageSize);
batchList.clear();
batchMessageSize = 0;
}
}
}
Expand Down