---
apiVersion: v1
kind: ConfigMap
metadata:
  labels:
    funktion.fabric8.io/kind: Connector
  name: stream
data:
  deployment.yml: |
    ---
    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      labels:
        funktion.fabric8.io/kind: Subscription
        connector: stream
    spec:
      replicas: 1
      template:
        metadata:
          labels:
            funktion.fabric8.io/kind: Subscription
            connector: stream
        spec:
          containers:
          - image: funktion/connector-stream:${project.version}
            name: connector
  schema.yml: |
    ---
    component:
      kind: component
      scheme: stream
      syntax: stream:kind
      title: Stream
      description: 'The stream: component provides access to the system-in system-out
        and system-err streams as well as allowing streaming of file and URL.'
      label: file,system
      deprecated: false
      async: false
      javaType: org.apache.camel.component.stream.StreamComponent
      groupId: org.apache.camel
      artifactId: camel-stream
      version: 2.18.3
    componentProperties: {}
    properties:
      kind:
        kind: path
        group: common
        required: true
        type: string
        javaType: java.lang.String
        enum:
        - in
        - out
        - err
        - header
        - file
        - url
        deprecated: false
        secret: false
        description: Kind of stream to use such as System.in or System.out.
        order: 0
      encoding:
        kind: parameter
        group: common
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: You can configure the encoding (is a charset name) to use text-based streams (for example message body is a String object). If not provided Camel uses the JVM default Charset.
        order: 1
      fileName:
        kind: parameter
        group: common
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: When using the stream:file URI format this option specifies the filename to stream to/from.
        order: 2
      url:
        kind: parameter
        group: common
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: When using the stream:url URI format this option specifies the URL to stream to/from. The input/output stream will be opened using the JDK URLConnection facility.
        order: 3
      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: 4
      groupLines:
        kind: parameter
        group: consumer
        label: consumer
        type: integer
        javaType: int
        deprecated: false
        secret: false
        description: To group X number of lines in the consumer. For example to group 10 lines and therefore only spit out an Exchange with 10 lines instead of 1 Exchange per line.
        order: 5
      groupStrategy:
        kind: parameter
        group: consumer
        label: consumer
        type: object
        javaType: org.apache.camel.component.stream.GroupStrategy
        deprecated: false
        secret: false
        description: Allows to use a custom GroupStrategy to control how to group lines.
        order: 6
      initialPromptDelay:
        kind: parameter
        group: consumer
        label: consumer
        type: integer
        javaType: long
        deprecated: false
        secret: false
        defaultValue: "2000"
        description: Initial delay in milliseconds before showing the message prompt. This delay occurs only once. Can be used during system startup to avoid message prompts being written while other logging is done to the system out.
        order: 7
      promptDelay:
        kind: parameter
        group: consumer
        label: consumer
        type: integer
        javaType: long
        deprecated: false
        secret: false
        description: Optional delay in milliseconds before showing the message prompt.
        order: 8
      promptMessage:
        kind: parameter
        group: consumer
        label: consumer
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: 'Message prompt to use when reading from stream:in; for example you
          could set this to Enter a command:'
        order: 9
      retry:
        kind: parameter
        group: consumer
        label: consumer
        type: boolean
        javaType: boolean
        deprecated: false
        secret: false
        defaultValue: false
        description: Will retry opening the file if it's overwritten somewhat like tail --retry
        order: 10
      scanStream:
        kind: parameter
        group: consumer
        label: consumer
        type: boolean
        javaType: boolean
        deprecated: false
        secret: false
        defaultValue: false
        description: To be used for continuously reading a stream such as the unix tail command.
        order: 11
      scanStreamDelay:
        kind: parameter
        group: consumer
        label: consumer
        type: integer
        javaType: long
        deprecated: false
        secret: false
        description: Delay in milliseconds between read attempts when using scanStream.
        order: 12
      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: 13
      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: 14
      autoCloseCount:
        kind: parameter
        group: producer
        label: producer
        type: integer
        javaType: int
        deprecated: false
        secret: false
        description: Number of messages to process before closing stream on Producer side. Never close stream by default (only when Producer is stopped). If more messages are sent the stream is reopened for another autoCloseCount batch.
        order: 15
      closeOnDone:
        kind: parameter
        group: producer
        label: producer
        type: boolean
        javaType: boolean
        deprecated: false
        secret: false
        defaultValue: false
        description: This option is used in combination with Splitter and streaming to the same file. The idea is to keep the stream open and only close when the Splitter is done to improve performance. Mind this requires that you only stream to the same file and not 2 or more files.
        order: 16
      delay:
        kind: parameter
        group: producer
        label: producer
        type: integer
        javaType: long
        deprecated: false
        secret: false
        description: Initial delay in milliseconds before producing the stream.
        order: 17
      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: 18
  documentation.adoc: |+
    [[Stream-StreamComponent]]
    Stream Component
    ~~~~~~~~~~~~~~~~

    The *stream:* component provides access to the `System.in`, `System.out`
    and `System.err` streams as well as allowing streaming of file and URL.

    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-stream</artifactId>
        <version>x.x.x</version>
        <!-- use the same version as your Camel core version -->
    </dependency>
    ------------------------------------------------------------

    [[Stream-URIformat]]
    URI format
    ^^^^^^^^^^

    [source,java]
    -----------------------
    stream:in[?options]
    stream:out[?options]
    stream:err[?options]
    stream:header[?options]
    -----------------------

    In addition, the `file` and `url` endpoint URIs are supported:

    [source,java]
    ---------------------------------
    stream:file?fileName=/foo/bar.txt
    stream:url[?options]
    ---------------------------------

    If the `stream:header` URI is specified, the `stream` header is used to
    find the stream to write to. This option is available only for stream
    producers (that is, it cannot appear in `from()`).

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

    [[Stream-Options]]
    Options
    ^^^^^^^


    // component options: START
    The Stream component has no options.
    // component options: END



    // endpoint options: START
    The Stream component supports 19 endpoint options which are listed below:

    {% raw %}
    [width="100%",cols="2,1,1m,1m,5",options="header"]
    |=======================================================================
    | Name | Group | Default | Java Type | Description
    | kind | common |  | String | *Required* Kind of stream to use such as System.in or System.out.
    | encoding | common |  | String | You can configure the encoding (is a charset name) to use text-based streams (for example message body is a String object). If not provided Camel uses the JVM default Charset.
    | fileName | common |  | String | When using the stream:file URI format this option specifies the filename to stream to/from.
    | url | common |  | String | When using the stream:url URI format this option specifies the URL to stream to/from. The input/output stream will be opened using the JDK URLConnection facility.
    | 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.
    | groupLines | consumer |  | int | To group X number of lines in the consumer. For example to group 10 lines and therefore only spit out an Exchange with 10 lines instead of 1 Exchange per line.
    | groupStrategy | consumer |  | GroupStrategy | Allows to use a custom GroupStrategy to control how to group lines.
    | initialPromptDelay | consumer | 2000 | long | Initial delay in milliseconds before showing the message prompt. This delay occurs only once. Can be used during system startup to avoid message prompts being written while other logging is done to the system out.
    | promptDelay | consumer |  | long | Optional delay in milliseconds before showing the message prompt.
    | promptMessage | consumer |  | String | Message prompt to use when reading from stream:in; for example you could set this to Enter a command:
    | retry | consumer | false | boolean | Will retry opening the file if it's overwritten somewhat like tail --retry
    | scanStream | consumer | false | boolean | To be used for continuously reading a stream such as the unix tail command.
    | scanStreamDelay | consumer |  | long | Delay in milliseconds between read attempts when using scanStream.
    | 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.
    | autoCloseCount | producer |  | int | Number of messages to process before closing stream on Producer side. Never close stream by default (only when Producer is stopped). If more messages are sent the stream is reopened for another autoCloseCount batch.
    | closeOnDone | producer | false | boolean | This option is used in combination with Splitter and streaming to the same file. The idea is to keep the stream open and only close when the Splitter is done to improve performance. Mind this requires that you only stream to the same file and not 2 or more files.
    | delay | producer |  | long | Initial delay in milliseconds before producing the stream.
    | synchronous | advanced | false | boolean | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).
    |=======================================================================
    {% endraw %}
    // endpoint options: END


    [[Stream-Messagecontent]]
    Message content
    ^^^^^^^^^^^^^^^

    The *stream:* component supports either `String` or `byte[]` for writing
    to streams. Just add either `String` or `byte[]` content to the
    `message.in.body`. Messages sent to the *stream:* producer in binary
    mode are not followed by the newline character (as opposed to the
    `String` messages). Message with `null` body will not be appended to the
    output stream. +
     The special `stream:header` URI is used for custom output streams. Just
    add a `java.io.OutputStream` object to `message.in.header` in the key
    `header`. +
     See samples for an example.

    [[Stream-Samples]]
    Samples
    ^^^^^^^

    In the following sample we route messages from the `direct:in` endpoint
    to the `System.out` stream:

    [source,java]
    ---------------------------------------------------------------
    // Route messages to the standard output.
    from("direct:in").to("stream:out");

    // Send String payload to the standard output.
    // Message will be followed by the newline.
    template.sendBody("direct:in", "Hello Text World");

    // Send byte[] payload to the standard output.
    // No newline will be added after the message.
    template.sendBody("direct:in", "Hello Bytes World".getBytes());
    ---------------------------------------------------------------

    The following sample demonstrates how the header type can be used to
    determine which stream to use. In the sample we use our own output
    stream, `MyOutputStream`.

    The following sample demonstrates how to continuously read a file stream
    (analogous to the UNIX `tail` command):

    [source,java]
    ------------------------------------------------------------------------------------------------------------------------------------
    from("stream:file?fileName=/server/logs/server.log&scanStream=true&scanStreamDelay=1000").to("bean:logService?method=parseLogLine");
    ------------------------------------------------------------------------------------------------------------------------------------

    One gotcha with scanStream (pre Camel 2.7) or scanStream + retry is the
    file will be re-opened and scanned with each iteration of
    scanStreamDelay. Until NIO2 is available we cannot reliably detect when
    a file is deleted/recreated.

    [[Stream-SeeAlso]]
    See Also
    ^^^^^^^^

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

