You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2021/12/07 09:12:06 UTC

[camel-kamelets] branch main updated: Add websocket source

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git


The following commit(s) were added to refs/heads/main by this push:
     new 9fa2ddd  Add websocket source
9fa2ddd is described below

commit 9fa2dddfdcf332103052c9773d356ca2b24a1391
Author: Federico Mariani <fe...@gmail.com>
AuthorDate: Mon Dec 6 16:14:00 2021 +0100

    Add websocket source
---
 docs/modules/ROOT/nav.adoc                         |   1 +
 docs/modules/ROOT/pages/websocket-source.adoc      | 161 +++++++++++++++++++++
 kamelets/websocket-source.kamelet.yaml             | 116 +++++++++++++++
 .../kamelets/websocket-source.kamelet.yaml         | 116 +++++++++++++++
 .../bindings/camel-k/websocket-source-binding.yaml |  18 +++
 .../bindings/core/websocket-source-binding.yaml    |   9 ++
 6 files changed, 421 insertions(+)

diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc
index c7200a6..abbe1d5 100644
--- a/docs/modules/ROOT/nav.adoc
+++ b/docs/modules/ROOT/nav.adoc
@@ -141,6 +141,7 @@
 * xref:ROOT:value-to-key-action.adoc[image:kamelets/value-to-key-action.svg[] Value to Key Action]
 * xref:ROOT:velocity-template-action.adoc[image:kamelets/velocity-template-action.svg[] Velocity Template Action]
 * xref:ROOT:webhook-source.adoc[image:kamelets/webhook-source.svg[] Webhook Source]
+* xref:ROOT:websocket-source.adoc[ Websocket Source]
 * xref:ROOT:wttrin-source.adoc[image:kamelets/wttrin-source.svg[] wttr.in Source]
 * xref:ROOT:xj-identity-action.adoc[image:kamelets/xj-identity-action.svg[] XJ Identity Action]
 * xref:ROOT:xj-template-action.adoc[image:kamelets/xj-template-action.svg[] XJ Template Action]
