Page History
When you leverage the Agent SDK to write either a sharer or a subscriberconsume or produce messages, you're writing a Java-based handler that is configured or plugged into the Perspectium Framework for performing various data replicating /service integration tasks.
The various handlers leverage the Perspectium Message class to represent the message or data that's being replicated and communicated shared via the Perspectium Message BusIntegration Mesh.
Perspectium Message
The Message class represents a message Perspectium Message that is being shared or subscribed to via the SDKproduced or consumed through the Integration Mesh. 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 Ssharing 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 a record from the incident table and the action associated with the row is that it was insertedis to insert the record.
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.
In the Perspectium Framework, a Sharer will produce messages to be shared to the Integration Mesh for consumption by another application. A Subscriber will consume messages from the Integration Mesh. So a Sharer will share messages to the Integration Mesh that a Subscriber will subscribe to and do action on (such as save the records into a database or another application).
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 Subscriber <subscribe> and the sharer 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 replicatedfrom the Integration Mesh. 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 Agent Configuration. Follow these steps:
UI Steps | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|