apiVersion: camel.apache.org/v1
kind: Integration
metadata:
  name: phi-test-0-10
spec:
  traits:
    mount:
      configs:
        - configmap:phi-common-config
        - configmap:phi-activemq-config
        - secret:phi-activemq-secret
      volumes:
        - phi-pvc-0-01:/share
  dependencies:
    # Camel-K doesn't take it from routes
    - camel:beanio
    - mvn:io.phi.tests.camel.k:phi-camel-k-test-01-c:1.0.0-SNAPSHOT
    - mvn:io.phi.tests.camel.k:phi-camel-k-test-01-d:1.0.0-SNAPSHOT
  configuration:
    - type: property
      value: camel.context.name=PHI.0.10
    - type: property
      value: phi.flow.code=flow10
  flows:
    - beans:
        - name: phiCamelSetup
          type: io.phi.tests.camel.k.t01.c.MyCamelSetup
          constructors:
            0: "{{phi.entity.code}}"
    - route:
        id: "phi:incoming"
        from:
          uri: "file:/share/{{phi.flow.code}}/input"
          parameters:
            preSort: true
            recursive: true
            doneFileName: "${file:name}.done"
            move: "../archived/${date:now:yyyy-MM-dd}/${file:name}_${date:now:yyyy-MM-dd_HH-mm-ss-SSS}"
            moveFailed: "../failed/${date:now:yyyy-MM-dd}/${file:name}_${date:now:yyyy-MM-dd_HH-mm-ss-SSS}"
          steps:
            - log: "Incoming file '${file:name}' [length=${file:length}]'"
            - to:
                uri: "direct:processing"
    - route:
        id: "phi:replay"
        from:
          uri: "amqp:queue:{{phi.flow.code}}.{{phi.entity.code}}.replay?exchangePattern=InOnly"
          steps:
            - log: "Replay : '${body}'"
            - to:
                uri: "direct:processing"
    - route:
        id: "phi:processing"
        from:
          uri: "direct:processing"
          steps:
            - unmarshal:
                beanio:
                  mapping: io/phi/tests/camel/k/t01/d/phi-flow-x.mapping.xml
                  streamName: flow-x
                  encoding: UTF-8
            - process:
                ref: phiWrappingProcessor
            - log: "Processing gives object : ${body}"
            - marshal:
                json:
                  library: Jackson
                  objectMapper: "#phiJacksonObjectMapper"
            - log: "Processed : ${body}"
            - to:
                uri: "amqp:queue:{{phi.flow.code}}.{{phi.entity.code}}.incoming?exchangePattern=InOnly"