Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add websocket source #609

Merged
merged 1 commit into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
161 changes: 161 additions & 0 deletions docs/modules/ROOT/pages/websocket-source.adoc
Original file line number Diff line number Diff line change
@@ -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
116 changes: 116 additions & 0 deletions kamelets/websocket-source.kamelet.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions templates/bindings/camel-k/websocket-source-binding.yaml
Original file line number Diff line number Diff line change
@@ -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

9 changes: 9 additions & 0 deletions templates/bindings/core/websocket-source-binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- route:
from:
uri: "kamelet:websocket-source"
parameters:
resourceUri: "The Resource Uri"
steps:
- to:
uri: "log:info"