The latest version for DAS is WSO2 Data Analytics Server 3.1.0. View documentation for the latest release.
WSO2 Data Analytics Server is succeeded by WSO2 Stream Processor. To view the latest documentation for WSO2 SP, see WSO2 Stream Processor Documentation.

All docs This doc
Skip to end of metadata
Go to start of metadata


This sample demonstrates how the WSO2 DAS can publish events to a Websocket client. 

Refer to below image to get an overview of the event flow.

The following is a summary of the steps that are followed to run this sample.

  • Step 1: Start the DAS server. This starts an inbuilt Websocket server in DAS.
  • Step 2: Define an Event Stream in DAS.
  • Step 3: Create an Output Websocket-local Event Adapter so that events of the type defined in step 1 are published via the DAS Websocket server.
  • Step 4: Connect a Websocket client to the Websocket Server in DAS. 
  • Step 5: Send a few events to the DAS. The inbuilt Event Simulator tool in DAS is used for this purpose. The events sent are received by the Websocket client. 


See Prerequisites in the CEP Samples Setup page. 

In addition to that, go to <DAS_HOME>/samples/cep/utils/output-websocket-local-adapter directory and execute the following command:

ant -Dsn=0070

This copies the outputwebsocket.war webapp to <DAS_HOME>/sample/artifacts/0070/webapps directory. 

Starting sample CEP configurations 

Start the WSO2 DAS server with the sample configuration numbered 0070 For instructions, see Starting sample CEP configurations.

This sample configuration points the default Axis2 repo to <DAS_HOME>/samples/cep/artifacts/0070 (by default, the Axis2 repo is <DAS_HOME>/repository/deployment/server). As a result, the artifacts in <DAS_HOME>/sample/artifacts/0070 directory are deployed.

When these sample configurations are deployed:

  • An event stream is defined.
  • The event simulator is available to play a set of events to DAS. 
  • An Output Websocket-local Event Adapter will be created.

In other words, all the first three steps listed in Introduction section are completed when the server is started with sample configuration number 0070.

Now the remaining tasks are to execute steps 4 and 5: connect a Websocket client, and send a few events to the CEP.

Connect to DAS via a Websocket client (to receive events)

In this sample, you will use your web browser as the Websocket client. However, any Websocket client can be used for this purpose.

Step I: Start a web browser and go to its Javascript console. In most browsers, such as Chrome and Firefox, you can load the Javascript console by simply pressing the keys Ctrl+Shift+J (or Cmd+Shift+J on a Mac). 

Ensure that the page on which you open the Javascript Console is loaded over HTTP. For example, you can open the page and load the Javascript console on that page.

Step II: On the browser console, copy and paste the following Javascript code block and press enter:

var ws = new WebSocket("ws://localhost:9763/outputwebsocket/wsLocalOutputAdapter");
ws.onopen = function() {
ws.onmessage = function (evt) {
alert("Message: " +; 
ws.onclose = function() {
ws.onerror = function(err) {
console.log("Error: " + err);

Note: If you have started DAS server on a different host and a port, replace localhost in the above command with that host, and 9763 with that port, respectively. See Running the Product page for more details.

This step is shown in the screenshot below.

Upon successful connection, you will see an output in the same console as shown in the below screenshot.

Now this browser-client is ready to receive events from the DAS.

Step III: Next and final step is to send four events to the DAS. We will send the following four events of type to the DAS.


The Event Simulator tool in DAS is used to send events.

To use the Event Simulator, log in to the DAS Management Console and go to Tools --> Event Simulator.

In the Event Simulator page, an input data file ready to be played is displayed in the Send Multiple Events section. Click Play as shown in the screenshot below to send the events included in this data file to the DAS. 

As the events are being played, you will see four alerts from your browser, indicating the receipt of events. One such alert is shown in the image below.

  • No labels