You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by kl...@apache.org on 2022/06/16 21:09:05 UTC
[camel-examples] branch main updated: CAMEL-18132: fix spring-pulsar example to work with Camel 3.17 Modify TypeConverters int to byte[] for compatbilty with new bulk converter handling byte[] to int
This is an automated email from the ASF dual-hosted git repository.
klease pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-examples.git
The following commit(s) were added to refs/heads/main by this push:
new 3059a62d CAMEL-18132: fix spring-pulsar example to work with Camel 3.17 Modify TypeConverters int to byte[] for compatbilty with new bulk converter handling byte[] to int
3059a62d is described below
commit 3059a62da6a1596ac92481403d3091a8c07e78d3
Author: klease <kl...@cegetel.net>
AuthorDate: Thu Jun 16 23:06:39 2022 +0200
CAMEL-18132: fix spring-pulsar example to work with Camel 3.17
Modify TypeConverters int to byte[] for compatbilty with new bulk
converter handling byte[] to int
---
.../org/apache/camel/example/pulsar/common/TypeConverters.java | 8 ++++++--
.../src/main/resources/META-INF/spring/camel-server.xml | 2 +-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/examples/spring-pulsar/src/main/java/org/apache/camel/example/pulsar/common/TypeConverters.java b/examples/spring-pulsar/src/main/java/org/apache/camel/example/pulsar/common/TypeConverters.java
index cf945736..995262c0 100644
--- a/examples/spring-pulsar/src/main/java/org/apache/camel/example/pulsar/common/TypeConverters.java
+++ b/examples/spring-pulsar/src/main/java/org/apache/camel/example/pulsar/common/TypeConverters.java
@@ -22,14 +22,18 @@ import org.apache.camel.Converter;
public class TypeConverters implements org.apache.camel.TypeConverters {
- @Converter
+ // In Camel 3.17 and later, this will not be called because overridden by
+ // built-in Bulk Converter which handles byte array to Integer conversion
+ // by first converting the byte array to a String
+ // @Converter
public int intFromByteArray(byte[] bytes) {
return ByteBuffer.wrap(bytes).getInt();
}
@Converter
public byte[] intToByteArray(Integer value) {
- return ByteBuffer.allocate(4).putInt(value).array();
+ // Write it as a string since that is how Bulk Converter will handle it
+ return value.toString().getBytes();
}
}
diff --git a/examples/spring-pulsar/src/main/resources/META-INF/spring/camel-server.xml b/examples/spring-pulsar/src/main/resources/META-INF/spring/camel-server.xml
index 47a7f30b..93772e11 100644
--- a/examples/spring-pulsar/src/main/resources/META-INF/spring/camel-server.xml
+++ b/examples/spring-pulsar/src/main/resources/META-INF/spring/camel-server.xml
@@ -29,7 +29,7 @@
<import resource="classpath:camel-common.xml"/>
<!-- declare a camel context that scans for classes that is RouteBuilder
in the package org.apache.camel.example.server -->
- <camel:camelContext id="camel-server">
+ <camel:camelContext id="camel-server" typeConverterExists="Override">
<camel:package>org.apache.camel.example.pulsar.server</camel:package>
<!-- enable JMX connector so we can connect to the server and browse mbeans -->
<!-- Camel will log at INFO level the service URI to use for connecting with jconsole -->