org.wso2.carbon.databridge.agent
Class DataPublisher

java.lang.Object
  extended by org.wso2.carbon.databridge.agent.DataPublisher

public class DataPublisher
extends Object

API Used to communicate with Data Receivers WSO2 BAM/CEP. It can be used to send events to multiple BAM/CEP nodes with load balancing and failover logic.


Constructor Summary
DataPublisher(String receiverURLSet, String username, String password)
          Creates the DataPublisher instance for a specific user, and the it creates connection asynchronously to receiver endpoint.
DataPublisher(String receiverURLSet, String authURLSet, String username, String password)
          Creates the DataPublisher instance for a specific user, and the it creates connection asynchronously to receiver endpoint.
DataPublisher(String type, String receiverURLSet, String authURLSet, String username, String password)
          Creates the DataPublisher instance for a specific user, and the it creates connection asynchronously to receiver endpoint.
 
Method Summary
 void publish(org.wso2.carbon.databridge.commons.Event event)
          Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher.
 void publish(String streamId, long timeStamp, Object[] metaDataArray, Object[] correlationDataArray, Object[] payloadDataArray)
          Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher.
 void publish(String streamId, long timeStamp, Object[] metaDataArray, Object[] correlationDataArray, Object[] payloadDataArray, Map<String,String> arbitraryDataMap)
          Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher.
 void publish(String streamId, Object[] metaDataArray, Object[] correlationDataArray, Object[] payloadDataArray)
          Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher.
 void publish(String streamId, Object[] metaDataArray, Object[] correlationDataArray, Object[] payloadDataArray, Map<String,String> arbitraryDataMap)
          Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher.
 void shutdown()
          Graceful shutdown of all the operations of the data publisher.
 void shutdownWithAgent()
          Graceful shutdown of all the operations of the data publisher, and also if there is no other data publishers registered with the associated then it will shutdown the agent as well.
 boolean tryPublish(org.wso2.carbon.databridge.commons.Event event)
          Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher.
 boolean tryPublish(org.wso2.carbon.databridge.commons.Event event, long timeoutMS)
          Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher.
 boolean tryPublish(String streamId, long timeStamp, Object[] metaDataArray, Object[] correlationDataArray, Object[] payloadDataArray)
          * Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher.
 boolean tryPublish(String streamId, long timeStamp, Object[] metaDataArray, Object[] correlationDataArray, Object[] payloadDataArray, long timeoutMS)
          Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher.
 boolean tryPublish(String streamId, long timeStamp, Object[] metaDataArray, Object[] correlationDataArray, Object[] payloadDataArray, Map<String,String> arbitraryDataMap)
          * Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher.
 boolean tryPublish(String streamId, long timeStamp, Object[] metaDataArray, Object[] correlationDataArray, Object[] payloadDataArray, Map<String,String> arbitraryDataMap, long timeoutMS)
          Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher.
 boolean tryPublish(String streamId, Object[] metaDataArray, Object[] correlationDataArray, Object[] payloadDataArray)
          * Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher.
 boolean tryPublish(String streamId, Object[] metaDataArray, Object[] correlationDataArray, Object[] payloadDataArray, long timeoutMS)
          Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher.
 boolean tryPublish(String streamId, Object[] metaDataArray, Object[] correlationDataArray, Object[] payloadDataArray, Map<String,String> arbitraryDataMap)
          * Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher.
 boolean tryPublish(String streamId, Object[] metaDataArray, Object[] correlationDataArray, Object[] payloadDataArray, Map<String,String> arbitraryDataMap, long timeoutMS)
          Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataPublisher

public DataPublisher(String receiverURLSet,
                     String authURLSet,
                     String username,
                     String password)
              throws DataEndpointAgentConfigurationException,
                     DataEndpointException,
                     DataEndpointConfigurationException,
                     DataEndpointAuthenticationException,
                     org.wso2.carbon.databridge.commons.exception.TransportException
Creates the DataPublisher instance for a specific user, and the it creates connection asynchronously to receiver endpoint.

Parameters:
receiverURLSet - The receiving endpoint URL Set. This can be either load balancing URL set, or Failover URL set.
authURLSet - The authenticating URL Set for the endpoints given in receiverURLSet parameter. This should be in the same format as receiverURL set parameter.
username - Authorized username at receiver.
password - The password of the username provided.
Throws:
DataEndpointAgentConfigurationException
DataEndpointException
DataEndpointConfigurationException
DataEndpointAuthenticationException
org.wso2.carbon.databridge.commons.exception.TransportException

