...
A data publisher allows you to send data to a predefined set of data fields in a DAS/CEP server. The data structure with predefined fields is defined in an /wiki/spaces/TESB/pages/32604253 event stream. The data is converted to the format defined by the /wiki/spaces/TESB/pages/32604253 and event stream and sent via the WSO2 data-bridge component. You can also send custom key-value pairs with data events.
...
Add the JAR files listed below to your class path. Note that ${carbon.analytics-commons.version}
refers to the version of the carbon -analytics commons github repository - https://github.com/wso2/carbon-commonsanalytics-common/. It is always recommended to use the jar file from the latest released version.
...
${carbon.commonsanalytics-common.version}
refers to the version of the carbon-analytics-commons github common github repository - https://github.com/wso2/carbon-analytics-commonscommon/. It is always recommended to use the dependency entry from the latest released version.
Code Block | ||||
---|---|---|---|---|
| ||||
<repositories> <repository> <id>wso2-nexus</id> <name>WSO2 internal Repository</name> <url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url> <releases> <enabled>true</enabled> <updatePolicy>daily</updatePolicy> <checksumPolicy>ignore</checksumPolicy> </releases> </repository> <repository> <id>wso2.releases</id> <name>WSO2 internal Repository</name> <url>http://maven.wso2.org/nexus/content/repositories/releases/</url> <releases> <enabled>true</enabled> <updatePolicy>daily</updatePolicy> <checksumPolicy>ignore</checksumPolicy> </releases> </repository> <repository> <id>wso2.snapshots</id> <name>Apache Snapshot Repository</name> <url>http://maven.wso2.org/nexus/content/repositories/snapshots/</url> <snapshots> <enabled>true</enabled> <updatePolicy>daily</updatePolicy> </snapshots> <releases> <enabled>false</enabled> </releases> </repository> </repositories> |
Code Block | ||||
---|---|---|---|---|
| ||||
<dependency> <groupId>org.wso2.carbon<carbon.analytics-common</groupId> <artifactId>org.wso2.carbon.databridge.agent</artifactId> <version>${carbon.commonsanalytics-common.version}</version> </dependency> <dependency> <groupId>org.wso2.carbon<carbon.analytics-common</groupId> <artifactId>org.wso2.carbon.databridge.commons</artifactId> <version>${carbon.commonsanalytics-common.version}</version> </dependency> <dependency> <groupId>org.wso2.carbon<carbon.analytics-common</groupId> <artifactId>org.wso2.carbon.databridge.commons.thrift</artifactId> <version>${carbon.analytics-common.version}</version> </dependency> <dependency> <groupId>org.wso2.carbon.analytics-common</groupId> <artifactId>org.wso2.carbon.databridge.commons.binary</artifactId> <version>${carbon.analytics-common.version}</version> </dependency> |
...
Load the following sample configurations and properties to define the data agent in the JVM.
Code Block language xml <DataAgentsConfiguration> <Agent> <Name>Thrift</Name> <DataEndpointClass>org.wso2.carbon.databridge.agent.internal.endpoint.thrift.ThriftDataEndpoint</DataEndpointClass> <TrustSore>src/main/resources/client-truststore.jks</TrustSore> <TrustSorePassword>wso2carbon</TrustSorePassword> <QueueSize>32768</QueueSize> <BatchSize>200</BatchSize> <CorePoolSize>5</CorePoolSize> <MaxPoolSize>10</MaxPoolSize> <KeepAliveTimeInPool>20</KeepAliveTimeInPool> <ReconnectionInterval>30</ReconnectionInterval> <MaxTransportPoolSize>250</MaxTransportPoolSize> <MaxIdleConnections>250</MaxIdleConnections> <EvictionTimePeriod>5500</EvictionTimePeriod> <MinIdleTimeInPool>5000</MinIdleTimeInPool> <SecureMaxTransportPoolSize>250</SecureMaxTransportPoolSize> <SecureMaxIdleConnections>250</SecureMaxIdleConnections> <SecureEvictionTimePeriod>5500</SecureEvictionTimePeriod> <SecureMinIdleTimeInPool>5000</SecureMinIdleTimeInPool> </Agent> <Agent> <Name>Binary</Name> <DataEndpointClass>org.wso2.carbon.databridge.agent.internal.endpoint.binary.BinaryDataEndpoint </DataEndpointClass> <TrustSore>src/main/resources/client-truststore.jks</TrustSore> <TrustSorePassword>wso2carbon</TrustSorePassword> <QueueSize>32768</QueueSize> <BatchSize>200</BatchSize> <CorePoolSize>5</CorePoolSize> <MaxPoolSize>10</MaxPoolSize> <KeepAliveTimeInPool>20</KeepAliveTimeInPool> <ReconnectionInterval>30</ReconnectionInterval> <MaxTransportPoolSize>250</MaxTransportPoolSize> <MaxIdleConnections>250</MaxIdleConnections> <EvictionTimePeriod>5500</EvictionTimePeriod> <MinIdleTimeInPool>5000</MinIdleTimeInPool> <SecureMaxTransportPoolSize>250</SecureMaxTransportPoolSize> <SecureMaxIdleConnections>250</SecureMaxIdleConnections> <SecureEvictionTimePeriod>5500</SecureEvictionTimePeriod> <SecureMinIdleTimeInPool>5000</SecureMinIdleTimeInPool> </Agent> </DataAgentsConfiguration>
Tip To configure the above parameters in the
<CEP_HOME>/repository/conf/data-bridge/data-agent-conf.xml
file in order to tune performance, follow the instructions in WSO2 event configuration.- Instantiate the data publisher as follows:
AgentHolder. setConfigPath(“/path/to/data/agent/conf.xml”)
Set trustStore
Code Block language java File securityFile = new File(<CEP_HOME> + "repository" + File.separator + "resources" + File.separator +"security"); String trustStore = securityFile.getAbsolutePath(); System.setProperty("javax.net.ssl.trustStore", trustStore + "" + File.separator + "client-truststore.jks"); System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");
Info The key also the can be found at https://github.com/wso2/carbon-kernel/tree/master/distribution/kernel/carbon-home/repository/resources/security
Instantiate and use the data publisher using one of the following configurations:
DataPublisher dataPublisher = new DataPublisher(url, username, password);
DataPublisher dataPublisher = new DataPublisher(receiverURLSet, username, password);
DataPublisher dataPublisher = new DataPublisher(receiverURLSet,authURLSet, username, password);
Info For information on the
receiverURLSet
andauthURLSet
parameters of the above configuration, see /wiki/spaces/PS/pages/10519892 Setting up Multi Receiver and Load Balancing Data Agent. And similarly if you are passing an receiverURLSet as tcp://localhost:7611|tcp://localhost:7612|tcp://localhost:7613, then the corresponding authentication URL set will be ssl://localhost:7711|ssl://localhost:7712|ssl://localhost:7713.In all the above methods, the default data agent (which is configured as first Agent element in the above configuration) will be used to create the data publishers. If you have configured only the Thrift data agent in the
<CEP_HOME>/repository/conf/data-bridge/data-agent-conf.xml
file, then this will provide you a Thirft-based data publisher instance.However, if you have configured more types of data agents in the
<CEP_HOME>/repository/conf/data-bridge/data-agent-conf.xml
file (Eg: Binary Agent in the above sample data-agent-conf.xml ), then you can pass an additional property namedtype
, which denotes the type of data publisher that needs to be created. For example, if you have a binary data publisher, then you can passbinary
as the type to get the binary data publisher Instance as shown below.Code Block language java DataPublisher dataPublisher = new DataPublisher(String type, String receiverURLSet, String authURLSet, String username, String password);
Data publisher sample
Tip |
---|
As a prerequisite for this sample, you need to define the event streams and a WSO2Event receiver in the server (WSO2 DAS/CEP). |
...