You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2019/05/28 03:02:33 UTC
[GitHub] [pulsar] tuteng commented on issue #4370: Implement Flume Source
with Event driven source instead
tuteng commented on issue #4370: Implement Flume Source with Event driven source instead
URL: https://github.com/apache/pulsar/issues/4370#issuecomment-496347899
Using event-driven is a better way.
However, in the current environment, sink of pulsar is a wrapper for the consumer. In the interface sink, the write method does not return a value and needs a place to temporarily store the received message. Therefore, a buffer queue-like component is needed here.
I think it is simpler to use consumer components directly, similar to the following code:
```
private Event extractEvent() {
...
while (!doneReading) {
Message msg = consumer.receive();
}
e = EventBuilder.withBody(msg.toByteArray(), headers);
return e;
}
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent mEvent) {
Event e = extractEvent();
getChannelProcessor().processEvent(e);
counterGroup.incrementAndGet("events.success");
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services