DataPublisher

public DataPublisher(String receiverURLSet,
                     String username,
                     String password)
              throws DataEndpointAgentConfigurationException,
                     DataEndpointException,
                     DataEndpointConfigurationException,
                     DataEndpointAuthenticationException,
                     org.wso2.carbon.databridge.commons.exception.TransportException
Creates the DataPublisher instance for a specific user, and the it creates connection asynchronously to receiver endpoint.

Parameters:
receiverURLSet - The receiving endpoint URL Set. This can be either load balancing URL set, or Failover URL set.
username - Authorized username at receiver.
password - The password of the username provided.
Throws:
DataEndpointAgentConfigurationException
DataEndpointException
DataEndpointConfigurationException
DataEndpointAuthenticationException
org.wso2.carbon.databridge.commons.exception.TransportException

DataPublisher

public DataPublisher(String type,
                     String receiverURLSet,
                     String authURLSet,
                     String username,
                     String password)
              throws DataEndpointAgentConfigurationException,
                     DataEndpointException,
                     DataEndpointConfigurationException,
                     DataEndpointAuthenticationException,
                     org.wso2.carbon.databridge.commons.exception.TransportException
Creates the DataPublisher instance for a specific user, and the it creates connection asynchronously to receiver endpoint.

Parameters:
type - The Agent name from which the DataPublisher that needs to be created. By default Thrift, and Binary is supported. The type should match with the element in the .
receiverURLSet - The receiving endpoint URL Set. This can be either load balancing URL set, or Failover URL set.
authURLSet - The authenticating URL Set for the endpoints given in receiverURLSet parameter. This should be in the same format as receiverURL set parameter.
username - Authorized username at receiver.
password - The password of the username provided.
Throws:
DataEndpointAgentConfigurationException
DataEndpointException
DataEndpointConfigurationException
DataEndpointAuthenticationException
org.wso2.carbon.databridge.commons.exception.TransportException
Method Detail

publish

public void publish(org.wso2.carbon.databridge.commons.Event event)
Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher. This is a blocking invocation until the event can be inserted in to internal queue for the publishing to the endpoint groups. But in case if any one or all of the receiver groups cannot send the event to the endpoint due to network connection failure, or Receiver node is unreachable or Receiver node has shutdown, and internal queue has become full then it will be blocked until the receiver is reachable again.

Parameters:
event - The Event that needs to sent for the receiver groups

publish

public void publish(String streamId,
                    Object[] metaDataArray,
                    Object[] correlationDataArray,
                    Object[] payloadDataArray)
Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher. This is a blocking invocation until the event can be inserted in to internal queue for the publishing to the endpoint groups. But in case if any one or all of the receiver groups cannot send the event to the endpoint due to network connection failure, or Receiver node is unreachable or Receiver node has shutdown, and internal queue has become full then it will be blocked until the receiver is reachable again.

Parameters:
streamId - StreamId for which the event belongs to.
metaDataArray - Meta data element of the event.
correlationDataArray - Correlation data element of the event.
payloadDataArray - Payload data element of the event.

publish

public void publish(String streamId,
                    Object[] metaDataArray,
                    Object[] correlationDataArray,
                    Object[] payloadDataArray,
                    Map<String,String> arbitraryDataMap)
Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher. This is a blocking invocation until the event can be inserted in to internal queue for the publishing to the endpoint groups. But in case if any one or all of the receiver groups cannot send the event to the endpoint due to network connection failure, or Receiver node is unreachable or Receiver node has shutdown, and internal queue has become full then it will be blocked until the receiver is reachable again.

Parameters:
streamId - StreamId for which the event belongs to.
metaDataArray - Meta data element of the event.
correlationDataArray - Correlation data element of the event.
payloadDataArray - Payload data element of the event.
arbitraryDataMap - Arbitrary data element of the event, which was not included in the stream definition of the event, and intermittent data.

publish

public void publish(String streamId,
                    long timeStamp,
                    Object[] metaDataArray,
                    Object[] correlationDataArray,
                    Object[] payloadDataArray)
Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher. This is a blocking invocation until the event can be inserted in to internal queue for the publishing to the endpoint groups. But in case if any one or all of the receiver groups cannot send the event to the endpoint due to network connection failure, or Receiver node is unreachable or Receiver node has shutdown, and internal queue has become full then it will be blocked until the receiver is reachable again.

