Page History
When you leverage the Agent SDK to write either a sharer or a subscriber, you're writing a Java based handler that is configured or plugged into the Perspectium Framework for performing various data replicating tasks.
The various handlers leverage the Message class to represent the message or data that's being replicated and communicated via the Perspectium Message Bus.
Message
The Message class represents a message that is being shared or subscribed to via the SDK. The class has the following properties:
- Topic
- Type
- Key
- Name
- Value
The meaning of these properties and their values are context dependent and typically coordinated between a producer and consumer. The sharer or producer will drive the value and meaning of each of these properties. In most cases, topic, type, key and name are mandatory. The value property represents the message's payload.
Name Overloading
The Message class provides the getName() method which is used to retrieve the Name value. In some cases, the handler or sharer of data leverages this property to mean more than one thing. For example, when Sharing a table from a ServiceNow instance, the value is structured such that it contains the name of the table followed by a '.' period separator and then the action associated with the table row contained within the Value keys value. For example getName() could return a String such as 'incident.insert'. The row contained within the value key's value is from the incident table and the action associated with the row is that it was inserted.
Writing Handlers
A handler is the actual software or Java class that's defined or plugged into the framework by using the <handler> directive to perform the replication.
Each handler will have access to its <task> section of the overall configuration. Two types of handlers that can be configured within the <agent> tag, the subscriber <subscribe> and the sharer <share>. Each of these directives will have zero or more nested <task> elements. Each <task> element will likely have unique directives that are required so the handler can perform its work.
Writing a Sharer
Each Sharer handler you write must extend the abstract class ASharer and implement the method public void processMessages().
As a Sharer type handler you are sharing or producing data that is being replicated. The data that you are replicating is placed into a Message and then shared to the Perspectium Framework using the publish(<Message>) method available as part of the SDK. The framework handles encryption of the message prior to being placed into the Message Bus with TripleDES.
Writing a Subscriber
Each Subscriber based handler you write must extend the abstract class ASubscriber and implement the method public boolean processMessage(Message message) throws SubscribeException.
As a Subscriber type handler you're subscribing to or consuming data to be replicated. The Perspectium Framework schedules your handler to run based on the type of scheduling that gets configured at the <task> level. The framework calls your processMessage(Message message) method with an available message from the Message Bus. The Message you receive is unencrypted for you by the framework.
See SDK Subscriber Example here.
Optionally, the agent supports reporting errors and acknowledgements back to the sender. This feature includes an extended SDK API for customizing reporting. For more information about the reporting feature and to view a sample Subscriber, see Reporting with the DataSync Agent SDK.
Quick Start
To embed the SDK agent in your own Java code, make sure you have the correct configuration documented here correct Agent Configuration. Then, follow Follow these steps:
UI Steps | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|