diff --git a/docs/modules/ROOT/pages/websocket-source.adoc b/docs/modules/ROOT/pages/websocket-source.adoc
new file mode 100644
index 0000000..94b38eb
--- /dev/null
+++ b/docs/modules/ROOT/pages/websocket-source.adoc
@@ -0,0 +1,161 @@
+// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT
+
+=  Websocket Source
+
+*Provided by: "Apache Software Foundation"*
+
+*Support Level for this Kamelet is: "Preview"*
+
+Websocket endpoints for communicating with clients
+
+== Configuration Options
+
+The following table summarizes the configuration options available for the `websocket-source` Kamelet:
+[width="100%",cols="2,^2,3,^2,^2,^3",options="header"]
+|===
+| Property| Name| Description| Type| Default| Example
+| *resourceUri {empty}* *| Resource Uri| Name of the websocket channel to use.| string| | 
+| allowedOrigins| Allowed Origins| The CORS allowed origins. Use to allow all.| string| `""`| 
+| bridgeErrorHandler| Bridge Rrror Handler| Allows for bridging the consumer to the Camel routing Error Handler| bool| `false`| 
+| bufferSize| Buffer Size| Set the buffer size of the websocketServlet| integer| `8192`| 
+| crossOriginFilterOn| Cross Origin Filter| Whether to enable CORS.| bool| `false`| 
+| enableJmx| Filter Path| Enable JMX support.| bool| `false`| 
+| filterPath| Filter Path| Context path for filtering CORS.| string| `""`| 
+| lazyStartProducer| Lazy Start Producer| Whether the producer should be started lazy (on the first message).| bool| `false`| 
+| maxBinaryMessageSize| Max Binary Message Size| Can be used to set the size in bytes that the websocket created by the websocketServlet may be accept before closing. (Default is -1 - or unlimited).| integer| `-1`| 
+| maxIdleTime| Max Idle Time| SetSet the time in ms that the websocket created by the websocketServlet may be idle before closing.| integer| `300000`| 
+| sendTimeout| Send Timeout| Timeout in millis when sending to a websocket channel. The default timeout is 30000 (30 seconds).| integer| `30000`| 
+| sessionSupport| Session Support| Whether to enable session support which enables HttpSession for each http request.| bool| `false`| 
+| subprotocol| Subprotocol| Comma-separated list of subprotocols that are supported by the application.| string| `"any"`| 
+| websocketHost| Host| The hostname| string| `"0.0.0.0"`| 
+| websocketPort| Port| The port number| integer| `9292`| 
+|===
+
+NOTE: Fields marked with an asterisk ({empty}*) are mandatory.
+
+
+== Dependencies
+
+At runtime, the `websocket-source` Kamelet relies upon the presence of the following dependencies:
+
+- camel:kamelet
+- camel:core
+- camel:websocket 
+
+== Usage
+
+This section describes how you can use the `websocket-source`.
+
+=== Knative Source
+
+You can use the `websocket-source` Kamelet as a Knative source by binding it to a Knative object.
+
+.websocket-source-binding.yaml
+[source,yaml]
+----
+apiVersion: camel.apache.org/v1alpha1
+kind: KameletBinding
+metadata:
+  name: websocket-source-binding
+spec:
+  source:
+    ref:
+      kind: Kamelet
+      apiVersion: camel.apache.org/v1alpha1
+      name: websocket-source
+    properties:
+      resourceUri: "The Resource Uri"
+  sink:
+    ref:
+      kind: Channel
+      apiVersion: messaging.knative.dev/v1
+      name: mychannel
+  
+----
+
+==== *Prerequisite*
+
+You have xref:{camel-k-version}@camel-k::installation/installation.adoc[Camel K installed] on the cluster.
+
+==== *Procedure for using the cluster CLI*
+
+. Save the `websocket-source-binding.yaml` file to your local drive, and then edit it as needed for your configuration.
+
+. Run the source by using the following command:
++
+[source,shell]
+----
+kubectl apply -f websocket-source-binding.yaml
+----
+
+==== *Procedure for using the Kamel CLI*
+
+Configure and run the source by using the following command:
+
+[source,shell]
+----
+kamel bind websocket-source -p "source.resourceUri=The Resource Uri" channel:mychannel
+----
+
+This command creates the KameletBinding in the current namespace on the cluster.
+
+=== Kafka Source
+
+You can use the `websocket-source` Kamelet as a Kafka source by binding it to a Kafka topic.
+
+.websocket-source-binding.yaml
+[source,yaml]
+----
+apiVersion: camel.apache.org/v1alpha1
+kind: KameletBinding
+metadata:
+  name: websocket-source-binding
+spec:
+  source:
+    ref:
+      kind: Kamelet
+      apiVersion: camel.apache.org/v1alpha1
+      name: websocket-source
+    properties:
+      resourceUri: "The Resource Uri"
+  sink:
+    ref:
+      kind: KafkaTopic
+      apiVersion: kafka.strimzi.io/v1beta1
+      name: my-topic
+  
+----
+
+==== *Prerequisites*
+
+* You've installed https://strimzi.io/[Strimzi].
+* You've created a topic named `my-topic` in the current namespace.
+* You have xref:{camel-k-version}@camel-k::installation/installation.adoc[Camel K installed] on the cluster.
+
+==== *Procedure for using the cluster CLI*
+
+. Save the `websocket-source-binding.yaml` file to your local drive, and then edit it as needed for your configuration.
+
+. Run the source by using the following command:
++
+[source,shell]
+----
+kubectl apply -f websocket-source-binding.yaml
+----
+
+==== *Procedure for using the Kamel CLI*
+
+Configure and run the source by using the following command:
+
+[source,shell]
+----
+kamel bind websocket-source -p "source.resourceUri=The Resource Uri" kafka.strimzi.io/v1beta1:KafkaTopic:my-topic
+----
+
+This command creates the KameletBinding in the current namespace on the cluster.
+
+== Kamelet source file
+
+https://github.com/apache/camel-kamelets/blob/main/kamelets/websocket-source.kamelet.yaml
+
+// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT
diff --git a/kamelets/websocket-source.kamelet.yaml b/kamelets/websocket-source.kamelet.yaml
new file mode 100644
index 0000000..5cfc287
--- /dev/null
+++ b/kamelets/websocket-source.kamelet.yaml
@@ -0,0 +1,116 @@
+apiVersion: camel.apache.org/v1alpha1
+kind: Kamelet
+metadata:
+  name: websocket-source
+  labels:
+    camel.apache.org/kamelet.type: "source"
+  annotations:
+    camel.apache.org/kamelet.support.level: "Preview"
+    camel.apache.org/catalog.version: "main-SNAPSHOT"
+    camel.apache.org/provider: "Apache Software Foundation"
+    camel.apache.org/kamelet.group: "Websocket"
+    camel.apache.org/kamelet.icon: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAACWAAAAcSCAYAAAAamNv5AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOLAAADiwB+ZvuEAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAACAASURBVHic7N3bl1xneefx562SbIIl1a5uyWerZXcbY5nEYGHGmMNYPgABJhwMmZvMWpBkLmb+g/kX5npmLuYUZsFVbHM2BGyGFQJJIIGEwyTY1qFbNhHGuKuqCfJB3VVzIXcw9N62pK6ud++qz+equ9bqXr/rvb717LR06NB/Go3ijwMAAADg1/3zsJV+/+TJk4/lHgIAAAAAUFcpItINC9f/lxSj/5h7DAAAAFA7T6fR8O5jp079Q+4hAAAAAAB11I6I6A36X+4W3QMp4vbcgwAAAIBa2RM [...]
+spec:
+  definition:
+    title: "Websocket Source"
+    description: "Websocket endpoints for communicating with clients"
+    type: object
+    required:
+    - resourceUri
+    properties:
+      websocketHost:
+        title: Host
+        description: The hostname
+        type: string
+        default: "0.0.0.0"
+      websocketPort:
+        title: Port
+        description: The port number
+        type: integer
+        default: 9292
+      resourceUri:
+        title: Resource Uri
+        description: Name of the websocket channel to use.
+        type: string
+      maxBinaryMessageSize:
+        title: Max Binary Message Size
+        description: Can be used to set the size in bytes that the websocket created by the websocketServlet may be accept before closing. (Default is -1 - or unlimited).
+        type: integer
+        default: -1
+      bridgeErrorHandler: 
+        title: Bridge Rrror Handler
+        description: Allows for bridging the consumer to the Camel routing Error Handler
+        type: bool
+        default: false
+      sessionSupport: 
+        title: Session Support
+        description: Whether to enable session support which enables HttpSession for each http request.
+        type: bool
+        default: false
+      subprotocol:
+        title: Subprotocol
+        description: Comma-separated list of subprotocols that are supported by the application.
+        type: string
+        default: any
+      lazyStartProducer:
+        title: Lazy Start Producer
+        description: Whether the producer should be started lazy (on the first message).
+        type: bool
+        default: false
+      sendTimeout:
+        title: Send Timeout
+        description: Timeout in millis when sending to a websocket channel. The default timeout is 30000 (30 seconds).
+        type: integer
+        default: 30000
+      bufferSize:
+        title: Buffer Size
+        description: Set the buffer size of the websocketServlet
+        type: integer
+        default: 8192
+      maxIdleTime:
+        title: Max Idle Time
+        description: SetSet the time in ms that the websocket created by the websocketServlet may be idle before closing.
+        type: integer
+        default: 300000
+      allowedOrigins:
+        title: Allowed Origins
+        description: The CORS allowed origins. Use to allow all.
+        type: string
+        default: ""
+      crossOriginFilterOn:
+        title: Cross Origin Filter
+        description: Whether to enable CORS.
+        type: bool
+        default: false
+      filterPath:
+        title: Filter Path
+        description: Context path for filtering CORS.
+        type: string
+        default: ""
+      enableJmx:
+        title: Filter Path
+        description: Enable JMX support.
+        type: bool
+        default: false
+  dependencies:
+    - "camel:kamelet"
+    - "camel:core"
+    - "camel:websocket"
+  flow:
+    from:
+      uri: "websocket://{{websocketHost}}:{{websocketPort}}/{{resourceUri}}"
+      parameters:
+        maxBinaryMessageSize: "{{maxBinaryMessageSize}}"
+        bridgeErrorHandler: "{{bridgeErrorHandler}}"
+        sessionSupport: "{{sessionSupport}}"
+        subprotocol: "{{subprotocol}}"
+        lazyStartProducer: "{{lazyStartProducer}}"
+        sendTimeout: "{{sendTimeout}}"
+        bufferSize: "{{bufferSize}}"
+        maxIdleTime: "{{maxIdleTime}}"
+        allowedOrigins: "{{allowedOrigins}}"
+        crossOriginFilterOn: "{{crossOriginFilterOn}}"
+        filterPath: "{{filterPath}}"
+        enableJmx: "{{enableJmx}}"
+      steps:
+      - to: kamelet:sink
diff --git a/library/camel-kamelets/src/main/resources/kamelets/websocket-source.kamelet.yaml b/library/camel-kamelets/src/main/resources/kamelets/websocket-source.kamelet.yaml
new file mode 100644
index 0000000..5cfc287
--- /dev/null
+++ b/library/camel-kamelets/src/main/resources/kamelets/websocket-source.kamelet.yaml
@@ -0,0 +1,116 @@
+apiVersion: camel.apache.org/v1alpha1
+kind: Kamelet
+metadata:
+  name: websocket-source
+  labels:
+    camel.apache.org/kamelet.type: "source"
+  annotations:
+    camel.apache.org/kamelet.support.level: "Preview"
+    camel.apache.org/catalog.version: "main-SNAPSHOT"
+    camel.apache.org/provider: "Apache Software Foundation"
+    camel.apache.org/kamelet.group: "Websocket"
+    camel.apache.org/kamelet.icon: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAACWAAAAcSCAYAAAAamNv5AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOLAAADiwB+ZvuEAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAACAASURBVHic7N3bl1xneefx562SbIIl1a5uyWerZXcbY5nEYGHGmMNYPgABJhwMmZvMWpBkLmb+g/kX5npmLuYUZsFVbHM2BGyGFQJJIIGEwyTY1qFbNhHGuKuqCfJB3VVzIXcw9N62pK6ud++qz+equ9bqXr/rvb717LR06NB/Go3ijwMAAADg1/3zsJV+/+TJk4/lHgIAAAAAUFcpItINC9f/lxSj/5h7DAAAAFA7T6fR8O5jp079Q+4hAAAAAAB11I6I6A36X+4W3QMp4vbcgwAAAIBa2RM [...]
+spec:
+  definition:
+    title: "Websocket Source"
+    description: "Websocket endpoints for communicating with clients"
+    type: object
+    required:
+    - resourceUri
+    properties:
+      websocketHost:
+        title: Host
+        description: The hostname
+        type: string
+        default: "0.0.0.0"
+      websocketPort:
+        title: Port
+        description: The port number
+        type: integer
+        default: 9292
+      resourceUri:
+        title: Resource Uri
+        description: Name of the websocket channel to use.
+        type: string
+      maxBinaryMessageSize:
+        title: Max Binary Message Size
+        description: Can be used to set the size in bytes that the websocket created by the websocketServlet may be accept before closing. (Default is -1 - or unlimited).
+        type: integer
+        default: -1
+      bridgeErrorHandler: 
+        title: Bridge Rrror Handler
+        description: Allows for bridging the consumer to the Camel routing Error Handler
+        type: bool
+        default: false
+      sessionSupport: 
+        title: Session Support
+        description: Whether to enable session support which enables HttpSession for each http request.
+        type: bool
+        default: false
+      subprotocol:
+        title: Subprotocol
+        description: Comma-separated list of subprotocols that are supported by the application.
+        type: string
+        default: any
+      lazyStartProducer:
+        title: Lazy Start Producer
+        description: Whether the producer should be started lazy (on the first message).
+        type: bool
+        default: false
+      sendTimeout:
+        title: Send Timeout
+        description: Timeout in millis when sending to a websocket channel. The default timeout is 30000 (30 seconds).
+        type: integer
+        default: 30000
+      bufferSize:
+        title: Buffer Size
+        description: Set the buffer size of the websocketServlet
+        type: integer
+        default: 8192
+      maxIdleTime:
+        title: Max Idle Time
+        description: SetSet the time in ms that the websocket created by the websocketServlet may be idle before closing.
+        type: integer
+        default: 300000
+      allowedOrigins:
+        title: Allowed Origins
+        description: The CORS allowed origins. Use to allow all.
+        type: string
+        default: ""
+      crossOriginFilterOn:
+        title: Cross Origin Filter
+        description: Whether to enable CORS.
+        type: bool
+        default: false
+      filterPath:
+        title: Filter Path
+        description: Context path for filtering CORS.
+        type: string
+        default: ""
+      enableJmx:
+        title: Filter Path
+        description: Enable JMX support.
+        type: bool
+        default: false
+  dependencies:
+    - "camel:kamelet"
+    - "camel:core"
+    - "camel:websocket"
+  flow:
+    from:
+      uri: "websocket://{{websocketHost}}:{{websocketPort}}/{{resourceUri}}"
+      parameters:
+        maxBinaryMessageSize: "{{maxBinaryMessageSize}}"
+        bridgeErrorHandler: "{{bridgeErrorHandler}}"
+        sessionSupport: "{{sessionSupport}}"
+        subprotocol: "{{subprotocol}}"
+        lazyStartProducer: "{{lazyStartProducer}}"
+        sendTimeout: "{{sendTimeout}}"
+        bufferSize: "{{bufferSize}}"
+        maxIdleTime: "{{maxIdleTime}}"
+        allowedOrigins: "{{allowedOrigins}}"
+        crossOriginFilterOn: "{{crossOriginFilterOn}}"
+        filterPath: "{{filterPath}}"
+        enableJmx: "{{enableJmx}}"
+      steps:
+      - to: kamelet:sink
diff --git a/templates/bindings/camel-k/websocket-source-binding.yaml b/templates/bindings/camel-k/websocket-source-binding.yaml
new file mode 100644
index 0000000..56dbe92
--- /dev/null
+++ b/templates/bindings/camel-k/websocket-source-binding.yaml
@@ -0,0 +1,18 @@
+apiVersion: camel.apache.org/v1alpha1
+kind: KameletBinding
+metadata:
+  name: websocket-source-binding
+spec:
+  source:
+    ref:
+      kind: Kamelet
+      apiVersion: camel.apache.org/v1alpha1
+      name: websocket-source
+    properties:
+      resourceUri: "The Resource Uri"
+  sink:
+    ref:
+      kind: KafkaTopic
+      apiVersion: kafka.strimzi.io/v1beta1
+      name: my-topic
+  
\ No newline at end of file
diff --git a/templates/bindings/core/websocket-source-binding.yaml b/templates/bindings/core/websocket-source-binding.yaml
new file mode 100644
index 0000000..83def49
--- /dev/null
+++ b/templates/bindings/core/websocket-source-binding.yaml
@@ -0,0 +1,9 @@
+- route:
+    from:
+      uri: "kamelet:websocket-source"
+      parameters:
+        resourceUri: "The Resource Uri"
+    steps:
+      - to:
+          uri: "log:info"
+    
\ No newline at end of file