amqphub / amqp-10-resource-adapter Goto Github PK
View Code? Open in Web Editor NEWAn AMQP 1.0 JCA resource adapter
License: GNU Lesser General Public License v2.1
An AMQP 1.0 JCA resource adapter
License: GNU Lesser General Public License v2.1
I'm trying to use this AMQ Resource Adapter in my project that runs on OpenLiberty. I'm currently at the point where I can succesfully inject a JMSContext
in my CDI bean, using this snippet
@Inject
@JMSConnectionFactory("jms/JmsFactory")
private JMSContext jmsContext;
My next step would be to inject a Queue
or Destination
so I can actually publish messages. @bpaskin explained to me that this resource adapter does not declare the proper admin objects for the Queue
or Destination
interfaces.
I've tried to craft some, by extending ra.xml as follows:
<adminobject>
<adminobject-interface>javax.jms.Queue</adminobject-interface>
<adminobject-class>org.apache.qpid.jms.JmsQueue</adminobject-class>
</adminobject>
<adminobject>
<adminobject-interface>javax.jms.TemporaryQueue</adminobject-interface>
<adminobject-class>org.apache.qpid.jms.JmsTemporaryQueue</adminobject-class>
</adminobject>
<adminobject>
<adminobject-interface>javax.jms.Destination</adminobject-interface>
<adminobject-class>org.apache.qpid.jms.JmsDestination</adminobject-class>
</adminobject>
I've then packaged and deployed the resource adapter. Now OpenLiberty attempts to inject the proper types, but it fails:
[ERROR ] CWOWB1000E: A CDI error has occurred: CWNEN0030E: The server was unable to obtain an object instance for the java:comp/env/it.mulders.junk.rabbitmq.MessageServiceFactory/queue1 reference. The exception message was: CWNEN1006E: The server was unable to obtain an object for the jms/ExampleQueue1 binding with the javax.jms.Queue type. The exception message was: java.lang.NoSuchMethodException: org.apache.qpid.jms.JmsDestination.<init>()
[ERROR ] CWOWB1000E: A CDI error has occurred: CWNEN0030E: The server was unable to obtain an object instance for the java:comp/env/it.mulders.junk.rabbitmq.MessageServiceFactory/queue1 reference. The exception message was: CWNEN1006E: The server was unable to obtain an object for the jms/ExampleQueue1 binding with the javax.jms.Queue type. The exception message was: java.lang.NoSuchMethodException: org.apache.qpid.jms.JmsDestination.<init>()
Indeed, the JmsDestination
class lacks a no-arg constructor. Is this something to address in this resource adapter or does this require a change in Apache QPid?
Is it possible to pass additional properties to a connection? Like vhost, exclusive consumer, ect. I tried several ways but none of them worked. Thx.
In the following log message, I can see my password in clear. Twice.
14:24:51,513 WARN [org.jboss.resource.adapter.jms.JmsManagedConnection] (QpidJMS Connection Executor: ID:a340d7e7-a228-4730-b8ab-3bc7a1f66b41:1) Handling jms exception failure: JmsManagedConnection{mcf=org.jboss.resource.adapter.jms.JmsManagedConnectionFactory@1f572370, info=JmsConnectionRequestInfo{userName=example, password=example, clientID=null, transacted=false, acknowledgeMode=1, type=3}, user=example, pwd=example, isSetUp=true, isDestroyed=false, lock=org.jboss.resource.adapter.jms.ReentrantLock@317e1235[Unlocked], con=org.jboss.resource.adapter.jms.JmsConnectionSession@4b199ffd, session=class org.apache.qpid.jms.JmsSession@1532118793, xaSession=null, xaResource=null, xaTransacted=false, context=org.apache.qpid.jms.JmsContext@3fb9fa6a, xaContext=null}: org.apache.qpid.jms.exceptions.JmsConnectionFailedException: The JMS connection has failed: Transport connection remotely closed.
at deployment.resource-adapter.rar//org.apache.qpid.jms.provider.exceptions.ProviderFailedException.toJMSException(ProviderFailedException.java:35)
at deployment.resource-adapter.rar//org.apache.qpid.jms.provider.exceptions.ProviderFailedException.toJMSException(ProviderFailedException.java:21)
at deployment.resource-adapter.rar//org.apache.qpid.jms.exceptions.JmsExceptionSupport.create(JmsExceptionSupport.java:80)
at deployment.resource-adapter.rar//org.apache.qpid.jms.exceptions.JmsExceptionSupport.create(JmsExceptionSupport.java:112)
at deployment.resource-adapter.rar//org.apache.qpid.jms.JmsConnection.onAsyncException(JmsConnection.java:1546)
at deployment.resource-adapter.rar//org.apache.qpid.jms.JmsConnection.onProviderException(JmsConnection.java:1530)
at deployment.resource-adapter.rar//org.apache.qpid.jms.JmsConnection.onConnectionFailure(JmsConnection.java:1374)
at deployment.resource-adapter.rar//org.apache.qpid.jms.provider.amqp.AmqpProvider.fireProviderException(AmqpProvider.java:1150)
at deployment.resource-adapter.rar//org.apache.qpid.jms.provider.amqp.AmqpProvider.lambda$onTransportClosed$18(AmqpProvider.java:914)
at deployment.resource-adapter.rar//io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at deployment.resource-adapter.rar//io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
at deployment.resource-adapter.rar//io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:384)
at deployment.resource-adapter.rar//io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at deployment.resource-adapter.rar//io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.apache.qpid.jms.provider.exceptions.ProviderFailedException: Transport connection remotely closed.
... 7 more
Attempting to get the adapter to work in Liberty however I'm encountering JBoss exceptions
liberty xml setup
<?xml version="1.0" encoding="UTF-8"?>
<server>
<!-- JMS CONFIGURATION -->
<resourceAdapter id="amqp" location="${server.config.dir}/resources/lib/resource-adapter/resource-adapter-1.0.0.rar">
<classloader apiTypeVisibility="+third-party"/>
</resourceAdapter>
<connectionFactory jndiName="jms/typedagkalender/kalenderupdates/queueCF" connectionManagerRef="ConMgr">
<!-- using .amqp as that is the ID for the resource adapter -->
<properties.amqp DeleteTemporaryDestinations="true"
ConnectionFactory="factory1"
JndiParameters="java.naming.factory.initial=org.apache.qpid.jms.jndi.JmsInitialContextFactory;connectionFactory.factory1=amqp://localhost:5672"
UserName="guest"
Password="guest" />
</connectionFactory>
</server>`
snippet of code where the exception happens
@Resource(name = "TypedagKalenderQueueCF", type = javax.jms.QueueConnectionFactory.class, authenticationType = CONTAINER, shareable = true)
private QueueConnectionFactory queueConnectionFactory;
@Resource(name = "TypedagKalenderQueue", type = javax.jms.Queue.class, authenticationType = CONTAINER, shareable = true)
private Queue queue;
QueueConnection queueConnection = null;
QueueSession queueSession = null;
QueueSender queueSender = null;
try {
queueConnection = queueConnectionFactory.createQueueConnection();
queueConnection.start();
queueSession = queueConnection.createQueueSession(false, AUTO_ACKNOWLEDGE);
queueSender = queueSession.createSender(queue);
TextMessage textMessage = queueSession.createTextMessage(kjvUpdate.getId());
textMessage.setStringProperty(MESSAGE_TYPE, KALENDER_UPDATE_NOTIFICATION);
textMessage.setJMSCorrelationID(kjvUpdate.getId());
LOG.debug("Message gepost voor KJVUpdate {}", kjvUpdate.getId());
queueSender.send(textMessage);
} catch (JMSException e) {
LOG.error("Kan kalenderUpdate niet op JSM queue zetten:", e);
throw new IllegalStateException("Kan kalenderUpdate niet op JSM queue zetten");
}
Exception stacktrace (on call to: queueSession = queueConnection.createQueueSession(false, AUTO_ACKNOWLEDGE);)
0 = {StackTraceElement@21816} "org.jboss.resource.adapter.jms.JmsSessionFactoryImpl.allocateConnection(JmsSessionFactoryImpl.java:435)"
1 = {StackTraceElement@21817} "org.jboss.resource.adapter.jms.JmsSessionFactoryImpl.createQueueSession(JmsSessionFactoryImpl.java:158)"
2 = {StackTraceElement@21818} "be.delijn.typedagkalender.service.jms.KalenderUpdateNotifier.postKalenderUpdate(KalenderUpdateNotifier.java:55)"
Message
Could not create a session: javax.resource.spi.ResourceAllocationException: Unable to setup connection
There isn't much detail other then this , unable to setup connection and indeed in rabbitMQ there is never a connection. Hope this is enough information to either see if it's a problem that can be fixed or not. For now I'll be forced to find another solution maybe ActiveMQ instead of rabbitMQ
Can the resource adapter safely claim to support XA transactions, as it apparently does claim?
When running the example project using Maven 3.6, the thorntail plugin fails with somewhat mysterious error message.
The failure is caused by thorntail-maven-plugin:2.2.0.Final being incompatible with Maven 3.6. When Maven 3.5 is used, the example works.
c.f. https://stackoverflow.com/questions/53507591/thorntail-examples-api-incompatibility, and https://issues.redhat.com/browse/THORN-2229
[ERROR] Failed to execute goal io.thorntail:thorntail-maven-plugin:2.2.0.Final-redhat-00022:package (default) on project resource-adapter-thorntail-example: Execution default of goal io.thorntail:thorntail-maven-plugin:2.2.0.Final-redhat-00022:package failed: An API incompatibility was encountered while executing io.thorntail:thorntail-maven-plugin:2.2.0.Final-redhat-00022:package: java.lang.AbstractMethodError: null
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>io.thorntail:thorntail-maven-plugin:2.2.0.Final-redhat-00022
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/home/jdanek/.m2/repository/io/thorntail/thorntail-maven-plugin/2.2.0.Final-redhat-00022/thorntail-maven-plugin-2.2.0.Final-redhat-00022.jar
[ERROR] urls[1] = file:/home/jdanek/.m2/repository/io/thorntail/fraction-metadata/2.2.0.Final-redhat-00022/fraction-metadata-2.2.0.Final-redhat-00022.jar
[ERROR] urls[2] = file:/home/jdanek/.m2/repository/io/thorntail/meta-spi/2.2.0.Final-redhat-00022/meta-spi-2.2.0.Final-redhat-00022.jar
[ERROR] urls[3] = file:/home/jdanek/.m2/repository/org/jboss/shrinkwrap/descriptors/shrinkwrap-descriptors-impl-javaee/2.0.0.redhat-122
I'm talking about declaring queues and topics. I understand that's not supported by the upstream library, but this repo is more active.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.