Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

RDBMS event publisher is used to publish events in map format to a RDBMS in two execution modes, which are insert and update-insert.

...

  1. Create a datasource to connect to the selected database. For instructions on creating a datasource, see Adding Datasources.

    Info

    If selected database is H2, uncomment the following H2 database configurations in the <PRODUCT_HOME>/repository/config/carbon.xml file as follows, to browse through the database and see the changes. Keep the other properties of the  H2DatabaseConfiguration  element element uncommented.

    Code Block
    <H2DatabaseConfiguration>
    	<property name="web"/>
    	<property name="webPort">8082</property>
    	<property name="webAllowOthers"/>
    </H2DatabaseConfiguration>

...

Info

After entering the above adapter properties, select  the  select the Message Format   which you want to apply on the published events . Also, click click Advanced  to to define custom output mappings based on the the Message Format  you you selected. For more information on custom output mapping types, see Output Mapping Types .

You can also define define the respective adapter properties of the event publisher based on the transport type within the the <to>  element element of the event publisher configuration in the <PRODUCT_HOME>/repository/deployment/server/eventpublishers/ directory as follows.

...

Adapter Property
Description
Configuration file PropertyExample
Data Source NameName of the datasource
datasource.name
WSO2_CARBON_DB
Table Name Name of the table
table.name
sensordata
Execution Mode Type of the execution mode.
execution.mode
insert/update or insert
Composite key columns

Attributes used for uniqueness checks for updates. Use commas to separate if you enter more than one attribute.

Info

It is required to enter one or more attributes as composite key columns if you select update-or-insert for the Execution Mode property.

update.keys

sensor-key,sensor-group

Configuring advanced properties

Advanced properties are configured to select attributes with IDs different to those defined in the event stream to which the publisher is connected. 

e.g., If the event stream to which the publisher is connected has an attribute named ID, but you want the publisher to include attributes of which the name is formatted as id, you can define id as an advanced property as shown below.

Image Added

Tip

An RDBMS publisher does not by default identify the persisted attributes of an event stream. You can define the persisted attributes as advanced properties to avoid an exception similar to the following example.

Expand
titleClick here to view the exception
Code Block
languagetext
TID: [-1234] [] [2015-10-10 07:17:20,968] ERROR {org.wso2.carbon.event.output.adapter.rdbms.RDBMSEventAdapter} -  Cannot Execute Insert/Update. Null value detected for attributemeta_referer Hence Event is dropped. {org.wso2.carbon.event.output.adapter.rdbms.RDBMSEventAdapter}
org.wso2.carbon.event.output.adapter.core.exception.OutputEventAdapterException: Cannot Execute Insert/Update. Null value detected for attributemeta_referer
	at org.wso2.carbon.event.output.adapter.rdbms.RDBMSEventAdapter.populateStatement(RDBMSEventAdapter.java:372)
	at org.wso2.carbon.event.output.adapter.rdbms.RDBMSEventAdapter.executeDbActions(RDBMSEventAdapter.java:326)
	at org.wso2.carbon.event.output.adapter.rdbms.RDBMSEventAdapter.executeProcessActions(RDBMSEventAdapter.java:291)
	at org.wso2.carbon.event.output.adapter.rdbms.RDBMSEventAdapter.publish(RDBMSEventAdapter.java:134)
	at org.wso2.carbon.event.output.adapter.core.internal.OutputAdapterRuntime.publish(OutputAdapterRuntime.java:69)
	at org.wso2.carbon.event.output.adapter.core.internal.CarbonOutputEventAdapterService.publish(CarbonOutputEventAdapterService.java:143)
	at org.wso2.carbon.event.publisher.core.internal.EventPublisher.process(EventPublisher.java:361)
	at org.wso2.carbon.event.publisher.core.internal.EventPublisher.sendEvent(EventPublisher.java:209)
	at org.wso2.carbon.event.publisher.core.internal.EventPublisher.consumeEvent(EventPublisher.java:275)
	at org.wso2.carbon.event.stream.core.internal.EventJunction.sendEvent(EventJunction.java:142)
	at org.wso2.carbon.event.receiver.core.internal.management.InputEventDispatcher.onEvent(InputEventDispatcher.java:27)
	at org.wso2.carbon.event.receiver.core.internal.EventReceiver.sendEvent(EventReceiver.java:259)
	at org.wso2.carbon.event.receiver.core.internal.EventReceiver.processTypedEvent(EventReceiver.java:241)
	at org.wso2.carbon.event.receiver.core.internal.EventReceiver$TypedEventSubscription.onEvent(EventReceiver.java:317)
	at org.wso2.carbon.event.input.adapter.core.internal.InputAdapterRuntime.onEvent(InputAdapterRuntime.java:110)
	at org.wso2.carbon.event.input.adapter.wso2event.internal.ds.WSO2EventAdapterServiceDS$1.receive(WSO2EventAdapterServiceDS.java:92)
	at org.wso2.carbon.databridge.core.internal.queue.QueueWorker.run(QueueWorker.java:81)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)

 

Related samples

For more information on rdbms event publisher type, see the following sample in WSO2 CEP Documentation.

...