Skip to content

Commit

Permalink
[WFLY-15405] Test for the MP Reactive Messaging AMQP Connnector
Browse files Browse the repository at this point in the history
  • Loading branch information
kabir committed Aug 14, 2024
1 parent 1f8c06d commit 12e1f9d
Show file tree
Hide file tree
Showing 13 changed files with 513 additions and 0 deletions.
49 changes: 49 additions & 0 deletions images/microprofile-reactive-messaging-amqp/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ JBoss, Home of Professional Open Source.
~ Copyright 2022 Red Hat, Inc., and individual contributors
~ as indicated by the @author tags.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->

<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>

<parent>
<groupId>org.wildfly.cloud-tests</groupId>
<artifactId>wildfly-cloud-test-images</artifactId>
<version>1.0.0.Alpha3-SNAPSHOT</version>
</parent>
<artifactId>image-microprofile-reactive-messaging-amqp</artifactId>
<packaging>pom</packaging>

<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<configuration>
<layers>
<layer>cloud-server</layer>
<layer>microprofile-reactive-messaging-amqp</layer>
</layers>
</configuration>
</plugin>

</plugins>
</build>
</project>
1 change: 1 addition & 0 deletions images/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<id>images</id>
<modules>
<module>cloud-server</module>
<module>microprofile-reactive-messaging-amqp</module>
<module>microprofile-reactive-messaging-kafka</module>
<module>datasources/postgresql</module>
<module>elytron-oidc-client</module>
Expand Down
6 changes: 6 additions & 0 deletions test-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@
<version>${project.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>image-microprofile-reactive-messaging-amqp</artifactId>
<version>${project.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>image-microprofile-reactive-messaging-kafka</artifactId>
Expand Down
1 change: 1 addition & 0 deletions tests/microprofile/reactive-messaging/amqp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Needed until https://github.com/dekorateio/dekorate/issues/1000 is fixed
66 changes: 66 additions & 0 deletions tests/microprofile/reactive-messaging/amqp/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ JBoss, Home of Professional Open Source.
~ Copyright 2022 Red Hat, Inc., and individual contributors
~ as indicated by the @author tags.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->

<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>

<parent>
<groupId>org.wildfly.cloud-tests</groupId>
<artifactId>wildfly-cloud-tests-microprofile-reactive-messaging</artifactId>
<version>1.0.0.Alpha3-SNAPSHOT</version>
</parent>
<artifactId>wildfly-cloud-tests-microprofile-reactive-messaging-amqp</artifactId>
<packaging>war</packaging>

<properties>
<wildfly.cloud.test.base.image.name>wildfly-cloud-test-image/image-microprofile-reactive-messaging-amqp:latest</wildfly.cloud.test.base.image.name>
</properties>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>image-microprofile-reactive-messaging-amqp</artifactId>
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.reactive.messaging</groupId>
<artifactId>microprofile-reactive-messaging-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2023 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.wildfly.test.cloud.microprofile.reactive.messaging.amqp;

import static io.dekorate.kubernetes.annotation.ImagePullPolicy.Always;

import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;

import io.dekorate.kubernetes.annotation.Env;
import io.dekorate.kubernetes.annotation.KubernetesApplication;

/**
* @author <a href="mailto:[email protected]">Kabir Khan</a>
*/
@KubernetesApplication(
envVars = {
@Env(name = "AMQP_HOST", value= "artemis")
},
imagePullPolicy = Always)
@ApplicationPath("")
public class ReactiveMessagingWithAmqpApp extends Application {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2023 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.wildfly.test.cloud.microprofile.reactive.messaging.amqp;

import java.util.ArrayList;
import java.util.List;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;

import org.eclipse.microprofile.reactive.messaging.Channel;
import org.eclipse.microprofile.reactive.messaging.Emitter;
import org.eclipse.microprofile.reactive.messaging.Incoming;

/**
* @author <a href="mailto:[email protected]">Kabir Khan</a>
*/
@ApplicationScoped
public class ReactiveMessagingWithAmqpBean {
@Inject
@Channel("to-amqp")
private Emitter<String> emitter;

private List<String> received = new ArrayList<>();

private boolean seenOne;

@Incoming("from-amqp")
public void receive(String value) {
System.out.println("Received: " + value);
if (value.equals("one")) {
if (seenOne) {
// Avoid adding duplicate 'one' entries since the test might send more than one. See the comment there
System.out.println("'one' already in list. Skipping");
return;
}
seenOne = true;
}
received.add(value);
}

void send(String value) {
System.out.println("Sending: " + value);
emitter.send(value);
}

public List<String> getReceived() {
return received;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2023 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.wildfly.test.cloud.microprofile.reactive.messaging.amqp;

import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON;

import java.util.List;

import jakarta.inject.Inject;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

/**
* @author <a href="mailto:[email protected]">Kabir Khan</a>
*/
@Path("")
public class ReactiveMessagingWithAmqpEndpoint {
@Inject
ReactiveMessagingWithAmqpBean bean;

@POST
@Path("{value}")
@Consumes(MediaType.TEXT_PLAIN)
public Response send(@PathParam("value") String value) {
bean.send(value);
return Response.ok().build();
}

@GET
@Produces(APPLICATION_JSON)
public List<String> getHelloWorldJSON() {
return bean.getReceived();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# JBoss, Home of Professional Open Source.
# Copyright 2022 Red Hat, Inc., and individual contributors
# as indicated by the @author tags.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#

amqp-port=5672
amqp-username=artemis
amqp-password=artemis
amqp-use-ssl=false

mp.messaging.outgoing.to-amqp.connector=smallrye-amqp
mp.messaging.outgoing.to-amqp.address=test

mp.messaging.incoming.from-amqp.connector=smallrye-amqp
mp.messaging.incoming.from-amqp.address=test

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
apiVersion: v1
kind: List
items:
- apiVersion: apps/v1
kind: Deployment
metadata:
name: artemis
labels:
app: artemis
spec:
replicas: 1
selector:
matchLabels:
app: artemis
template:
metadata:
labels:
app: artemis
spec:
containers:
- name: artemis
image: quay.io/artemiscloud/activemq-artemis-broker-kubernetes:1.0.23
env:
- name: AMQ_USER
value: artemis
- name: AMQ_PASSWORD
value: artemis
- name: AMQ_DATA_DIR
value: /home/jboss/data
# - name: AMQ_EXTRA_ARGS
# value: "--http-host 0.0.0.0 "
- name: SCRIPT_DEBUG
value: "true"
ports:
- containerPort: 5672
- containerPort: 8161
- containerPort: 61613
- apiVersion: v1
kind: Service
metadata:
name: artemis
spec:
selector:
app: artemis
ports:
- protocol: TCP
port: 5672
targetPort: 5672
name: amqp
- protocol: TCP
port: 8161
targetPort: 8161
name: http
- protocol: TCP
port: 61616
targetPort: 61613
name: all
Loading

0 comments on commit 12e1f9d

Please sign in to comment.