forked from wildfly/wildfly
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WFLY-18195] Added smallrye reactive messaging in-memory connector
- Loading branch information
Alexander Wagner
committed
Oct 5, 2023
1 parent
6386569
commit d72529a
Showing
12 changed files
with
377 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
.../main/resources/layers/standalone/microprofile-reactive-messaging-inmemory/layer-spec.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ JBoss, Home of Professional Open Source. | ||
~ Copyright 2023, 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. | ||
--> | ||
<layer-spec xmlns="urn:jboss:galleon:layer-spec:1.0" name="microprofile-reactive-messaging-inmemory"> | ||
<dependencies> | ||
<layer name="microprofile-reactive-messaging"/> | ||
</dependencies> | ||
|
||
<packages> | ||
<package name="io.smallrye.reactive.messaging.connector.inmemory"/> | ||
</packages> | ||
</layer-spec> |
52 changes: 52 additions & 0 deletions
52
...ules/system/layers/base/io/smallrye/reactive/messaging/connector/inmemory/main/module.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?xml version="1.0" ?> | ||
<!-- | ||
~ JBoss, Home of Professional Open Source. | ||
~ Copyright 2023, 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. | ||
--> | ||
<module xmlns="urn:jboss:module:1.9" name="io.smallrye.reactive.messaging.connector.inmemory"> | ||
|
||
<resources> | ||
<artifact name="${io.smallrye.reactive:smallrye-reactive-messaging-in-memory}"/> | ||
</resources> | ||
|
||
<dependencies> | ||
<module name="io.smallrye.config" services="import"/> | ||
<module name="io.smallrye.common.annotation"/> | ||
<module name="io.smallrye.reactive.converters.api"/> | ||
<module name="io.smallrye.reactive.messaging"/> | ||
<module name="io.smallrye.reactive.mutiny"/> | ||
<module name="io.smallrye.reactive.mutiny.reactive-streams-operators"/> | ||
<module name="io.smallrye.reactive.mutiny.zero"/> | ||
<module name="io.smallrye.reactive.mutiny.zero-flow-adapters"/> | ||
<module name="javax.annotation.api"/> | ||
<module name="javax.enterprise.api"/> | ||
<module name="org.eclipse.microprofile.reactive-messaging.api"/> | ||
<module name="org.eclipse.microprofile.reactive-streams-operators.api"/> | ||
<module name="org.eclipse.microprofile.reactive-streams-operators.core" services="import"/> | ||
<module name="org.eclipse.microprofile.config.api"/> | ||
<module name="org.jboss.logging"/> | ||
<module name="org.jboss.weld.api"/> | ||
<module name="org.jboss.weld.core"/> | ||
<module name="org.jboss.weld.spi"/> | ||
<module name="org.reactivestreams"/> | ||
<module name="org.wildfly.reactive.messaging.config" optional="true" export="true" services="export"/> | ||
<module name="org.slf4j"/> | ||
</dependencies> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
4 changes: 4 additions & 0 deletions
4
...src/main/resources/packages/io.smallrye.reactive.messaging.connector.inmemory/package.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" ?> | ||
|
||
<package-spec xmlns="urn:jboss:galleon:package:2.0" name="io.smallrye.reactive.messaging.connector.inmemory"> | ||
</package-spec> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ JBoss, Home of Professional Open Source. | ||
~ Copyright 2021, 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. | ||
--> | ||
|
||
<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</groupId> | ||
<artifactId>wildfly-microprofile-reactive-messaging-parent</artifactId> | ||
<!-- | ||
Maintain separation between the artifact id and the version to help prevent | ||
merge conflicts between commits changing the GA and those changing the V. | ||
--> | ||
<version>29.0.0.Beta1-SNAPSHOT</version> | ||
</parent> | ||
|
||
|
||
<artifactId>wildfly-microprofile-reactive-messaging-inmemory</artifactId> | ||
<name>WildFly: MicroProfile Reactive Messaging In-Memory</name> | ||
|
||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.smallrye.reactive</groupId> | ||
<artifactId>smallrye-reactive-messaging-in-memory</artifactId> | ||
<version>${version.io.smallrye.smallrye-reactive-messaging}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.smallrye.reactive</groupId> | ||
<artifactId>mutiny-zero-flow-adapters</artifactId> | ||
<version>${version.io.smallrye.smallrye-mutiny-zero}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.smallrye.reactive</groupId> | ||
<artifactId>mutiny-zero</artifactId> | ||
<version>${version.io.smallrye.smallrye-mutiny-zero}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.eclipse.microprofile.config</groupId> | ||
<artifactId>microprofile-config-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.logging</groupId> | ||
<artifactId>jboss-logging-annotations</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.logging</groupId> | ||
<artifactId>jboss-logging-processor</artifactId> | ||
<!-- | ||
This is a compile-time dependency of this project, but is not needed at compile or runtime by other | ||
projects that depend on this project. | ||
--> | ||
<scope>provided</scope> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.msc</groupId> | ||
<artifactId>jboss-msc</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.wildfly.core</groupId> | ||
<artifactId>wildfly-server</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>${full.maven.groupId}</groupId> | ||
<artifactId>wildfly-microprofile-reactive-messaging-common</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>${full.maven.groupId}</groupId> | ||
<artifactId>wildfly-microprofile-reactive-messaging-config</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...a/org/wildfly/test/integration/microprofile/reactive/messaging/inmemory/InMemoryBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2023, 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 org.wildfly.test.integration.microprofile.reactive.messaging.inmemory; | ||
|
||
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; | ||
|
||
@ApplicationScoped | ||
public class InMemoryBean { | ||
|
||
private String message; | ||
|
||
@Inject | ||
@Channel("to-inmemory") | ||
Emitter<String> outgoingEmitter; | ||
|
||
@Incoming("from-inmemory") | ||
public void incoming(String message) { | ||
this.message = message; | ||
} | ||
|
||
public void outgoing(String payload) { | ||
outgoingEmitter.send(payload); | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
} |
90 changes: 90 additions & 0 deletions
90
...tegration/microprofile/reactive/messaging/inmemory/ReactiveMessagingInMemoryTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2023, 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 org.wildfly.test.integration.microprofile.reactive.messaging.inmemory; | ||
|
||
import io.smallrye.reactive.messaging.memory.InMemoryConnector; | ||
import jakarta.enterprise.inject.Any; | ||
import jakarta.inject.Inject; | ||
import org.eclipse.microprofile.reactive.messaging.Message; | ||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.as.arquillian.api.ServerSetup; | ||
import org.jboss.as.test.shared.CLIServerSetupTask; | ||
import org.jboss.as.test.shared.TimeoutUtil; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.EmptyAsset; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.wildfly.test.integration.microprofile.reactive.EnableReactiveExtensionsSetupTask; | ||
|
||
import java.util.List; | ||
import java.util.PropertyPermission; | ||
|
||
import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset; | ||
|
||
/** | ||
* Run with | ||
* mvn clean install -DallTests -pl testsuite/integration/microprofile -Dtest=ReactiveMessagingInMemoryUserApiTestCase | ||
*/ | ||
@RunWith(Arquillian.class) | ||
@ServerSetup({EnableReactiveExtensionsSetupTask.class}) | ||
public class ReactiveMessagingInMemoryTestCase { | ||
|
||
@Inject | ||
InMemoryBean inMemoryBean; | ||
|
||
@Inject | ||
@Any | ||
InMemoryConnector connector; | ||
|
||
@Deployment | ||
public static WebArchive getDeployment() { | ||
|
||
return ShrinkWrap.create(WebArchive.class, "reactive-messaging-connector-inmemory.war") | ||
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml") | ||
.addPackage(ReactiveMessagingInMemoryTestCase.class.getPackage()) | ||
.addClasses(EnableReactiveExtensionsSetupTask.class, CLIServerSetupTask.class) | ||
.addAsWebInfResource(ReactiveMessagingInMemoryTestCase.class.getPackage(), "microprofile-config.properties", "classes/META-INF/microprofile-config.properties") | ||
.addClass(TimeoutUtil.class) | ||
.addAsManifestResource(createPermissionsXmlAsset( | ||
new PropertyPermission(TimeoutUtil.FACTOR_SYS_PROP, "read") | ||
), "permissions.xml"); | ||
} | ||
|
||
@Test | ||
public void testIncomingMessageSendFromInMemoryConnector() throws InterruptedException { | ||
connector.source("from-inmemory").send("IncomingTestMessage"); | ||
Assert.assertEquals("IncomingTestMessage",inMemoryBean.getMessage()); | ||
} | ||
|
||
@Test | ||
public void testOutgoingMessageReceivedByInMemoryConnector() throws InterruptedException { | ||
inMemoryBean.outgoing("OutgoingTestMessage"); | ||
List<? extends Message<Object>> messages = connector.sink("to-inmemory").received(); | ||
Assert.assertEquals(1,messages.size()); | ||
Assert.assertEquals("OutgoingTestMessage",messages.get(0).getPayload()); | ||
} | ||
|
||
} |
Oops, something went wrong.