---
apiVersion: v1
kind: ConfigMap
metadata:
  labels:
    funktion.fabric8.io/kind: Connector
  name: jt400
data:
  deployment.yml: |
    ---
    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      labels:
        funktion.fabric8.io/kind: Subscription
        connector: jt400
    spec:
      replicas: 1
      template:
        metadata:
          labels:
            funktion.fabric8.io/kind: Subscription
            connector: jt400
        spec:
          containers:
          - image: funktion/connector-jt400:${project.version}
            name: connector
  schema.yml: |
    ---
    component:
      kind: component
      scheme: jt400
      syntax: jt400:userID:password/systemName/objectPath.type
      title: JT400
      description: The jt400 component allows you to exchanges messages with an AS/400 system using data queues or program call.
      label: messaging
      deprecated: false
      async: false
      javaType: org.apache.camel.component.jt400.Jt400Component
      groupId: org.apache.camel
      artifactId: camel-jt400
      version: 2.18.3
    componentProperties:
      connectionPool:
        kind: property
        type: object
        javaType: com.ibm.as400.access.AS400ConnectionPool
        deprecated: false
        secret: false
        description: Returns the default connection pool used by this component.
        order: 0
    properties:
      userID:
        kind: path
        group: common
        required: true
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: Returns the ID of the AS/400 user.
        order: 0
      password:
        kind: path
        group: common
        required: true
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: Returns the password of the AS/400 user.
        order: 1
      systemName:
        kind: path
        group: common
        required: true
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: Returns the name of the AS/400 system.
        order: 2
      objectPath:
        kind: path
        group: common
        required: true
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: Returns the fully qualified integrated file system path name of the target object of this endpoint.
        order: 3
      type:
        kind: path
        group: common
        required: true
        type: string
        javaType: org.apache.camel.component.jt400.Jt400Type
        enum:
        - DTAQ
        - PGM
        deprecated: false
        secret: false
        description: Whether to work with data queues or remote program call
        order: 4
      ccsid:
        kind: parameter
        group: common
        type: integer
        javaType: int
        deprecated: false
        secret: false
        description: Sets the CCSID to use for the connection with the AS/400 system.
        order: 5
      format:
        kind: parameter
        group: common
        type: object
        javaType: org.apache.camel.component.jt400.Jt400Configuration.Format
        deprecated: false
        secret: false
        defaultValue: text
        description: Sets the data format for sending messages.
        order: 6
      guiAvailable:
        kind: parameter
        group: common
        type: boolean
        javaType: boolean
        deprecated: false
        secret: false
        defaultValue: false
        description: Sets whether AS/400 prompting is enabled in the environment running Camel.
        order: 7
      keyed:
        kind: parameter
        group: common
        type: boolean
        javaType: boolean
        deprecated: false
        secret: false
        defaultValue: false
        description: Whether to use keyed or non-keyed data queues.
        order: 8
      outputFieldsIdxArray:
        kind: parameter
        group: common
        type: object
        javaType: java.lang.Integer[]
        deprecated: false
        secret: false
        description: Specifies which fields (program parameters) are output parameters.
        order: 9
      outputFieldsLengthArray:
        kind: parameter
        group: common
        type: object
        javaType: java.lang.Integer[]
        deprecated: false
        secret: false
        description: Specifies the fields (program parameters) length as in the AS/400 program definition.
        order: 10
      searchKey:
        kind: parameter
        group: common
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: Search key for keyed data queues.
        order: 11
      searchType:
        kind: parameter
        group: common
        type: object
        javaType: org.apache.camel.component.jt400.Jt400Configuration.SearchType
        deprecated: false
        secret: false
        defaultValue: EQ
        description: Search type such as EQ for equal etc.
        order: 12
      secured:
        kind: parameter
        group: common
        type: boolean
        javaType: boolean
        deprecated: false
        secret: false
        defaultValue: false
        description: Whether connections to AS/400 are secured with SSL.
        order: 13
      bridgeErrorHandler:
        kind: parameter
        group: consumer
        label: consumer
        type: boolean
        javaType: boolean
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        defaultValue: false
        description: Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN/ERROR level and ignored.
        order: 14
      readTimeout:
        kind: parameter
        group: consumer
        label: consumer
        type: integer
        javaType: int
        deprecated: false
        secret: false
        defaultValue: "30000"
        description: Timeout in millis the consumer will wait while trying to read a new message of the data queue.
        order: 15
      sendEmptyMessageWhenIdle:
        kind: parameter
        group: consumer
        label: consumer
        type: boolean
        javaType: boolean
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        defaultValue: false
        description: If the polling consumer did not poll any files you can enable this option to send an empty message (no body) instead.
        order: 16
      exceptionHandler:
        kind: parameter
        group: consumer (advanced)
        label: consumer,advanced
        type: object
        javaType: org.apache.camel.spi.ExceptionHandler
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        description: To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR level and ignored.
        order: 17
      exchangePattern:
        kind: parameter
        group: consumer (advanced)
        label: consumer,advanced
        type: string
        javaType: org.apache.camel.ExchangePattern
        enum:
        - InOnly
        - RobustInOnly
        - InOut
        - InOptionalOut
        - OutOnly
        - RobustOutOnly
        - OutIn
        - OutOptionalIn
        deprecated: false
        secret: false
        description: Sets the exchange pattern when the consumer creates an exchange.
        order: 18
      pollStrategy:
        kind: parameter
        group: consumer (advanced)
        label: consumer,advanced
        type: object
        javaType: org.apache.camel.spi.PollingConsumerPollStrategy
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        description: A pluggable org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your custom implementation to control error handling usually occurred during the poll operation before an Exchange have been created and being routed in Camel.
        order: 19
      synchronous:
        kind: parameter
        group: advanced
        label: advanced
        type: boolean
        javaType: boolean
        deprecated: false
        secret: false
        defaultValue: false
        description: Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).
        order: 20
      backoffErrorThreshold:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: integer
        javaType: int
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        description: The number of subsequent error polls (failed due some error) that should happen before the backoffMultipler should kick-in.
        order: 21
      backoffIdleThreshold:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: integer
        javaType: int
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        description: The number of subsequent idle polls that should happen before the backoffMultipler should kick-in.
        order: 22
      backoffMultiplier:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: integer
        javaType: int
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        description: To let the scheduled polling consumer backoff if there has been a number of subsequent idles/errors in a row. The multiplier is then the number of polls that will be skipped before the next actual attempt is happening again. When this option is in use then backoffIdleThreshold and/or backoffErrorThreshold must also be configured.
        order: 23
      delay:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: integer
        javaType: long
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        defaultValue: "500"
        description: Milliseconds before the next poll. You can also specify time values using units such as 60s (60 seconds) 5m30s (5 minutes and 30 seconds) and 1h (1 hour).
        order: 24
      greedy:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: boolean
        javaType: boolean
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        defaultValue: false
        description: If greedy is enabled then the ScheduledPollConsumer will run immediately again if the previous run polled 1 or more messages.
        order: 25
      initialDelay:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: integer
        javaType: long
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        defaultValue: "1000"
        description: Milliseconds before the first poll starts. You can also specify time values using units such as 60s (60 seconds) 5m30s (5 minutes and 30 seconds) and 1h (1 hour).
        order: 26
      runLoggingLevel:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: string
        javaType: org.apache.camel.LoggingLevel
        enum:
        - TRACE
        - DEBUG
        - INFO
        - WARN
        - ERROR
        - OFF
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        defaultValue: TRACE
        description: The consumer logs a start/complete log line when it polls. This option allows you to configure the logging level for that.
        order: 27
      scheduledExecutorService:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: object
        javaType: java.util.concurrent.ScheduledExecutorService
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        description: Allows for configuring a custom/shared thread pool to use for the consumer. By default each consumer has its own single threaded thread pool.
        order: 28
      scheduler:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: string
        javaType: org.apache.camel.spi.ScheduledPollConsumerScheduler
        enum:
        - none
        - spring
        - quartz2
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        defaultValue: none
        description: To use a cron scheduler from either camel-spring or camel-quartz2 component
        order: 29
      schedulerProperties:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: object
        javaType: java.util.Map<java.lang.String,java.lang.Object>
        prefix: scheduler.
        multiValue: true
        deprecated: false
        secret: false
        description: To configure additional properties when using a custom scheduler or any of the Quartz2 Spring based scheduler.
        order: 30
      startScheduler:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: boolean
        javaType: boolean
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        defaultValue: true
        description: Whether the scheduler should be auto started.
        order: 31
      timeUnit:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: string
        javaType: java.util.concurrent.TimeUnit
        enum:
        - NANOSECONDS
        - MICROSECONDS
        - MILLISECONDS
        - SECONDS
        - MINUTES
        - HOURS
        - DAYS
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        defaultValue: MILLISECONDS
        description: Time unit for initialDelay and delay options.
        order: 32
      useFixedDelay:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: boolean
        javaType: boolean
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        defaultValue: true
        description: Controls if fixed delay or fixed rate is used. See ScheduledExecutorService in JDK for details.
        order: 33
  documentation.adoc: |+
    [[JT400-JT400Component]]
    JT/400 Component
    ~~~~~~~~~~~~~~~~

    The *`jt400`* component allows you to exchanges messages with an AS/400
    system using data queues.

    Maven users will need to add the following dependency to their `pom.xml`
    for this component:

    [source,xml]
    ------------------------------------------------------------
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-jt400</artifactId>
        <version>x.x.x</version>
        <!-- use the same version as your Camel core version -->
    </dependency>
    ------------------------------------------------------------

    [[JT400-URIformat]]
    URI format
    ^^^^^^^^^^

    [source,java]
    ----------------------------------------------------------------------
    jt400://user:password@system/QSYS.LIB/LIBRARY.LIB/QUEUE.DTAQ[?options]
    ----------------------------------------------------------------------

    To call remote program (*Camel 2.7*)

    [source,java]
    -----------------------------------------------------------------------
    jt400://user:password@system/QSYS.LIB/LIBRARY.LIB/program.PGM[?options]
    -----------------------------------------------------------------------

    You can append query options to the URI in the following format,
    `?option=value&option=value&...`

    [[JT400-options]]
    JT400 options
    ^^^^^^^^^^^^^

    // component options: START
    The JT400 component supports 1 options which are listed below.



    {% raw %}
    [width="100%",cols="2,1m,7",options="header"]
    |=======================================================================
    | Name | Java Type | Description
    | connectionPool | AS400ConnectionPool | Returns the default connection pool used by this component.
    |=======================================================================
    {% endraw %}
    // component options: END


    // endpoint options: START
    The JT400 component supports 34 endpoint options which are listed below:

    {% raw %}
    [width="100%",cols="2,1,1m,1m,5",options="header"]
    |=======================================================================
    | Name | Group | Default | Java Type | Description
    | userID | common |  | String | *Required* Returns the ID of the AS/400 user.
    | password | common |  | String | *Required* Returns the password of the AS/400 user.
    | systemName | common |  | String | *Required* Returns the name of the AS/400 system.
    | objectPath | common |  | String | *Required* Returns the fully qualified integrated file system path name of the target object of this endpoint.
    | type | common |  | Jt400Type | *Required* Whether to work with data queues or remote program call
    | ccsid | common |  | int | Sets the CCSID to use for the connection with the AS/400 system.
    | format | common | text | Format | Sets the data format for sending messages.
    | guiAvailable | common | false | boolean | Sets whether AS/400 prompting is enabled in the environment running Camel.
    | keyed | common | false | boolean | Whether to use keyed or non-keyed data queues.
    | outputFieldsIdxArray | common |  | Integer[] | Specifies which fields (program parameters) are output parameters.
    | outputFieldsLengthArray | common |  | Integer[] | Specifies the fields (program parameters) length as in the AS/400 program definition.
    | searchKey | common |  | String | Search key for keyed data queues.
    | searchType | common | EQ | SearchType | Search type such as EQ for equal etc.
    | secured | common | false | boolean | Whether connections to AS/400 are secured with SSL.
    | bridgeErrorHandler | consumer | false | boolean | Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN/ERROR level and ignored.
    | readTimeout | consumer | 30000 | int | Timeout in millis the consumer will wait while trying to read a new message of the data queue.
    | sendEmptyMessageWhenIdle | consumer | false | boolean | If the polling consumer did not poll any files you can enable this option to send an empty message (no body) instead.
    | exceptionHandler | consumer (advanced) |  | ExceptionHandler | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR level and ignored.
    | exchangePattern | consumer (advanced) |  | ExchangePattern | Sets the exchange pattern when the consumer creates an exchange.
    | pollStrategy | consumer (advanced) |  | PollingConsumerPollStrategy | A pluggable org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your custom implementation to control error handling usually occurred during the poll operation before an Exchange have been created and being routed in Camel.
    | synchronous | advanced | false | boolean | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).
    | backoffErrorThreshold | scheduler |  | int | The number of subsequent error polls (failed due some error) that should happen before the backoffMultipler should kick-in.
    | backoffIdleThreshold | scheduler |  | int | The number of subsequent idle polls that should happen before the backoffMultipler should kick-in.
    | backoffMultiplier | scheduler |  | int | To let the scheduled polling consumer backoff if there has been a number of subsequent idles/errors in a row. The multiplier is then the number of polls that will be skipped before the next actual attempt is happening again. When this option is in use then backoffIdleThreshold and/or backoffErrorThreshold must also be configured.
    | delay | scheduler | 500 | long | Milliseconds before the next poll. You can also specify time values using units such as 60s (60 seconds) 5m30s (5 minutes and 30 seconds) and 1h (1 hour).
    | greedy | scheduler | false | boolean | If greedy is enabled then the ScheduledPollConsumer will run immediately again if the previous run polled 1 or more messages.
    | initialDelay | scheduler | 1000 | long | Milliseconds before the first poll starts. You can also specify time values using units such as 60s (60 seconds) 5m30s (5 minutes and 30 seconds) and 1h (1 hour).
    | runLoggingLevel | scheduler | TRACE | LoggingLevel | The consumer logs a start/complete log line when it polls. This option allows you to configure the logging level for that.
    | scheduledExecutorService | scheduler |  | ScheduledExecutorService | Allows for configuring a custom/shared thread pool to use for the consumer. By default each consumer has its own single threaded thread pool.
    | scheduler | scheduler | none | ScheduledPollConsumerScheduler | To use a cron scheduler from either camel-spring or camel-quartz2 component
    | schedulerProperties | scheduler |  | Map | To configure additional properties when using a custom scheduler or any of the Quartz2 Spring based scheduler.
    | startScheduler | scheduler | true | boolean | Whether the scheduler should be auto started.
    | timeUnit | scheduler | MILLISECONDS | TimeUnit | Time unit for initialDelay and delay options.
    | useFixedDelay | scheduler | true | boolean | Controls if fixed delay or fixed rate is used. See ScheduledExecutorService in JDK for details.
    |=======================================================================
    {% endraw %}
    // endpoint options: END


    [[JT400-Usage]]
    Usage
    ^^^^^

    When configured as a consumer endpoint, the endpoint will poll a data
    queue on a remote system. For every entry on the data queue, a new
    `Exchange` is sent with the entry's data in the _In_ message's body,
    formatted either as a `String` or a `byte[]`, depending on the format.
    For a provider endpoint, the _In_ message body contents will be put on
    the data queue as either raw bytes or text.

    [[JT400-Connectionpool]]
    Connection pool
    ^^^^^^^^^^^^^^^

    *Available as of Camel 2.10*

    Connection pooling is in use from Camel 2.10 onwards. You can explicit
    configure a connection pool on the Jt400Component, or as an uri option
    on the endpoint.

    [[JT400-Remoteprogramcall]]
    Remote program call (*Camel 2.7*)
    +++++++++++++++++++++++++++++++++

    This endpoint expects the input to be either a String array or byte[]
    array (depending on format) and handles all the CCSID handling through
    the native jt400 library mechanisms. A parameter can be _omitted_ by
    passing null as the value in its position (the remote program has to
    support it). After the program execution the endpoint returns either a
    String array or byte[] array with the values as they were returned by
    the program (the input only parameters will contain the same data as the
    beginning of the invocation). This endpoint does not implement a provider endpoint!

    [[JT400-Example]]
    Example
    ^^^^^^^

    In the snippet below, the data for an exchange sent to the
    `direct:george` endpoint will be put in the data queue `PENNYLANE` in
    library `BEATLES` on a system named `LIVERPOOL`.  +
     Another user connects to the same data queue to receive the information
    from the data queue and forward it to the `mock:ringo` endpoint.

    [source,java]
    -------------------------------------------------------------------------------------------------------
    public class Jt400RouteBuilder extends RouteBuilder {
        @Override
        public void configure() throws Exception {
           from("direct:george").to("jt400://GEORGE:EGROEG@LIVERPOOL/QSYS.LIB/BEATLES.LIB/PENNYLANE.DTAQ");
           from("jt400://RINGO:OGNIR@LIVERPOOL/QSYS.LIB/BEATLES.LIB/PENNYLANE.DTAQ").to("mock:ringo");
        }
    }
    -------------------------------------------------------------------------------------------------------

    [[JT400-Remoteprogramcallexample]]
    Remote program call example (*Camel 2.7*)
    +++++++++++++++++++++++++++++++++++++++++

    In the snippet below, the data Exchange sent to the direct:work endpoint
    will contain three string that will be used as the arguments for the
    program “compute” in the library “assets”. This program will write the
    output values in the 2nd and 3rd parameters. All the parameters will be
    sent to the direct:play endpoint.

    [source,java]
    ---------------------------------------------------------------------------------------------------------------------------------------------------------
    public class Jt400RouteBuilder extends RouteBuilder {
        @Override
        public void configure() throws Exception {
           from("direct:work").to("jt400://GRUPO:ATWORK@server/QSYS.LIB/assets.LIB/compute.PGM?fieldsLength=10,10,512&ouputFieldsIdx=2,3").to(“direct:play”);
        }
    }
    ---------------------------------------------------------------------------------------------------------------------------------------------------------

    [[JT400-Writingtokeyeddataqueues]]
    Writing to keyed data queues
    ++++++++++++++++++++++++++++

    [source,java]
    ------------------------------------------------------------------------
    from("jms:queue:input")
    .to("jt400://username:password@system/lib.lib/MSGINDQ.DTAQ?keyed=true");
    ------------------------------------------------------------------------

    [[JT400-Readingfromkeyeddataqueues]]
    Reading from keyed data queues
    ++++++++++++++++++++++++++++++

    [source,java]
    -------------------------------------------------------------------------------------------------------
    from("jt400://username:password@system/lib.lib/MSGOUTDQ.DTAQ?keyed=true&searchKey=MYKEY&searchType=GE")
    .to("jms:queue:output");
    -------------------------------------------------------------------------------------------------------

    [[JT400-SeeAlso]]
    See Also
    ^^^^^^^^

    * link:configuring-camel.html[Configuring Camel]
    * link:component.html[Component]
    * link:endpoint.html[Endpoint]
    * link:getting-started.html[Getting Started]

