-
Story
-
Resolution: Done
-
Normal
-
None
-
None
-
None
-
False
-
-
False
-
-
-
-
0
By using "extract-field-action", user can extract a message field from a json data format data. But the extracted String data is surrounded by double quotes. There is a needs to trim that kinds of characters from the extracted field.
Simple reproducer and tested it with camel-jbang.
sample.yaml
#!/usr/bin/env jbang camel@apache/camel run apiVersion: camel.apache.org/v1alpha1 kind: KameletBinding metadata: name: sample spec: source: ref: kind: Kamelet apiVersion: camel.apache.org/v1alpha1 name: timer-source properties: period: 5000 contentType: application/json message: '{"id":"1","field":"hello","message":"Camel Rocks"}' steps: - ref: kind: Kamelet apiVersion: camel.apache.org/v1alpha1 name: extract-field-action properties: field: "field" sink: ref: kind: Kamelet apiVersion: camel.apache.org/v1 name: log-sink properties: show-headers: false
console // use jbang
]$ camel run sample.yaml 2023-03-16 10:06:41.944 INFO 25077 --- [ main] org.apache.camel.main.MainSupport : Apache Camel (JBang) 3.20.2 is starting 2023-03-16 10:06:42.286 INFO 25077 --- [ main] org.apache.camel.main.MainSupport : Using Java 17.0.2 with PID 25077. Started by hfuruich in /home/hfuruich/cases/03462407 2023-03-16 10:06:42.300 INFO 25077 --- [ main] mel.cli.connector.LocalCliConnector : Camel CLI enabled (local) 2023-03-16 10:06:43.815 INFO 25077 --- [ main] el.impl.engine.AbstractCamelContext : Apache Camel 3.20.2 (sample) is starting 2023-03-16 10:06:44.024 INFO 25077 --- [ main] g.apache.camel.main.BaseMainSupport : Property-placeholders summary 2023-03-16 10:06:44.025 INFO 25077 --- [ main] g.apache.camel.main.BaseMainSupport : [timer-source.kamelet.yaml] period=5000 2023-03-16 10:06:44.025 INFO 25077 --- [ main] g.apache.camel.main.BaseMainSupport : [timer-source.kamelet.yaml] message={"id":"1","field":"hello","message":"Camel Rocks"} 2023-03-16 10:06:44.025 INFO 25077 --- [ main] g.apache.camel.main.BaseMainSupport : [timer-source.kamelet.yaml] contentType=application/json 2023-03-16 10:06:44.025 INFO 25077 --- [ main] g.apache.camel.main.BaseMainSupport : [ct-field-action.kamelet.yaml] extractField=extractField-1 2023-03-16 10:06:44.025 INFO 25077 --- [ main] g.apache.camel.main.BaseMainSupport : [ct-field-action.kamelet.yaml] field=field 2023-03-16 10:06:44.039 INFO 25077 --- [ main] el.impl.engine.AbstractCamelContext : Routes startup (started:4) 2023-03-16 10:06:44.039 INFO 25077 --- [ main] el.impl.engine.AbstractCamelContext : Started sample (kamelet://timer-source) 2023-03-16 10:06:44.039 INFO 25077 --- [ main] el.impl.engine.AbstractCamelContext : Started timer-source-1 (timer://tick) 2023-03-16 10:06:44.040 INFO 25077 --- [ main] el.impl.engine.AbstractCamelContext : Started log-sink-2 (kamelet://source) 2023-03-16 10:06:44.040 INFO 25077 --- [ main] el.impl.engine.AbstractCamelContext : Started extract-field-action-3 (kamelet://source) 2023-03-16 10:06:44.040 INFO 25077 --- [ main] el.impl.engine.AbstractCamelContext : Apache Camel 3.20.2 (sample) started in 1s355ms (build:82ms init:1s49ms start:224ms JVM-uptime:2s) 2023-03-16 10:06:45.071 INFO 25077 --- [ - timer://tick] log-sink : Exchange[ExchangePattern: InOnly, BodyType: org.apache.camel.converter.stream.InputStreamCache, Body: "hello"] 2023-03-16 10:06:50.032 INFO 25077 --- [ - timer://tick] log-sink : Exchange[ExchangePattern: InOnly, BodyType: org.apache.camel.converter.stream.InputStreamCache, Body: "hello"]
Expected data: hello
Actual data: "hello"
1.
|
Development - Trimming extracted String data capability by "extract-field-action" | Closed | Unassigned | ||
2.
|
Productization - Trimming extracted String data capability by "extract-field-action" | Closed | Unassigned | ||
3.
|
Review Test - Trimming extracted String data capability by "extract-field-action" | Closed | Unassigned | ||
4.
|
Documentation - Trimming extracted String data capability by "extract-field-action" | Closed | Unassigned |