This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 08809746418 CAMEL-21974: camel-j8583: ISO-8583 data format
08809746418 is described below
commit 08809746418237d3daa3b7f702070764e064e693
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Jul 21 07:58:09 2025 +0200
CAMEL-21974: camel-j8583: ISO-8583 data format
---
.../src/main/docs/iso8583-dataformat.adoc | 19 ++++++
.../iso8583/Iso8583DataFormatGroovyTest.java | 68 ++++++++++++++++++++++
2 files changed, 87 insertions(+)
diff --git a/components/camel-iso8583/src/main/docs/iso8583-dataformat.adoc
b/components/camel-iso8583/src/main/docs/iso8583-dataformat.adoc
index 3cc400ff9af..6f7e3f17cb2 100644
--- a/components/camel-iso8583/src/main/docs/iso8583-dataformat.adoc
+++ b/components/camel-iso8583/src/main/docs/iso8583-dataformat.adoc
@@ -88,6 +88,25 @@ from("jms:payment:response")
.to("direct:payementResponse");
----
+Instead of simple language you can also use Groovy which has a special support
in J8583 library:
+
+[source,java]
+----
+from("jms:payment:response")
+ .unmarshal().iso8583("0210")
+ .transform().groovy(
+ """
+ [
+ "op": body[3].value,
+ "amount": body[4].value,
+ "ref": body[37].value,
+ "response": body[39].value,
+ "terminal": body[41].value,
+ "currency": body[49].value
+ ]
+ """)
+ .to("direct:payementResponse");
+----
== More Information
diff --git
a/components/camel-iso8583/src/test/java/org/apache/camel/dataformat/iso8583/Iso8583DataFormatGroovyTest.java
b/components/camel-iso8583/src/test/java/org/apache/camel/dataformat/iso8583/Iso8583DataFormatGroovyTest.java
new file mode 100644
index 00000000000..0d2275821cb
--- /dev/null
+++
b/components/camel-iso8583/src/test/java/org/apache/camel/dataformat/iso8583/Iso8583DataFormatGroovyTest.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dataformat.iso8583;
+
+import java.io.File;
+import java.util.Map;
+
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+public class Iso8583DataFormatGroovyTest extends CamelTestSupport {
+
+ @Test
+ public void testUnmarshal() throws Exception {
+ getMockEndpoint("mock:result").expectedMessageCount(1);
+
getMockEndpoint("mock:result").message(0).body().isInstanceOf(Map.class);
+
getMockEndpoint("mock:result").message(0).body().simple("${body[op]}").isEqualTo("650000");
+
getMockEndpoint("mock:result").message(0).body().simple("${body[amount]}").isEqualTo("30.00");
+
getMockEndpoint("mock:result").message(0).body().simple("${body[ref]}").isEqualTo("001234425791");
+
getMockEndpoint("mock:result").message(0).body().simple("${body[response]}").isEqualTo("00");
+
getMockEndpoint("mock:result").message(0).body().simple("${body[terminal]}").isEqualTo("614209027600TéST");
+
getMockEndpoint("mock:result").message(0).body().simple("${body[currency]}").isEqualTo("484");
+
+ template.sendBody("direct:unmarshal", new
File("src/test/resources/parse1.txt"));
+
+ MockEndpoint.assertIsSatisfied(context);
+ }
+
+ @Override
+ protected RoutesBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:unmarshal").unmarshal().iso8583("0210")
+ .transform().groovy(
+ """
+ [
+ "op": body[3].value,
+ "amount": body[4].value,
+ "ref": body[37].value,
+ "response": body[39].value,
+ "terminal": body[41].value,
+ "currency": body[49].value
+ ]
+ """)
+ .log("${body}")
+ .to("mock:result");
+ }
+ };
+ }
+}