Skip to content

Commit 47ec399

Browse files
committed
Sql aggregator does not work in native mode, solve DefaultExchangeHolder globally.
1 parent 3ce5294 commit 47ec399

File tree

5 files changed

+89
-2
lines changed

5 files changed

+89
-2
lines changed

docs/modules/ROOT/pages/reference/extensions/sql.adoc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,41 @@ Or add the coordinates to your existing project:
4040

4141
Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
4242

43+
== Usage
44+
45+
If you are using SQL Aggregator in native mode, you have to register several classes for serialization using GraalVM feature.
46+
Serialization support since GraalVM 21.0 allows developers to configure classes for serialization via the serialization
47+
configuration file `-H:SerializationConfigurationResources=/path-to/serialization-config.json` option. For more information
48+
see https://github.com/oracle/graal/pull/2730[pull request with feature].
49+
50+
Several classes has to be registered for serialization every time to make SQL Aggregator work in native.
51+
Here is a template of `serialization-config.json` with all mandatory classes:
52+
53+
```
54+
[
55+
{
56+
"name" : "java.lang.Integer"
57+
},
58+
{
59+
"name" : "java.lang.Number"
60+
},
61+
{
62+
"name" : "java.lang.String"
63+
},
64+
{
65+
"name" : "java.util.HashMap"
66+
},
67+
{
68+
"name" : "java.util.LinkedHashMap"
69+
},
70+
{
71+
"name" : "org.apache.camel.support.DefaultExchangeHolder"
72+
}
73+
]
74+
```
75+
76+
77+
4378
== Additional Camel Quarkus configuration
4479

4580
=== Configuring a DataSource
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
If you are using SQL Aggregator in native mode, you have to register several classes for serialization using GraalVM feature.
2+
Serialization support since GraalVM 21.0 allows developers to configure classes for serialization via the serialization
3+
configuration file `-H:SerializationConfigurationResources=/path-to/serialization-config.json` option. For more information
4+
see https://github.com/oracle/graal/pull/2730[pull request with feature].
5+
6+
Several classes has to be registered for serialization every time to make SQL Aggregator work in native.
7+
Here is a template of `serialization-config.json` with all mandatory classes:
8+
9+
```
10+
[
11+
{
12+
"name" : "java.lang.Integer"
13+
},
14+
{
15+
"name" : "java.lang.Number"
16+
},
17+
{
18+
"name" : "java.lang.String"
19+
},
20+
{
21+
"name" : "java.util.HashMap"
22+
},
23+
{
24+
"name" : "java.util.LinkedHashMap"
25+
},
26+
{
27+
"name" : "org.apache.camel.support.DefaultExchangeHolder"
28+
}
29+
]
30+
```
31+

integration-tests/sql/src/main/resources/application.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@
1818
# Camel Quarkus SQL
1919
#
2020
quarkus.camel.sql.script-files=sql/get-camels.sql,sql/initDb.sql,sql/selectProjects.sql
21+
22+
#Serialization-config.json is a workaround until serilazation support makes it into Quarkus (see https://github.com/quarkusio/quarkus/pull/15380)
23+
quarkus.native.additional-build-args=-H:SerializationConfigurationResources=serialization-config.json
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[
2+
{
3+
"name" : "java.lang.Integer"
4+
},
5+
{
6+
"name" : "java.lang.Number"
7+
},
8+
{
9+
"name" : "java.lang.String"
10+
},
11+
{
12+
"name" : "java.util.HashMap"
13+
},
14+
{
15+
"name" : "java.util.LinkedHashMap"
16+
},
17+
{
18+
"name" : "org.apache.camel.support.DefaultExchangeHolder"
19+
}
20+
]

integration-tests/sql/src/test/java/org/apache/camel/quarkus/component/sql/it/SqlTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import io.restassured.specification.RequestSpecification;
2828
import org.apache.camel.component.sql.SqlConstants;
2929
import org.apache.camel.util.CollectionHelper;
30-
import org.junit.jupiter.api.Disabled;
3130
import org.junit.jupiter.api.Test;
3231

3332
import static io.restassured.RestAssured.given;
@@ -189,7 +188,6 @@ public void testIdempotentRepository() {
189188
}
190189

191190
@Test
192-
@Disabled //see https://github.com/apache/camel-quarkus/issues/2693
193191
public void testAggregationRepository() {
194192
postMapWithParam("/sql/toDirect/aggregation", "body", "A", CollectionHelper.mapOf("messageId", "123"))
195193
.statusCode(200);

0 commit comments

Comments
 (0)