WebSocket Event Publisher
The WebSocket event publisher can be configured with XML, JSON, and text output mapping types.
The websocket
event publisher should be used when the CEP publishes to a websocket server to which the CEP server needs to connect in order to publish events. However, if the events are to be published in a web socket client, that web socket client needs to connect to the inbuilt websocket server of the CEP. In such scenarios, use the WebSocket Local Event Publisher.
Prerequisites
Start the WebSocket server, before starting the event publisher configurations.
Creating a WebSocket event publisher
For instructions on creating a WebSocket event publisher, see Configuring CEP to Create Alerts.
Configuring global properties
The following global properties can be set for the WebSocket
event publisher type in the <CEP_HOME>/repository/conf/output-event-adapters.xml
file. These properties apply to all the publishers of the websocket
type. If a global property available by default is removed, the default value of the property is considered.
Custom properties cannot be added as global properties.
Property Key | Description | Data Type | Default Value |
---|---|---|---|
minThread | The minimum number of threads (including idle threads) that should be available in the thread pool at a given time. | Integer | 8 |
maxThread | The maximum number of threads (including idle threads) that should be available in the thread pool at a given time. | Integer | 100 |
keepAliveTimeInMillis | The maximum number of milliseconds that idle threads should be kept alive when the total number of threads in the pool exceeds the number of cores in the machine. | Integer | 20000 |
jobQueueSize | The maximum number of milliseconds that idle threads should be kept alive when the total number of threads in the pool exceeds the number of cores in the machine. | Integer | 10000
|
Configuring adapter properties
Specify the Static Adapter Properties, when creating a WebSocket event publisher using the management console as shown below.
After entering the above adapter properties, select the Event Stream to which you want to map the incoming events, and the Message Format that you want to apply on the receiving events. Also, click Advanced to define custom input mappings based on the Message Format you selected. For more information on custom input mapping types, see Input Mapping Types.
You can also d efine the respective adapter properties of the event receiver based on the transport type within the <from>
element of the event receiver configuration in the<PRODUCT_HOME>/repository/deployment/server/eventpublishers/
directory as follows.
<eventPublisher name="WebSocketOutputEventAdapter" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher"> ........ <to eventAdapterType="websocket"> <property name="websocket.server.url">ws://localhost:9099</property> </to> </eventPublisher>
Adapter Property | Description | Configuration file property | Example |
---|---|---|---|
Web Socket Server URL | URL of the WebSocket server to which you want to connect | websocket.server.url | ws://localhost:9099 |
Related samples
For more information on websocket
event publisher type, see the following sample.