jbang/variables-eip/myapp.camel.yaml (38 lines of code) (raw):
# camel-k: language=yaml
# Write your routes here, for example:
- from:
uri: "timer:beers"
parameters:
period: "5000"
steps:
- to:
uri: "https://random-data-api.com/api/v2/beers"
variableReceive: beer1
- to:
uri: "https://random-data-api.com/api/v2/beers"
variableReceive: beer2
- setVariable:
name: alc1
expression:
jq:
expression: .alcohol | rtrimstr("%")
source: beer1
resultType: float
- setVariable:
name: alc2
expression:
jq:
expression: .alcohol | rtrimstr("%")
source: beer2
resultType: float
- choice:
when:
- id: choice
expression:
simple:
expression: ${variable.alc1} > ${variable.alc2}
steps:
- log:
message: 'Beer battle: ${jq(variable:beer1,.name)} (${variable.alc1}%) is stronger than ${jq(variable:beer2,.name)} (${variable.alc2}%)'
otherwise:
steps:
- log:
message: 'Beer battle: ${jq(variable:beer1,.name)} (${variable.alc1}%) is weaker than ${jq(variable:beer2,.name)} (${variable.alc2}%)'