Parameters:
streamId - StreamId for which the event belongs to.
metaDataArray - Meta data element of the event.
correlationDataArray - Correlation data element of the event.
payloadDataArray - Payload data element of the event.
timeStamp - Timestamp of the event.

publish

public void publish(String streamId,
                    long timeStamp,
                    Object[] metaDataArray,
                    Object[] correlationDataArray,
                    Object[] payloadDataArray,
                    Map<String,String> arbitraryDataMap)
Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher. This is a blocking invocation until the event can be inserted in to internal queue for the publishing to the endpoint groups. But in case if any one or all of the receiver groups cannot send the event to the endpoint due to network connection failure, or Receiver node is unreachable or Receiver node has shutdown, and internal queue has become full then it will be blocked until the receiver is reachable again.

Parameters:
streamId - StreamId for which the event belongs to.
metaDataArray - Meta data element of the event.
correlationDataArray - Correlation data element of the event.
payloadDataArray - Payload data element of the event.
timeStamp - Timestamp of the event.
arbitraryDataMap - Arbitrary data element of the event, which was not included in the stream definition of the event, and intermittent data.

tryPublish

public boolean tryPublish(org.wso2.carbon.databridge.commons.Event event)
Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher. This is a non-blocking invocation and if the queue if full then it will simply drop the event.

Parameters:
event - The event which needs to be published to the receiver groups
Returns:
the success/failure of the event that has been published/dropped.

tryPublish

public boolean tryPublish(org.wso2.carbon.databridge.commons.Event event,
                          long timeoutMS)
Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher. This is a non-blocking invocation and if the queue if full then it will wait until timeoutMS value, and try to insert into the queue. If the publisher still can't insert into the queue then it will return back with success/failure to the client.

Parameters:
event - The event which needs to be published to the receiver groups
timeoutMS - The timeout value to insert publish the event
Returns:
the success/failure of the event that has been published/dropped.

tryPublish

public boolean tryPublish(String streamId,
                          Object[] metaDataArray,
                          Object[] correlationDataArray,
                          Object[] payloadDataArray,
                          long timeoutMS)
Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher. This is a non-blocking invocation and if the queue if full then it will wait until timeoutMS value, and try to insert into the queue. If the publisher still can't insert into the queue then it will return back with success/failure to the client.

Parameters:
streamId - StreamId for which the event belongs to.
metaDataArray - Meta data element of the event.
correlationDataArray - Correlation data element of the event.
payloadDataArray - Payload data element of the event.
timeoutMS - The timeout value to insert publish the event
Returns:
the success/failure of the event that has been published/dropped.

tryPublish

public boolean tryPublish(String streamId,
                          Object[] metaDataArray,
                          Object[] correlationDataArray,
                          Object[] payloadDataArray,
                          Map<String,String> arbitraryDataMap,
                          long timeoutMS)
Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher. This is a non-blocking invocation and if the queue if full then it will wait until timeoutMS value, and try to insert into the queue. If the publisher still can't insert into the queue then it will return back with success/failure to the client.

Parameters:
streamId - StreamId for which the event belongs to.
metaDataArray - Meta data element of the event.
correlationDataArray - Correlation data element of the event.
payloadDataArray - Payload data element of the event.
arbitraryDataMap - Arbitrary data element of the event, which was not included in the stream definition of the event, and intermittent data.
timeoutMS - The timeout value to insert publish the event
Returns:
the success/failure of the event that has been published/dropped.

tryPublish

public boolean tryPublish(String streamId,
                          long timeStamp,
                          Object[] metaDataArray,
                          Object[] correlationDataArray,
                          Object[] payloadDataArray,
                          long timeoutMS)
Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher. This is a non-blocking invocation and if the queue if full then it will wait until timeoutMS value, and try to insert into the queue. If the publisher still can't insert into the queue then it will return back with success/failure to the client.

Parameters:
streamId - StreamId for which the event belongs to.
metaDataArray - Meta data element of the event.
correlationDataArray - Correlation data element of the event.
payloadDataArray - Payload data element of the event.
timeStamp - Time stamp of the event.
timeoutMS - The timeout value to insert publish the event
Returns:
the success/failure of the event that has been published/dropped.

