Skip to content

Commit

Permalink
Fix #257 to add quarkus-artemis-jms-ra
Browse files Browse the repository at this point in the history
  • Loading branch information
zhfeng committed Dec 2, 2023
1 parent 6fdc98f commit 39aa966
Show file tree
Hide file tree
Showing 37 changed files with 1,044 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ jobs:
--projects \
"core/deployment, \
jms/deployment, \
ra/deployment, \
${{ matrix.integration-test-module }}" \
verify
Expand Down Expand Up @@ -227,6 +228,7 @@ jobs:
--projects \
"core/deployment, \
jms/deployment, \
ra/deployment, \
${{ matrix.integration-test-module }}" \
verify
Expand Down Expand Up @@ -254,4 +256,4 @@ jobs:
checkout: 'true'
download-artifact-name: test-report-native
report-name: JUnit Native Test
report-path: '**/target/*-reports/TEST*.xml'
report-path: '**/target/*-reports/TEST*.xml'
26 changes: 26 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@
<artifactId>quarkus-artemis-jms-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkiverse.artemis</groupId>
<artifactId>quarkus-artemis-jms-ra</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkiverse.artemis</groupId>
<artifactId>quarkus-artemis-jms-ra-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkiverse.artemis</groupId>
<artifactId>quarkus-test-artemis</artifactId>
Expand Down Expand Up @@ -92,6 +102,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-jakarta-ra</artifactId>
<version>${artemis.version}</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-server</artifactId>
Expand Down Expand Up @@ -146,6 +161,17 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-hqclient-protocol</artifactId>
<version>${artemis.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-server</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
</project>
10 changes: 10 additions & 0 deletions build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.quarkiverse.ironjacamar</groupId>
<artifactId>quarkus-ironjacamar</artifactId>
<version>${quarkus-ironjacamar.version}</version>
</dependency>
<dependency>
<groupId>io.quarkiverse.ironjacamar</groupId>
<artifactId>quarkus-ironjacamar-deployment</artifactId>
<version>${quarkus-ironjacamar.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.quarkus.artemis.core.deployment.health;

import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -34,12 +35,19 @@ ArtemisHealthSupportBuildItem healthSupport(
ShadowRuntimeConfigs shadowRunTimeConfigs,
ArtemisBuildTimeConfigs buildTimeConfigs,
BuildProducer<SyntheticBeanBuildItem> syntheticBeanProducer,
List<ExtraArtemisHealthCheckBuildItem> extras,
ArtemisHealthSupportRecorder recorder) {
if (!buildTimeConfigs.isHealthEnabled()) {
return null;
}
Set<String> names = bootstrap.getConfigurationNames();
Set<String> names = new HashSet<>(bootstrap.getConfigurationNames());
Set<String> excludedNames = processConfigs(names, shadowRunTimeConfigs, buildTimeConfigs);
for (ExtraArtemisHealthCheckBuildItem extra : extras) {
String name = extra.getName();
if (!excludedNames.contains(name)) {
names.add(name);
}
}
syntheticBeanProducer.produce(SyntheticBeanBuildItem
.configure(ArtemisHealthSupport.class)
.supplier(recorder.getArtemisSupportBuilder(names, excludedNames))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.quarkus.artemis.core.deployment.health;

import io.quarkus.builder.item.MultiBuildItem;

public final class ExtraArtemisHealthCheckBuildItem extends MultiBuildItem {
private final String name;

public ExtraArtemisHealthCheckBuildItem(String name) {
this.name = name;
}

public String getName() {
return name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ public Supplier<ServerLocator> getServerLocatorSupplier(
ArtemisRuntimeConfig runtimeConfig = runtimeConfigs.configs().get(name);
ArtemisBuildTimeConfig buildTimeConfig = buildTimeConfigs.configs().get(name);
ArtemisUtil.validateIntegrity(name, runtimeConfig, buildTimeConfig);
ServerLocator serverLocator = Objects.requireNonNull(getServerLocator(runtimeConfig));
ServerLocator serverLocator = Objects.requireNonNull(getServerLocator(runtimeConfig.getUrl()));
return () -> serverLocator;
}

private static ServerLocator getServerLocator(ArtemisRuntimeConfig runtimeConfig) {
String url = runtimeConfig.getUrl();
protected static ServerLocator getServerLocator(String url) {
if (url != null) {
try {
return ActiveMQClient.createServerLocator(url);
Expand Down
5 changes: 5 additions & 0 deletions docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,10 @@
<artifactId>quarkus-artemis-jms-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkiverse.artemis</groupId>
<artifactId>quarkus-artemis-jms-ra-deployment</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ quarkus.artemis.xa-enabled=true
quarkus.artemis."named-1".devservices.enabled=false
quarkus.artemis."named-1".xa-enabled=true
quarkus.artemis."named-2".enabled=false
artemis.externally-defined.url=tcp://dummy
artemis.externally-defined.url=tcp://dummy
quarkus.log.category."org.apache.activemq.audit".level=WARN
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ quarkus.artemis.xa-enabled=true
quarkus.artemis."named-1".url=tcp://dummy-1:23456
quarkus.artemis."named-1".devservices.enabled=false
quarkus.artemis."named-1".xa-enabled=true
quarkus.artemis."named-2".enabled=false
quarkus.artemis."named-2".enabled=false
quarkus.log.category."org.apache.activemq.audit".level=WARN
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ quarkus.artemis.health-exclude=true
quarkus.artemis.xa-enabled=true
quarkus.artemis."named-1".devservices.enabled=false
quarkus.artemis."named-1".xa-enabled=true
quarkus.artemis."named-2".enabled=false
quarkus.artemis."named-2".enabled=false
quarkus.log.category."org.apache.activemq.audit".level=WARN
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
quarkus.log.category."org.apache.activemq.audit".level=WARN
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
quarkus.artemis."named-1".devservices.enabled=false
quarkus.artemis."named-1".xa-enabled=true
quarkus.artemis."named-2".enabled=false
quarkus.artemis."named-2".enabled=false
quarkus.log.category."org.apache.activemq.audit".level=WARN
1 change: 1 addition & 0 deletions integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<module>common-parent</module>
<module>core</module>
<module>jms</module>
<module>ra</module>
</modules>

<build>
Expand Down
63 changes: 63 additions & 0 deletions integration-tests/ra/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.quarkiverse.artemis</groupId>
<artifactId>quarkus-artemis-integration-tests-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>

<artifactId>quarkus-integration-test-artemis-jms-ra</artifactId>
<name>Quarkus - Artemis - Integration Tests - JMS Resource Adapter</name>
<description>The Apache ActiveMQ Artemis JMS Resource Adapter integration tests</description>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm-panache</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-postgresql</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-narayana-jta</artifactId>
</dependency>

<!-- Artemis -->
<dependency>
<groupId>io.quarkiverse.artemis</groupId>
<artifactId>quarkus-artemis-jms-ra</artifactId>
</dependency>

<!-- Test -->
<dependency>
<groupId>io.quarkiverse.artemis</groupId>
<artifactId>quarkus-integration-test-artemis-common</artifactId>
<classifier>tests</classifier>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.24.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.quarkus.it.artemis.ra;

import jakarta.persistence.Entity;

import io.quarkus.hibernate.orm.panache.PanacheEntity;

@Entity
public class Gift extends PanacheEntity {

public String name;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package io.quarkus.it.artemis.ra;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.JMSContext;
import jakarta.jms.JMSProducer;
import jakarta.jms.Queue;
import jakarta.jms.TextMessage;
import jakarta.transaction.Transactional;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.DefaultValue;
import jakarta.ws.rs.FormParam;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.QueryParam;

import io.quarkus.narayana.jta.QuarkusTransaction;

@Path("/jca")
@ApplicationScoped
public class JcaResource {
// add some rest methods here

@Inject
ConnectionFactory factory;

@GET
@Transactional
public String hello(@QueryParam("name") @DefaultValue("JCA") String name) {
try (JMSContext context = factory.createContext()) {
Queue myQueue = context.createQueue("MyQueue");
JMSProducer producer = context.createProducer();
producer.send(myQueue, "Hello " + name);
Gift gift = new Gift();
gift.name = name;
gift.persist();
if (name.equals("rollback")) {
QuarkusTransaction.setRollbackOnly();
}
}
return "Hello " + name;
}

@POST
@Transactional
@Path("/sales")
public void sendToSalesQueue(@FormParam("name") String name) throws Exception {
try (JMSContext context = factory.createContext()) {
JMSProducer producer = context.createProducer();
TextMessage msg = context.createTextMessage(name);
msg.setJMSReplyTo(context.createQueue("inventory"));
producer.send(context.createQueue("sales"), msg);
}
}

@DELETE
@Path("/gifts")
@Transactional
public void deleteGifts() {
Gift.deleteAll();
}

@GET
@Path("/gifts/count")
@Transactional
public long countGifts() {
return Gift.count();
}

@GET
@Path("/transacted")
@Transactional
public boolean Transacted() {
return isTransacted();
}

@GET
@Path("/not-transacted")
public boolean notTransacted() {
return isTransacted();
}

private boolean isTransacted() {
try (JMSContext context = factory.createContext()) {
return context.getTransacted();
}
}
}
Loading

0 comments on commit 39aa966

Please sign in to comment.