question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Funqy unable to get event data

See original GitHub issue

Describe the bug

I’m using import io.quarkus.funqy.Funq to create a Serverless function for use with Knative and a Knative Kafka Source. The Funq processes JSON objects.

When I send a request via HTTP POST it works as expected. Example cURL:

curl -X POST -H "Content-Type: application/json; charset=utf-8" -H "ce-id: 03ce2ea0-c3a7-499c-8edd-ac4e31c6536a" -H "ce-type: shots" -H "ce-source: localhost" -H "ce-specversion: 1.0" -d @ce.body.json $URL_ENDPOINT

When the Kafka Source sends the data to the same Funq this error is printed. Could it be that some header is not set correctly by the Kafka source HTTP request?

ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-0) HTTP Request to / failed, error id: 03b90aeb-11c9-41cd-8e01-b9407e83d38f-6: java.lang.RuntimeException: Don't know how to get event data (dataContentType: 'null', javaType: 'functions.Shot').
	at io.quarkus.funqy.runtime.bindings.knative.events.HeaderCloudEventImpl.data(HeaderCloudEventImpl.java:185)
	at io.quarkus.funqy.runtime.bindings.knative.events.VertxRequestHandler.lambda$processCloudEvent$5(VertxRequestHandler.java:232)
	at io.quarkus.vertx.core.runtime.VertxCoreRecorder$13.runWith(VertxCoreRecorder.java:543)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
	at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
	at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:829)

What makes this issue more interesting is that it only started occurring after I updated from Quarkus version 1.8.1.Final to version 2.2.3.Final. The issue is also happening with the latest Quarkus release. If I use Quarkus 1.8.1.Final the Funq is able to deserialise the incoming JSON event, but then I lose access to the CloudEventBuilder.

Expected behavior

Events sent from Kafka Source should be correctly deserialised and processed by my Funq.

Actual behavior

The stack trace above is printed.

How to Reproduce?

  1. Obtain an OpenShift/Kube cluster with Serverless/Knative installed.
  2. Enable Eventing and Serving per the docs, making sure to enable the KafkaSource option for Eventing.

Deploy a Knative function:

  1. kn func create -l quarkus
  2. kn func build
  3. kn service create my-service --image $IMAGE_FROM_BUILD

Create a Kafka Source that sinks events to my-service. Pod logs for my-service show the stack trace above.

Output of uname -a or ver

Darwin MacBook-Pro 20.6.0 Darwin Kernel Version 20.6.0

Output of java -version

AdoptOpenJDK-11.0.11

GraalVM version (if different from Java)

N/A

Quarkus version or git rev

2.2.3

Build tool (ie. output of mvnw --version or gradlew --version)

Knative Version: v0.25.1

Additional information

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:35 (33 by maintainers)

github_iconTop GitHub Comments

1reaction
evanshortisscommented, Jan 11, 2022

@matejvasek yes, that header in the Kafka payload does the trick.

@lance I agree with this. It’s a downstream issue, and Quarkus 2.x is taking the right approach by not making an assumption. Perhaps the error message could be improved and the Kafka Source doc could be improved?

1reaction
lancecommented, Jan 11, 2022

@patriot1burke the proper thing to do here, in my opinion, is to make no assumptions about content type. If the CloudEvent has a datacontenttype attribute, obviously, that should be used, but if there is no content-type header and no ce-datacontenttype header for the CE code to parse, then the CE data should simply be a byte[].

Read more comments on GitHub >

github_iconTop Results From Across the Web

Funqy Google Cloud Functions - Quarkus
Create an application with the quarkus-funqy-google-cloud-functions extension. ... getType()); System.out.println("Receive event Data: " + new ...
Read more >
Developing Quarkus functions - OpenShift Documentation
Both http and event trigger functions have the same template structure: Template structure ... Funq; import io.quarkus.funqy.knative.events.
Read more >
Getting Started With Quarkus Serverless Functions - DZone
It also allows developers to decouple binding between event producers and consumers for efficient serverless architectures. Quarkus funqy extensions enable ...
Read more >
Using Knative Quarkus Bench to Perform Serverless ... - IBM
The combination of Quarkus Funqy and IBM Cloud Code Engine is a refreshingly ... get -n <APPLICATIONNAME>; ibmcloud ce application events -n ...
Read more >
Quarkus Funqy Amazon Lambda - YouTube
Your browser can't play this video. ... Quarkus Funqy Amazon Lambda ... SQS Using JAVA - Send, Receive And Delete data. CodeSpace. CodeSpace....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found