tryPublish

public boolean tryPublish(String streamId,
                          long timeStamp,
                          Object[] metaDataArray,
                          Object[] correlationDataArray,
                          Object[] payloadDataArray,
                          Map<String,String> arbitraryDataMap,
                          long timeoutMS)
Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher. This is a non-blocking invocation and if the queue if full then it will wait until timeoutMS value, and try to insert into the queue. If the publisher still can't insert into the queue then it will return back with success/failure to the client.

Parameters:
streamId - StreamId for which the event belongs to.
metaDataArray - Meta data element of the event.
correlationDataArray - Correlation data element of the event.
payloadDataArray - Payload data element of the event.
arbitraryDataMap - Arbitrary data element of the event, which was not included in the stream definition of the event, and intermittent data.
timeStamp - Time stamp of the event.
timeoutMS - The timeout value to insert publish the event
Returns:
the success/failure of the event that has been published/dropped.

tryPublish

public boolean tryPublish(String streamId,
                          Object[] metaDataArray,
                          Object[] correlationDataArray,
                          Object[] payloadDataArray)
* Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher. This is a non-blocking invocation and if the queue if full then it will simply drop the event.

Parameters:
streamId - StreamId for which the event belongs to.
metaDataArray - Meta data element of the event.
correlationDataArray - Correlation data element of the event.
payloadDataArray - Payload data element of the event.
Returns:
the success/failure of the event that has been published/dropped.

tryPublish

public boolean tryPublish(String streamId,
                          Object[] metaDataArray,
                          Object[] correlationDataArray,
                          Object[] payloadDataArray,
                          Map<String,String> arbitraryDataMap)
* Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher. This is a non-blocking invocation and if the queue if full then it will simply drop the event.

Parameters:
streamId - StreamId for which the event belongs to.
metaDataArray - Meta data element of the event.
correlationDataArray - Correlation data element of the event.
payloadDataArray - Payload data element of the event.
arbitraryDataMap - Arbitrary data element of the event, which was not included in the stream definition of the event, and intermittent data.
Returns:
the success/failure of the event that has been published/dropped.

tryPublish

public boolean tryPublish(String streamId,
                          long timeStamp,
                          Object[] metaDataArray,
                          Object[] correlationDataArray,
                          Object[] payloadDataArray)
* Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher. This is a non-blocking invocation and if the queue if full then it will simply drop the event.

Parameters:
streamId - StreamId for which the event belongs to.
metaDataArray - Meta data element of the event.
correlationDataArray - Correlation data element of the event.
payloadDataArray - Payload data element of the event.
timeStamp - TimeStamp of the event.
Returns:
the success/failure of the event that has been published/dropped.

tryPublish

public boolean tryPublish(String streamId,
                          long timeStamp,
                          Object[] metaDataArray,
                          Object[] correlationDataArray,
                          Object[] payloadDataArray,
                          Map<String,String> arbitraryDataMap)
* Publish an event based on the event properties that are passed for all receiver groups which has been specified in the DataPublisher. This is a non-blocking invocation and if the queue if full then it will simply drop the event.

Parameters:
streamId - StreamId for which the event belongs to.
metaDataArray - Meta data element of the event.
correlationDataArray - Correlation data element of the event.
payloadDataArray - Payload data element of the event.
arbitraryDataMap - Arbitrary data element of the event, which was not included in the stream definition of the event, and intermittent data.
timeStamp - Timestamp of the event.
Returns:
the success/failure of the event that has been published/dropped.

shutdown

public void shutdown()
              throws DataEndpointException
Graceful shutdown of all the operations of the data publisher. It will flush all the events to the relevant endpoint, and closes all the resources and thread pools used for its operation. Once the shutdown operation is called you can't publish events using the data publisher.

Throws:
DataEndpointException

shutdownWithAgent

public void shutdownWithAgent()
                       throws DataEndpointException
Graceful shutdown of all the operations of the data publisher, and also if there is no other data publishers registered with the associated then it will shutdown the agent as well. Also during the data publisher shutdown it will flush all the events to the relevant endpoint, and closes all the resources and thread pools used for its operation. Once the shutdown operation is called you can't publish events using the data publisher.

Throws:
DataEndpointException


Copyright © 2015 WSO2. All rights reserved.