Set up WebSockets in Intrexx
Topics are created in the "Applications" module.
To create a topic in an application, please proceed as follows:
- Open the properties dialog of the application that you would like to create the topic in.
Switch to the "Topics" tab.
- Click on the icon.
The fields "GUID of the topic" and "Name of the topic" will appear on the right:
|GUID of the topic
||The GUID of the topic is shown in the right area of the dialog.
Intrexx assigns the GUID automatically, it cannot be changed.
|Name of the topic
||Provide the topic with a name here.
This name must be unique, it may only be used in Intrexx once.
You can use the topic name if you want to refer to the topic in WebSocket actions.
(Optional) Click on the icon again to create additional topics.
You can add any number of topics to an application.
You have now created a topic in an application.
Open the application that you would like to display the WebSocket message in.
a. Write the function for subscribing to the topic and for displaying the message in the portal.
b. (Optional) Write the function for unsubscribing from the topic.
a. start the subscription (e.g. onload, onclick) and
b. (Optional) end the subscription.
Configure WebSocket action
WebSocket actions are configured in the "Processes" module.
In the normal manner, add a WebSocket action to the corresponding process.
To configure a WebSocket action, please proceed as follows:
Open the properties dialog of the WebSocket action.
- Provide the WebSocket action with a title and (if required) a description.
Go to the "Topic" tab.
- Select the application that the message should be sent to from the "Application" drop-down list.
Select the topic that the message should be sent to from the "Topic" drop-down list.
The topic can be subscribed to in the browser.
2. Create topic
and 3. Define appearance in the portal for more information.
Please note: If you are using a WebSocket action, you only need the name of a topic to be able to refer to it.
If you are using a Groovy script action, you need the GUID of a topic to be able to refer to it.
Go to the "Content" tab.
Create the content for the message.
You can choose from one of the following options here:
||You can write a static text here. This is suitable if the message is always the same, i.e. you do not require changing message elements.
|Text from data field
||To display dynamic text, you can select a data field that provides the values.
This option is only available if the process contains a data group event handler.
|Text from system value
||You can generate texts from system values here. For example, you can apply user values or variables from the sharedState.
|Generate from Velocity
||You can generate texts via Velocity script here.
Go to the "Error handling" tab.
Define how Intrexx should behave if no (message) content can be found to continue processing.
You can choose from the following options here:
|Cancel transaction (default)
||If you select this option, the transaction will be canceled meaning that the process will no longer be executed if the WebSocket action does not have any content.
In this case, a message is not sent to the selected topic.
||If you select this option, the transaction is continued.
Select this option if subsequent process actions should still be executed even if the WebSocket action does not have any content.
This option can also be useful if the data record that triggered the event should be saved.
Click on "OK".
You have configured a WebSocket action.
Configure Groovy action
Groovy actions are configured in the "Processes" module.
In the normal manner, add a Groovy action to the corresponding process.
To configure a Groovy action with WebSocket functions, please proceed as follows:
- Open the properties dialog of the Groovy action.
- Go to the "Script" tab.
Click on "Open Intrexx editor".
This will launch the Intrexx Groovy editor.
Enter the Groovy script.
You can create the WebSocket message and the link to the topic using Groovy script.
Import the Groovy script class:
Use the following Groovy function to send text or JSON messages, respectively: