Closed gastaldi closed 5 years ago
You have to enable JNI as specified in the error message. Via Gradle this is done by --enable-jni
, via Maven by <enableJni>true</enableJni>
. Also you need the following reflect config:
[
{
"name" : "org.apache.activemq.artemis.api.core.client.loadbalance.RoundRobinConnectionLoadBalancingPolicy",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true
}, {
"name" : "org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true
}
]
I can confirm that the quarkus-artemis-jms
extension fixes the problem. Here is a sample REST endpoint illustrating how I tested it:
package org.acme;
import javax.inject.Inject;
import javax.jms.ConnectionFactory;
import javax.jms.JMSContext;
import javax.jms.Queue;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/hello")
public class GreetingResource {
@Inject
ConnectionFactory connectionFactory;
@GET
@Path("/produce")
@Produces(MediaType.TEXT_PLAIN)
public String produce() {
try (JMSContext jmsContext = connectionFactory.createContext()) {
Queue teste = jmsContext.createQueue("TEST");
jmsContext.createProducer().send(teste, "HELLO JMS WORLD!");
}
return "Published";
}
@GET
@Produces(MediaType.TEXT_PLAIN)
public String consume() {
String message = null;
try (JMSContext jmsContext = connectionFactory.createContext()) {
Queue teste = jmsContext.createQueue("TEST");
message = jmsContext.createConsumer(teste).receiveBodyNoWait(String.class);
}
return message;
}
}
I can't use the
org.apache.activemq:artemis-jms-client
dependency directly because it fails with the following error when creating the native image: