websocket source Websocket Source

Provided by: "Apache Software Foundation"

Support Level for this Kamelet is: "Stable"

Websocket endpoints for communicating with clients

Configuration Options

The following table summarizes the configuration options available for the websocket-source Kamelet:

Property Name Description Type Default Example

resourceUri

Resource Uri

Required 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.

boolean

false

bufferSize

Buffer Size

Set the buffer size of the websocketServlet.

integer

8192

crossOriginFilterOn

Cross Origin Filter

Whether to enable CORS.

boolean

false

enableJmx

Filter Path

Enable JMX support.

boolean

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).

boolean

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.

boolean

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

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
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 Camel K installed on the cluster.

Procedure for using the cluster CLI

  1. Save the websocket-source-binding.yaml file to your local drive, and then edit it as needed for your configuration.

  2. Run the source by using the following command:

    kubectl apply -f websocket-source-binding.yaml

Procedure for using the Kamel CLI

Configure and run the source by using the following command:

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
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 Strimzi.

  • You’ve created a topic named my-topic in the current namespace.

  • You have Camel K installed on the cluster.

Procedure for using the cluster CLI

  1. Save the websocket-source-binding.yaml file to your local drive, and then edit it as needed for your configuration.

  2. Run the source by using the following command:

    kubectl apply -f websocket-source-binding.yaml

Procedure for using the Kamel CLI

Configure and run the source by using the following command:

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.