Skip to content

Instantly share code, notes, and snippets.

Avatar

Paul Parkinson paulparkinson

View GitHub Profile
@paulparkinson
paulparkinson / StartLRAExampleAppServices
Created Sep 14, 2019
LRA: start example application services
View StartLRAExampleAppServices
java -jar lra-coordinator-helidon/target/lra-coordinator-helidon-0.0.1-SNAPSHOT.jar
java -jar order/target/order-0.0.1-SNAPSHOT.jar
java -jar inventory/target/inventory-0.0.1-SNAPSHOT.jar
View RegisterClientLRA.java
public OrderResource() {
client = ClientBuilder.newBuilder()
.register(ClientLRARequestFilter.class)
.register(ClientLRAResponseFilter.class)
.build();
}
@paulparkinson
paulparkinson / lraparticipantdependencies.pom
Last active Sep 13, 2019
LRA participant: pom dependencies
View lraparticipantdependencies.pom
<dependency>
<groupId>org.eclipse.microprofile.lra</groupId>
<artifactId>microprofile-lra-api</artifactId>
<version>1.0-RC1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jboss.narayana.rts</groupId>
<artifactId>lra-client</artifactId>
<version>${narayana.lra.version}</version>
@paulparkinson
paulparkinson / LRAFilterRegistrationDynamicFeature.java
Last active Sep 13, 2019
LRA FilterRegistration DynamicFeature
View LRAFilterRegistrationDynamicFeature.java
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> s = new HashSet<Class<?>>();
s.add(FilterRegistration.class);
//...
return s;
}
@paulparkinson
paulparkinson / lra-compensationrun-steps.sh
Last active Sep 14, 2019
LRA: steps to run compensation case
View lra-compensationrun-steps.sh
curl http://localhost:8091/inventory/removeInventory
curl http://localhost:8090/order/placeOrder
@paulparkinson
paulparkinson / lra-successrun-steps.sh
Last active Sep 14, 2019
LRA: steps to run success case
View lra-successrun-steps.sh
curl http://localhost:8091/inventory/addInventory
curl http://localhost:8090/order/placeOrder
@paulparkinson
paulparkinson / lra-coordinator.pom
Last active Sep 14, 2019
LRA: coordinator pom
View lra-coordinator.pom
<dependency>
<groupId>org.jboss.narayana.rts</groupId>
<artifactId>lra-coordinator</artifactId>
<version>${narayana.lra.version}</version>
<type>war</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jboss.narayana.rts</groupId>
<artifactId>lra-service-base</artifactId>
@paulparkinson
paulparkinson / InventoryResource.java
Last active Sep 14, 2019
LRA participant: inventory service
View InventoryResource.java
@Path("/reserveInventoryForOrder")
@GET
@Produces(MediaType.APPLICATION_JSON)
@LRA(value = LRA.Type.MANDATORY, end = false)
public Response reserveInventoryForOrder(@HeaderParam(LRA_HTTP_CONTEXT_HEADER) String lraId) {
//...
if(inventoryExists) return Response.ok().entity("inventorysuccess").build();
else return Response.ok().entity("inventoryfailure").build();
}
@paulparkinson
paulparkinson / lraparticipantannotationchecker.pom
Last active Sep 13, 2019
LRA participant annotation checker: pom
View lraparticipantannotationchecker.pom
<plugin>
<groupId>org.jboss.narayana.rts</groupId>
<artifactId>lra-annotation-checker-maven-plugin</artifactId>
<version>${narayana.lra.version}</version>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
@paulparkinson
paulparkinson / OrderResource.java
Last active Sep 14, 2019
LRA participant: order service
View OrderResource.java
@Path("/placeOrder")
@GET
@Produces(MediaType.APPLICATION_JSON)
@LRA(value = LRA.Type.REQUIRES_NEW)
public Response placeOrder(@HeaderParam(LRA_HTTP_CONTEXT_HEADER) String lraId) {
//...
}
@Path("/cancelOrder")