Skip to content

Commit

Permalink
Small adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed Aug 6, 2021
1 parent 1ade264 commit dac5303
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 76 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

////
This guide is maintained in the main Quarkus repository
and pull requests should be submitted there:
https://github.com/quarkusio/quarkus/tree/master/docs/src/main/asciidoc
////
= Quarkus - Narayana LRA Participant Support
= Narayana LRA Participant Support

include::./attributes.adoc[]

Expand All @@ -18,7 +17,7 @@ retaining the option to compensate for any actions performed during the computat
This kind of loose coupling of services bridges the gap between strong consistency models
such as JTA/XA and "home grown" ad hoc consistency solutions.

The model is based on the https://github.com/eclipse/microprofile-lra/blob/master/spec/src/main/asciidoc/microprofile-lra-spec.adoc#eclipse-microprofile-lra[Eclipse Microprofile LRA specification].
The model is based on the https://github.com/eclipse/microprofile-lra/blob/master/spec/src/main/asciidoc/microprofile-lra-spec.adoc#eclipse-microprofile-lra[Eclipse MicroProfile LRA specification].
The approach is for the developer to annotate a business method with a Java annotation
(https://download.eclipse.org/microprofile/microprofile-lra-1.0/apidocs/[`@LRA`]).
When such a method is called, an LRA context is created (if one is not already present) which is passed
Expand All @@ -43,15 +42,15 @@ https://download.eclipse.org/microprofile/microprofile-lra-1.0/apidocs/[MicroPro

== Configuration

Once you have your Quarkus maven project configured you can add the `narayana-lra` extension
Once you have your Quarkus Maven project configured you can add the `narayana-lra` extension
by running the following command in your project base directory:

[source,bash]
----
./mvnw quarkus:add-extension -Dextensions="narayana-lra"
----

This will add the following to your pom.xml
This will add the following to your pom.xml:

[source,xml]
----
Expand All @@ -74,11 +73,11 @@ coordinator, for example:
quarkus.lra.coordinator-url=http://localhost:8080/lra-coordinator
----

For a narayana coordinator the path component of the url is normally `lra-coordinator`.
For a Narayana coordinator the path component of the url is normally `lra-coordinator`.
Coordinators can be obtained from `https://hub.docker.com/r/jbosstm/lra-coordinator`
or you can build your own coordinator using a maven pom that includes the appropriate
dependencies. A quarkus quickstart will be provided to show how to do this or you can
take a look at one of the https://github.com/jbosstm/quickstart/tree/master/rts/lra-examples/lra-coordinator[narayana quickstarts].
dependencies. A Quarkus quickstart will be provided to show how to do this or you can
take a look at one of the https://github.com/jbosstm/quickstart/tree/master/rts/lra-examples/lra-coordinator[Narayana quickstarts].
Another option would be to run it managed inside a WildFly application server.

== Handling failures
Expand All @@ -94,7 +93,7 @@ participants have acknowledged that they have finished.
The coordinator is responsible for reliably creating and ending LRAs and for managing
participant enlistment and it therefore must be available (for example if it or the
network fail then something in the environment is responsible for restarting
the coordinator or for repairing the network, respectively). To fulfil this task the
the coordinator or for repairing the network, respectively). To fulfill this task the
coordinator must have access to durable storage for its logs (via a filesystem or in
a database). At the time of writing, managing coordinators is the responsibility of
the user. An "out-of-the-box" solution will be forthcoming.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,15 @@
import io.quarkus.narayana.lra.runtime.LRAConfiguration;
import io.quarkus.narayana.lra.runtime.NarayanaLRAProducers;
import io.quarkus.narayana.lra.runtime.NarayanaLRARecorder;
import io.quarkus.resteasy.common.spi.ResteasyDotNames;

class NarayanaLRAProcessor {

@BuildStep
void registerFeature(BuildProducer<FeatureBuildItem> feature) {
feature.produce(new FeatureBuildItem(Feature.NARAYANA_LRA));
}

@BuildStep
@Record(RUNTIME_INIT)
public void build(NarayanaLRARecorder recorder,
Expand All @@ -46,7 +53,7 @@ void createLRAParticipantRegistry(NarayanaLRARecorder recorder,
final List<String> classNames = new ArrayList<>();

IndexView index = beanArchiveIndex.getIndex();
Collection<AnnotationInstance> annotations = index.getAnnotations(DotName.createSimple("javax.ws.rs.Path"));
Collection<AnnotationInstance> annotations = index.getAnnotations(ResteasyDotNames.PATH);

for (AnnotationInstance annotation : annotations) {
ClassInfo classInfo;
Expand Down Expand Up @@ -79,7 +86,8 @@ private boolean isLRAParticipant(IndexView index, ClassInfo classInfo) {
return false;
} else if (!annotations.containsKey(DotNames.COMPENSATE) && !annotations.containsKey(DotNames.AFTER_LRA)) {
throw new IllegalStateException(String.format("%s: %s",
classInfo.name(), "The class contains an LRA method and no Compensate or AfterLRA method was found."));
classInfo.name(),
"The class contains a method annotated with @LRA and no method annotated with @Compensate or @AfterLRA was found."));
} else {
return true;
}
Expand Down Expand Up @@ -121,11 +129,6 @@ private static Map<DotName, List<AnnotationInstance>> getInterfaceAnnotations(Li
return annotations;
}

@BuildStep
void registerFeature(BuildProducer<FeatureBuildItem> feature) {
feature.produce(new FeatureBuildItem(Feature.NARAYANA_LRA));
}

@BuildStep
void registerBeans(BuildProducer<AdditionalBeanBuildItem> additionalBeans) {
additionalBeans.produce(AdditionalBeanBuildItem.builder()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2019, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package io.narayana.lra.client.internal.proxy.nonjaxrs;

import static io.narayana.lra.LRAConstants.AFTER;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2019, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package io.narayana.lra.client.internal.proxy.nonjaxrs;

import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import javax.enterprise.context.Dependent;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.CDI;

import io.narayana.lra.client.internal.proxy.ParticipantProxyResource;
import io.narayana.lra.client.internal.proxy.nonjaxrs.LRAParticipantRegistry;
Expand All @@ -16,7 +15,6 @@ public LRAParticipantRegistry lraParticipantRegistry() {

@Produces
public ParticipantProxyResource participantProxyResource() {
Object proxy = CDI.current().select(ParticipantProxyResource.class);
return new ParticipantProxyResource();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
artifact: ${project.groupId}:${project.artifactId}:${project.version}
name: "Narayana LRA - LRA Participant Support"
metadata:
keywords:
- "narayana-lra"
- "narayana"
- "lra"
- "compensations"
- "transactions"
- "transaction"
- "saga"
guide: "https://quarkus.io/guides/lra"
categories:
- "data"
status: "preview"

0 comments on commit dac5303

Please sign in to comment.