Events can be notified or published to external systems from WSO2 servers using event publishers. Event publishers enable you to manage event publishing and notifications. They allow publishing events via multiple transports in JSON, XML, Map, text, and WSO2Event formats to various endpoints and data stores.
Configuring global properties
Global properties can be set for individual output event adapter types in the <DAS_HOME>/repository/conf/output-event-adapters.xml
file. A global property set for an output event adapter type in this file applies to all the publishers with that adapter type. If a property available for an adapter type by default is removed, the default value of the property applies. Click the relevant tab to view the properties available by default for a specific output event adapter type.
Custom properties cannot be added as global properties.
When the output event adapter type is RDBMS
, it is allowed to change the queries used to perform the standard database operations. This enables you to use RDBMS database types that use different queries. Customised values can be defined for the following used in standard queries.
Attribute/activity | Current query |
---|---|
string | VARCHAR(255) |
double | DOUBLE |
integer | INT |
long | BIGINT |
float | FLOAT |
createTable | CREATE TABLE $TABLE_NAME ($COLUMN_TYPES) |
insertDataToTable | INSERT INTO $TABLE_NAME ($COLUMNS) VALUES ($VALUES) |
isTableExist | SELECT * FROM $TABLE_NAME limit 1 |
updateTableRow | UPDATE $TABLE_NAME SET $COLUMN_VALUES WHERE $CONDITION |
comma | , |
questionMark | ? |
equal | = |
and | AND |
selectAllColumnsDataTypeInTable | SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '$TABLE_NAME' |
selectFromTable | SELECT $COLUMNS FROM $TABLE_NAME |
oracle.string | varchar2(255) |
oracle.long | CLOB |
oracle.double | BINARY_DOUBLE |
oracle.isTableExist | SELECT * FROM $TABLE_NAME WHERE ROWNUM = 1 |
oracle.selectAllColumnsDataTypeInTable | SELECT COLUMN_NAME, DATA_TYPE FROM USER_TAB_COLS WHERE TABLE_NAME = '$TABLE_NAME' |
mssql.string | varchar2(255) |
mssql.isTableExist | SELECT TOP 1 * FROM $TABLE_NAME |
mssql.selectAllColumnsDataTypeInTable | SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '$TABLE_NAME' |
h2.integer | varchar2(255) |
h2.long | REAL |
h2.selectAllColumnsDataTypeInTable | SHOW COLUMNS FROM $TABLE_NAME
|
The following properties are available for the http
output event adapter type.
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 size of the queue that is used to hold events before they are forwarded to the event stream. | Integer | 10000 |
defaultMaxConnectionsPerHost | The maximum number of connections allowed per host configuration. | Integer | 50 |
maxTotalConnections | The maximum number of connections allowed overall. | Integer | 1000
|
The following properties are available for the jms
output event adapter type.
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 |
The following properties are available for the mqtt
output event adapter type.
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 |
connectionKeepAliveInterval | The time interval in milliseconds at which a check should be carried out to identify inactive threads. | Integer | 60
|
The following properties are available for the kafka output event adapter type.
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
|
The following properties are available for the email output event adapter type.
Property Key | Description | Data Type | Default Value |
---|---|---|---|
mail.smtp.from | The email address used by the publisher to publish events. | String | [email protected] |
mail.smtp.user | The username used by the publisher to publish events via email. | String | abcd |
mail.smtp.password | The password used by the publish events via email. | String | xxxx |
mail.smtp.host | The host of the email server. | String | smtp.gmail.com |
mail.smtp.port | The port of the email server. | Integer | 587 |
mail.smtp.starttls.enable | This property specifies whether STARTTLS encryption is enabled or not. STARTTLS is an extension which enables a plain text connection to be upgraded to an encrypted (SSL or TLS) connection. | Boolean | true |
mail.smtp.auth | This property specifies whether SMTP authentication is enabled or not. | Boolean | true |
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
|
The following properties are available for the UI
output event adapter type.
Property Key | Description | Data Type | Default Value |
---|---|---|---|
eventQueueSize | The maximum number of events allowed in the adapter queue when the rate at which a UI publisher receives events to be published higher than the rate at which the relevant UI is accepting the events. When the number of events received by the publisher exceeds the value specified for this property, the publisher stops accepting events until the events that are already in the queue get published. Therefore, if you want to reduce system latency, a higher queue size should be specified. | Integer | 30 |
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
|
The following properties are available for the websocket-local output event adapter type.
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
|
The following properties are available for the websocket output event adapter type.
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
|
The following properties are available for the soap output event adapter type.
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 |
axis2ClientConnectionTimeout | The number of milliseconds allowed to elapse before the Axis2 client connection times out. | Integer | 10000 |
reuseHTTPClient | If this property is set to true , it is allowed to reuse the connection to the HTTP client for subsequent requests. | Boolean | true |
autoReleaseConnection | If this property is set to true , inactive connections are automatically killed. | Boolean | true |
maxConnectionsPerHost | The maximum number of connections allowed per host configuration. | Integer | 50
|
Event publisher configuration
An event publisher configuration has four main sections as follows.
Event publisher configurations are stored in file system as hot deployable artifacts in the <PRODUCT
_HOME>/repository/deployment/server/eventpublishers/
directory as shown in the example below .
<eventPublisher name="WebSocketEventPublisher" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher"> <from streamName="testEventStream" version="1.0.0"/> <mapping customMapping="disable" type="text"/> <to eventAdapterType="websocket"> <property name="websocket.server.url">ws://localhost:9099</property> </to> </eventPublisher>
The above sections of an event publisher configuration are described below.
Section | Description |
---|---|
From | The event stream from which the event publisher will fetch the events for publishing. |
To | An output event adapter(transport) configuration that is used to send the events to. |
Adapter properties | Output event adapters contain three types of adapter properties in their configuration as explained below.
|
Mapping configuration | The format of the message that needs to be sent. You can configure custom mappings on the selected format via advanced settings. |
Creating event publishers
You can create event publishers either using the management console or using a configuration file as explained below.
Creating publishers using the management console
Follow the steps below to create an event publisher using the management console of WOS2 CEP/DAS.
- To create an event publisher via the management console, you must at least have one event stream defined.
- Once and event publisher is created and saved, its XML configuration is saved in the
<DAS_HOME>/repository/deployment/server/eventpublishers
directory.
- Log in to the management console, and click Main.
- Click Publishers in the Event menu, and then click Add Event Publisher.
Enter a name for Event Publisher Name. (Do not use spaces between the words in the name of the event publisher.)
Select the Event Source with the published events.
- You view the Stream Attributes of the selected event source. You cannot edit the attributes of a created event stream in here.
Select the output transport to which you want to publish events for the Output Event Adapter Type, and enter the Adapter Properties accordingly. For instructions on the adapter properties of output transport types, see Event Publisher Types.
Select the Message Format which you want to apply on the published events. WSO2 servers allow users to configure events in XML, JSON, Text, Map, and WSO2Event event formats.
- Click Advanced to define custom output mappings based on the message format you selected, if you want to publish events that do not adhere to the default event formats. For more information on custom input mapping types, see Publishing Events in Various Event Formats.
- Click Add Event Publisher , to create the event publisher in the system. When you click OK in the pop-up message on successful addition of the event publisher, you view it in the Available Event Publishers list as shown below.
Creating publishers using a configuration file
Follow the steps below to create an event publisher using a configuration file.
Create an XML file with the following event publisher configurations. An event publisher implementation should start with
<eventPublisher
as the root element.>
In the following configuration, specify the respective adapter properties based on the transport type of the publisher within the
<from>
element. For the respective adapter properties of the event publisher configuration based on the transport type, see Publishing Events via Various Transports.<eventPublisher name="EVENT-PUBLISHER-NAME" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher"> <from streamName="Test Stream" version="1.0.0"/> <mapping customMapping="disable" type="text"/> <to eventAdapterType="EVENT-ADAPTER-TYPE"> ..................... </to> </eventPublisher>
The properties of the above configuration are described below.
Adapter property Description name
Name of the event publisher statistics
Whether monitoring event statistics is enabled for the publisher trace
Whether tracing events is enabled for the publisher xmlns
XML namespace for event receivers streamName
Name of the event stream from which the publisher publishes events. version
Version of the event stream from which the publisher publishes events. customMapping
Whether a custom mapping is enabled on the receiver. type
Type of the enabled custom mapping. eventAdapterType
Type of the event adapter. Add the XML file to the
<DAS_HOME>/repository/deployment/server/eventpublishers
directory. Since hot deployment is supported in the product, you can simply add/remove event publisher configuration files to deploy/undeploy event publishers to/from the server.First define the stream to which the publisher is publishing data from to activate the publisher. When receiving WSO2Events, the outgoing stream definition that you select in the advanced input mappings must also be defined, to activate the event publisher. When you click Inactive Event Publishers in the Available Event Publishers screen, if an event publisher is in the inactive state due to some issue in the configurations, you view a short message specifying the reason why the event publisher is inactive as shown below. A similar message is also printed on the CLI.
After a publisher is successfully added, it gets added to the list of publisher displayed under Event in the Main menu of the product's management console. ClickEdit to change its configuration and redeploy it. This opens an XML-based editor allowing you to edit the event adapter configurations from the UI. Do your modifications and click Update. You can also delete it, enable/disable statistics or enable/disable tracing on it using the provided options in the UI as described below.
Enabling statistics for event publishers
Follow the steps below to enable monitoring statistics of events published by an existing event publisher.
For more information on monitoring event statistics of event publishers, see Event Statistics.
- Log in to the management console, and click Main.
- Click Publishers in the Event menu. You view the Available Event Publishers list.
- Click the Enable Statistics button of the corresponding event publisher to enable monitoring event statistics for it.
Enabling tracing for event publishers
Follow the steps below to enable tracing on events published by an existing event publisher.
For more information on monitoring event statistics of event publisher s, see Event Tracer.
- Log in to the management console, and click Main.
- Click Publishers in the Event menu. You view the Available Event Publishers list.
- Click the Enable Tracing button of the corresponding event publisher to enable event tracing for it.
Deleting event publishers
Follow the steps below to delete an existing event publisher.
- Log in to the management console, and click Main.
- Click Publishers in the Event menu. You view the Available Event Publishers list.
- Click the Delete button of the corresponding event publishe r to delete it.
Editing event publishers
Follow the steps below to edit an existing event publisher.
- Log in to the management console, and click Main.
- Click Publishers in the Event menu. You view the Available Event Publishers list.
- Click the Edit button of the corresponding event publishe r to edit it. This opens Edit Event Publishers Configurations XML editor.
- After editing, click Update, to save the configuration, or click Reset to reset the configuration to its original state.