I am writing a toy project to receive wikimedia events and stream it to kafka. I use okhttp-eventsource to connect to wikimedia. But I am receiving any data. I am having a hard time debug the problem.
Here is my code. The server runs fine, but I don't see events from wikimedia.
public void sendMessage() throws InterruptedException {
String topic = "wikimedia_recent";
BackgroundEventHandler backgroundEventHandler = new WikimediaChangesHandler(kafkaTemplate, topic);
String url = "https://stream.wikimedia.org/v2/stream/recentchange";
BackgroundEventSource.Builder builder = new BackgroundEventSource.Builder(backgroundEventHandler, new EventSource.Builder(URI.create(url)));
try (BackgroundEventSource source = builder.build()) {
source.start();
System.out.println("source started");
}
TimeUnit.MINUTES.sleep(2);
}
here is my handler method that I want to see logged:
@Override
public void onMessage(String s, MessageEvent messageEvent) throws Exception {
LOGGER.info(String.format("event data -> %s", messageEvent.getData()));
kafkaTemplate.send(topic, messageEvent.getData());
}
Below is my log, but I don't receive the event data from wikimedia. Any suggestion how do I go about debugging?
2024-02-25T12:31:56.676-05:00 DEBUG 3654 --- [-stream[null]-1] okhttp3.internal.http2.Http2 : >> CONNECTION 505249202a20485454502f322e300d0a0d0a534d0d0a0d0a
2024-02-25T12:31:56.678-05:00 DEBUG 3654 --- [-stream[null]-1] okhttp3.internal.http2.Http2 : >> 0x00000000 6 SETTINGS
2024-02-25T12:31:56.679-05:00 DEBUG 3654 --- [-stream[null]-1] okhttp3.internal.http2.Http2 : >> 0x00000000 4 WINDOW_UPDATE
2024-02-25T12:31:56.680-05:00 DEBUG 3654 --- [-stream[null]-1] okhttp3.internal.concurrent.TaskRunner : Q10005 scheduled after 0 µs: OkHttp stream.wikimedia.org
2024-02-25T12:31:56.681-05:00 DEBUG 3654 --- [Http TaskRunner] okhttp3.internal.concurrent.TaskRunner : Q10005 starting : OkHttp stream.wikimedia.org
2024-02-25T12:31:56.681-05:00 DEBUG 3654 --- [-stream[null]-1] okhttp3.internal.concurrent.TaskRunner : Q10001 scheduled after 0 µs: OkHttp ConnectionPool
2024-02-25T12:31:56.681-05:00 DEBUG 3654 --- [Http TaskRunner] okhttp3.internal.concurrent.TaskRunner : Q10001 starting : OkHttp ConnectionPool
2024-02-25T12:31:56.681-05:00 DEBUG 3654 --- [ ConnectionPool] okhttp3.internal.concurrent.TaskRunner : Q10001 run again after 1 s : OkHttp ConnectionPool
2024-02-25T12:31:56.682-05:00 DEBUG 3654 --- [Http TaskRunner] okhttp3.internal.concurrent.TaskRunner : Q10001 finished run in 428 µs: OkHttp ConnectionPool
2024-02-25T12:31:56.693-05:00 DEBUG 3654 --- [-stream[null]-1] okhttp3.internal.http2.Http2 : >> 0x00000003 75 HEADERS END_STREAM|END_HEADERS
2024-02-25T12:31:56.743-05:00 DEBUG 3654 --- [m.wikimedia.org] okhttp3.internal.http2.Http2 : << 0x00000000 12 SETTINGS
2024-02-25T12:31:56.745-05:00 DEBUG 3654 --- [m.wikimedia.org] okhttp3.internal.concurrent.TaskRunner : Q10002 scheduled after 0 µs: OkHttp stream.wikimedia.org applyAndAckSettings
2024-02-25T12:31:56.745-05:00 DEBUG 3654 --- [Http TaskRunner] okhttp3.internal.concurrent.TaskRunner : Q10002 starting : OkHttp stream.wikimedia.org applyAndAckSettings
2024-02-25T12:31:56.746-05:00 DEBUG 3654 --- [yAndAckSettings] okhttp3.internal.concurrent.TaskRunner : Q10004 scheduled after 0 µs: OkHttp stream.wikimedia.org onSettings
2024-02-25T12:31:56.746-05:00 DEBUG 3654 --- [yAndAckSettings] okhttp3.internal.http2.Http2 : >> 0x00000000 0 SETTINGS ACK
2024-02-25T12:31:56.746-05:00 DEBUG 3654 --- [Http TaskRunner] okhttp3.internal.concurrent.TaskRunner : Q10004 starting : OkHttp stream.wikimedia.org onSettings
2024-02-25T12:31:56.747-05:00 DEBUG 3654 --- [Http TaskRunner] okhttp3.internal.concurrent.TaskRunner : Q10002 finished run in 1 ms: OkHttp stream.wikimedia.org applyAndAckSettings
2024-02-25T12:31:56.747-05:00 DEBUG 3654 --- [Http TaskRunner] okhttp3.internal.concurrent.TaskRunner : Q10004 finished run in 165 µs: OkHttp stream.wikimedia.org onSettings
2024-02-25T12:31:56.791-05:00 DEBUG 3654 --- [m.wikimedia.org] okhttp3.internal.http2.Http2 : << 0x00000000 0 SETTINGS ACK
2024-02-25T12:31:56.946-05:00 DEBUG 3654 --- [m.wikimedia.org] okhttp3.internal.http2.Http2 : << 0x00000003 797 HEADERS END_HEADERS
2024-02-25T12:31:56.947-05:00 DEBUG 3654 --- [m.wikimedia.org] okhttp3.internal.http2.Http2 : << 0x00000003 5 DATA
2024-02-25T12:31:57.682-05:00 DEBUG 3654 --- [Http TaskRunner] okhttp3.internal.concurrent.TaskRunner : Q10001 starting : OkHttp ConnectionPool
2024-02-25T12:31:57.682-05:00 DEBUG 3654 --- [ ConnectionPool] okhttp3.internal.concurrent.TaskRunner : Q10001 run again after 1 s : OkHttp ConnectionPool
2024-02-25T12:31:57.682-05:00 DEBUG 3654 --- [Http TaskRunner] okhttp3.internal.concurrent.TaskRunner : Q10001 finished run in 397 µs: OkHttp ConnectionPool
2024-02-25T12:31:57.972-05:00 DEBUG 3654 --- [m.wikimedia.org] okhttp3.internal.http2.Http2 : << 0x00000003 15 DATA
2024-02-25T12:31:57.973-05:00 DEBUG 3654 --- [m.wikimedia.org] okhttp3.internal.http2.Http2 : << 0x00000003 154 DATA
2024-02-25T12:31:57.974-05:00 DEBUG 3654 --- [m.wikimedia.org] okhttp3.internal.http2.Http2 : << 0x00000003 1287 DATA
2024-02-25T12:31:57.974-05:00 DEBUG 3654 --- [m.wikimedia.org] okhttp3.internal.http2.Http2 : << 0x00000003 15 DATA
2024-02-25T12:31:57.975-05:00 DEBUG 3654 --- [m.wikimedia.org] okhttp3.internal.http2.Http2
Move
TimeUnit.MINUTES.sleep(2);inside thetryblock: