Football-player-market-microservice-lra

This is the key module of our scenario.

Here, we will organize the invocations to the microservices football-player-microservice-lra and football-player-offer-microservice-lra microservices as is required to implement our business logic.

We will analyze the two key points of this microservice, in detail:

  • The Maven pom.xml, with the right dependencies
  • The RESTful endpoint to understand the logic of the LRA specifications

Let's start with pom.xml, as follows:

<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.packtpub.thorntail</groupId>
<artifactId>football-player-market-microservice-lra</artifactId>
<name>Thorntail Football player market microservice LRA</name>
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>

<properties>
<version.thorntail>2.1.0.Final</version.thorntail>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.resteasy>3.0.19.Final</version.resteasy>
<lra.http.host>localhost</lra.http.host>
<lra.http.port>8580</lra.http.port>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.thorntail</groupId>
<artifactId>bom</artifactId>
<version>${version.thorntail}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<finalName>football-player-market-microservice-lra</finalName>
<plugins>
<plugin>
<groupId>io.thorntail</groupId>
<artifactId>thorntail-maven-plugin</artifactId>
<version>${version.thorntail}</version>

<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
<configuration>
<properties>
<lra.http.host>${lra.http.host}</lra.http.host>
<lra.http.port>${lra.http.port}</lra.http.port>
<swarm.port.offset>400</swarm.port.offset>
</properties>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>io.thorntail</groupId>
<artifactId>microprofile</artifactId>
</dependency>
<dependency>
<groupId>io.thorntail</groupId>
<artifactId>transactions</artifactId>
<scope>provided</scope>
</dependency>
<!-- LRA JAXRS filters -->
<dependency>
<groupId>org.jboss.narayana.rts</groupId>
<artifactId>lra-filters</artifactId>
<version>5.9.0.Final</version>
</dependency>
<dependency>
<groupId>io.thorntail</groupId>
<artifactId>jaxrs</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.thorntail</groupId>
<artifactId>cdi</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>${version.resteasy}</version>
<scope>provided</scope>
</dependency>
<!-- CORS Support For JAX-RS 2.0 / JavaEE 7 -->
<dependency>
<groupId>com.airhacks</groupId>
<artifactId>jaxrs-cors</artifactId>
<version>0.0.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

The key points are as follows:

  • The minimum Thorntail version that's required is 2.1.0
  •  lra.http.port and lra.http.host are needed to connect to the LRA coordinator
  • The dependencies are needed to perform RESTful invocations and to handle the LRA

Now, we will analyze the RESTful endpoint.

We will categorize a four-part class to analyze the key elements of the implementation, given as follows:

  • Initialize
  • A business method that represents our LRA
  • The complete phase
  • The compensate phase
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset