The Agent SDK for Java allows you to leverage the Perspectium Replication Framework to write your own Java applications to consume and produce messages with the Perspectium Integration Mesh. This provides you a way to integrate custom applications with Perspectium-supported applications.


Procedures 

To set up the Agent SDK, follow these steps:


Installation

Once you have obtained your Perspectium Agent SDK Account from Perspectium Support, you will need to add the Perspectium Maven Repository URL and login credentials to your Maven settings.xml file and your SDK project pom.xml file.

Setting up settings.xml

Since the Perspectium Nexus server requires authentication, you will also need to place your credentials in the Maven settings.xml in a servers element. There are two locations where a settings.xml file may live:

Maven install: $M2_HOME/conf/settings.xml 

User’s install: ${user.home}/.m2/settings.xml 

Here's a sample servers element using the default username and password for the deployment user:

<servers>
    <server>
      <id>perspectiumRepo</id>
      <username>your_username</username>
      <password>your_password</password>
    </server>
</servers>

Setting up pom.xml

Next, create a pom.xml file for your Java project with a dependency to the Perspectium Agent SDK library. The pom.xml will look similar to this:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
 
    <groupId>com.yourcompany</groupId>
    <artifactId>test-perspectium-sdk</artifactId>
    <version>1.0-SNAPSHOT</version>
 
    <dependencies>
        <dependency>
            <groupId>com.perspectium</groupId>
            <artifactId>perspectium-replicator-agent</artifactId>
            <version>5.0.0</version>
        </dependency>
    </dependencies>
 
    <repositories>
		<repository>
			<id>perspectium</id>
			<name>Perspectium</name>
			<url>https://nexus.perspectium.net/repository/public/</url>
		</repository>    
    </repositories>    
</project>


Sample Project

Click here to download a sample Java project that uses the Agent SDK. This project requires you have JDK and Maven installed on your computer.

You can import the project into your Integrated Development Environment (IDE) such as Eclipse or you can build the project and run the application in a terminal window.

To build and run in a terminal, follow these steps:


Unzip the attachment

Navigate to the folder where you downloaded the sample Java project zip file and unzip the file.

Build the project

Open up a terminal window and go into the directory where the file was unzipped and enter the following command to build the project:

mvn clean install 
./start.sh

This will use Maven to compile and build the project into a Java application that can then be run.

Run the application

In the same terminal window and in the same directory as the previous step, run the following command to run the application:

./start.sh

You will see the Java application publish messages and consume messages, logging out as it does these actions.