-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WFLY-18195] Added smallrye reactive messaging in-memory connector #54
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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> |
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> |
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> |
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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kuhhpid I don't think we need this module any longer? |
||
<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> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,6 +210,14 @@ | |
<scope>test</scope> | ||
</dependency> | ||
|
||
<!-- MicroProfile Reactive Messaging In-Memory Connector Test Dependencies --> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need this dependency. Basically, this pom is stuff that needs to be on the compile classpath. And the tests classes don't seem to contain anything from this module. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the Test the InMemoryConnector is used which come from smallrye-reactive-messaging-in-memory, so it is needed. Or did I not get the point here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I missed that. In that case I think the test looks a bit strange, in that it is using implementation details :-) Can you rework it so it uses @Outgoing/@incoming like the Kafka tests do? Generally we should just be using MP Reactive Messaging classes, and not SmallRye ones in user code (i.e the tests) |
||
<dependency> | ||
<groupId>io.smallrye.reactive</groupId> | ||
<artifactId>smallrye-reactive-messaging-in-memory</artifactId> | ||
<version>${version.io.smallrye.smallrye-reactive-messaging}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!-- MicroProfile Reactive Messaging Kafka Connector Test Dependencies --> | ||
<dependency> | ||
<groupId>io.smallrye.reactive</groupId> | ||
|
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; | ||
} | ||
|
||
} |
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()); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a license header like in the file above :-)