You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

When developing an application with Saga Library embedded, and connecting to the ElasticSearch manage by the Saga Server

This tutorial assumes, the reader ability to create a project with Maven Framework support

Step-by-step guide

  1. Configure pom.xml
  2. Main class
  3. Settings loading

Configure pom.xml

In the pom.xml of the project, a basic example of the minimum configuration can be found below. But elementary section of this configuration is the dependencies section, where we need two main libraries.

saga-library

The core library of Saga, this dependency includes the Engine, Stages, Tag Manager, Pipeline Manager and Resource Manager which are all the parts necessary to use Saga in any application.

saga-library

The core library of Saga, this dependency includes the Engine, Stages, Tag Manager, Pipeline Manager and Resource Manager which are all the parts necessary to use Saga in any application.

More indexers will be available in the future, but to use Saga full functionality we recommend the use of the saga-elastic-indexer.

Other important configuration to notice is the use of Java 11, for the compilation of the code and the encoding UTF-8, as you can see in the lines 36-38

pom.xml
<?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.accenture.saga</groupId>
    <artifactId>saga-howto</artifactId>
    <version>1.0.0-SNAPSHOT</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <saga.version>1.0.0</saga.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <executions>
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>testCompile</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <source>11</source>
                    <target>11</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>com.accenture.saga.server.SagaServer</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <appendAssemblyId>false</appendAssemblyId>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id> <!-- this is used for inheritance merges -->
                        <phase>package</phase> <!-- bind to the packaging phase -->
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>com.accenture.saga</groupId>
            <artifactId>saga-library</artifactId>
            <version>${saga.version}</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>com.accenture.saga</groupId>
            <artifactId>saga-elastic-indexer</artifactId>
            <version>${saga.version}</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
</project>

Main Class

For starters, we will create a main class, which will hold a SagaEngine, ResourceManager, TagManager and PipelineManager.

package com.accenture.saga;

import com.accenture.saga.engine.PipelineManager;
import com.accenture.saga.engine.SagaEngine;
import com.accenture.saga.resourcemgr.ResourceManager;
import com.accenture.saga.tags.TagManager;

public class Main {

    SagaEngine engine;
    ResourceManager resourceManager;
    TagManager tagManager;
    PipelineManager pipelineManager;

    public static void main(String[] args) {
        
    }
}


First we start by creating an configuring the ResourceManager


There is no content with the specified labels

  • No labels