Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle timestamp value in response from Bridge #107

Merged
merged 2 commits into from
Aug 6, 2024

Conversation

im-konge
Copy link
Member

@im-konge im-konge commented Aug 5, 2024

After strimzi/strimzi-kafka-bridge#915 was added into Bridge, we need to handle it in our ConsumerRecord for HTTP response -> because without that, we are getting:

2024-08-01 16:24:45.758.12287383472543 �[1;31mERROR�[m HttpConsumerClient:175 - Failed to consume message due to: Unrecognized field "timestamp" (class io.strimzi.common.records.http.consumer.ConsumerRecord), not marked as ignorable (5 known properties: "value", "partition", "offset", "topic", "key"])
 at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 130] (through reference chain: java.lang.Object[][0]->io.strimzi.common.records.http.consumer.ConsumerRecord["timestamp"])
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "timestamp" (class io.strimzi.common.records.http.consumer.ConsumerRecord), not marked as ignorable (5 known properties: "value", "partition", "offset", "topic", "key"])
 at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 130] (through reference chain: java.lang.Object[][0]->io.strimzi.common.records.http.consumer.ConsumerRecord["timestamp"])
	at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:61)
	at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownProperty(DeserializationContext.java:1153)
	at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:2224)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1793)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1771)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:316)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:177)
	at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.deserialize(ObjectArrayDeserializer.java:217)
	at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.deserialize(ObjectArrayDeserializer.java:27)
	at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:342)
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4899)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3846)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3814)
	at io.strimzi.common.records.http.consumer.ConsumerRecordUtils.parseConsumerRecordsFromJson(ConsumerRecordUtils.java:22)
	at io.strimzi.http.consumer.HttpConsumerClient.consumeMessages(HttpConsumerClient.java:168)
	at io.strimzi.http.consumer.HttpConsumerClient.checkAndReceiveMessages(HttpConsumerClient.java:96)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)

@im-konge im-konge requested review from Frawless and see-quick August 5, 2024 16:18
@im-konge im-konge added this to the 0.9.0 milestone Aug 5, 2024
@im-konge im-konge requested a review from henryZrncik August 5, 2024 16:18
@im-konge im-konge self-assigned this Aug 5, 2024
@im-konge im-konge added the bug Something isn't working label Aug 5, 2024
@im-konge im-konge modified the milestones: 0.9.0, 0.9.1 Aug 5, 2024
@ppatierno
Copy link
Member

Looking at the error message, I am assuming the test is failing because producer is setting the timestamp but consumer is not able to decode it, right? Because timestamp is optional not mandatory for the bridge.

@im-konge
Copy link
Member Author

im-konge commented Aug 5, 2024

@ppatierno
From what I tested, the timestamp was there every time.
In our Kafka producer, we are not setting the timestamp:

        return new ProducerRecord(configuration.getTopicName(), null, null, configuration.getMessageKey(),
            message, configuration.getHeaders());

where the second null should be timestamp.

For Bridge producer we are not setting the timestamp neither:

String record = "{\"records\":[{\"key\":\"key-" + numOfMessage + "\",\"value\":" + message + "}]}";

Is it optional? I thought that it will be there always (but that's something I will need to test).

@ppatierno
Copy link
Member

@im-konge yeah sorry, I was stupid. Of course, on the consumer side it's always there. Even when the producer doesn't send it, the record will get the processed timestamp when it's ingested on Kafka and returned to the consumer.

Copy link
Member

@ppatierno ppatierno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@im-konge
Copy link
Member Author

im-konge commented Aug 6, 2024

@ppatierno yeah I was just testing it and I bumped into article about it. So yes, it will be there always.
Thanks for checking it :)

@im-konge im-konge merged commit d045f13 into strimzi:main Aug 6, 2024
3 checks passed
im-konge added a commit that referenced this pull request Aug 6, 2024
* Handle timestamp value in response from Bridge

Signed-off-by: Lukas Kral <[email protected]>

* fix the ConsumerRecord toString() method

Signed-off-by: Lukas Kral <[email protected]>

---------

Signed-off-by: Lukas Kral <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants