...
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 This is 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 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);
...