You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Nathan Kunkee <nk...@genome.wustl.edu> on 2014/09/15 22:35:05 UTC
Qpid with RabbitMQ and Glassfish4
Hi all,
I'm trying to get QPID JCA adapter, Glassfish, and RabbitMQ to work
together. At this point, I believe that the Destination is not recreated
correctly from the initial Queue when creating a MessageProducer. I can
see in the log messages that the Queue is populated correctly when
initially created, but later when the Session is creating the
MessageProducer, it is empty, causing AMQNoRouteException. It would be
really nice if this could be addressed in your next release.
I downloaded the 0.30-rc code (r6489 I think) and built with maven, with
one change as listed below. It allows use of the JCA adapter if
transactions are not required. When I create a MessageProducer, I get
the following error:
org.apache.qpid.client.AMQNoRouteException: Error: NO_ROUTE [error code
312: no route]
RabbitMQ 3.3.4 reports that the exchange 'outbound' exists on the server
just fine, under the /qpid virtual host. I have no errors in the
RabbitMQ log. It makes no difference I can see if I create the queue or
exchange manually or let the adapter create them.
The code seems to connect fine, negotiate AMQP 0-9-1, username and
passwords work (as noted below), but when actually pushing a message I
get the no route error. I do find it odd that the actual connection
attempt believes I'm using an ADDR value when I setup a BURL queue. Any
ideas?
If nothing else, could the trivial patch below be applied?
Thanks!
Nathan Kunkee
How did I get this to run on Glassfish?
In order to see log messages, I had to enable log4j messages, by
dropping a .properties file in
$GLASSFISH/glassfish/domains/domain1/lib/classes which turned on
log4j.rootLogger=DEBUG. Then I had to add to the jvm options of the
server instance an option to
-Dlog4j.configuration=nkunkee.log.properties and restart.
Next was configuring the JCA adapter. I had to make a resource adapter
config first,
asadmin create-resource-adapter-config --threadpoolid thread-pool-1
--property
TransactionManagerLocatorMethod=getTm:TransactionManagerLocatorClass=org.apache.qpid.ra.tm.GlassfishTransactionManagerLocator:ConnectionURL=amqp://qpid:qpid@macbook/interop?brokerlist='tcp://localhost:5672'
qpid-ra-0.30
Escaped for bash:
asadmin create-resource-adapter-config --threadpoolid thread-pool-1
--property
ConnectionURL=amqp\\://qpid\\:qpid@macbookra/qpid\?brokerlist\\=\\\'tcp\\://localhost\\:5672\\\':TransactionManagerLocatorMethod=getTm:TransactionManagerLocatorClass=org.apache.qpid.ra.tm.GlassfishTransactionManagerLocator
qpid-ra-0.30
Note the name has to match the resource adapter. Note those are supposed
to be one line. Next I can add the log4j and slf4j libraries to the rar
file, since the Glassfish class loader seems to need them there, then
deploy it.
zip -u qpid-ra-0.30.rar log4j-1.2.16.jar slf4j-log4j12-1.6.4.jar
asadmin deploy qpid-ra-0.30.rar
Next I can create the connection objects:
#note that yes, you have to specify the connect string in
# the alternative properties; they don't cascade from the
# ra config or ConnectionURL
asadmin create-connector-connection-pool --raname qpid-ra-0.30
--transactionsupport NoTransaction --connectiondefinition
org.apache.qpid.ra.QpidRAConnectionFactory --property
UseTryLock=0:SessionDefaultType=javax.jms.Queue:Host=linus59.gsc.wustl.edu:Port=5672:UserName=qpid:Password=qpid:ClientId=macbook:Path=/qpid
qpid30-test-pool
asadmin create-connector-resource --poolname qpid30-test-pool
qpid30-test-conn
asadmin create-admin-object --raname qpid-ra-0.30 --restype
org.apache.qpid.ra.admin.QpidQueue --classname
org.apache.qpid.ra.admin.QpidQueueImpl --property
DestinationAddress=BURL\:direct\://outbound//fromjava qpid30-test-queue
My code at the moment is fairly simple:
@Resource(lookup = "qpid30-test-conn")
private ConnectionFactory testCF;
@Resource(lookup = "qpid30-test-queue")
private Queue testQueue;
public String pushMessage() {
try {
Connection connection;
Session session;
MessageProducer msgProducer;
TextMessage msg;
System.out.println("NKUNKEE--connect to send");
connection = testCF.createConnection();
session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
System.out.println("NKUNKEE--session is " +
session.toString());
msgProducer = session.createProducer(testQueue);
msg = session.createTextMessage(visibleText);
msgProducer.send(msg);
System.out.println("NKUNKEE--send message:"+visibleText);
session.close();
connection.close();
}
This is attached to a button on a JSF page, so that it sends a message
when i push the button. When I push the button, I get an error:
Caused by: java.lang.UnsupportedOperationException: 0_8 version does not
provide XA support
I do not need full XA support in the Java sense, and turned it off when
I made the connector pool, so the below patch gets me past that issue:
Index: jca/src/main/java/org/apache/qpid/ra/QpidRAManagedConnection.java
===================================================================
--- jca/src/main/java/org/apache/qpid/ra/QpidRAManagedConnection.java
(revision 1624621)
+++ jca/src/main/java/org/apache/qpid/ra/QpidRAManagedConnection.java
(working copy)
@@ -782,7 +782,10 @@
_connection =
_mcf.getDefaultAMQConnectionFactory().createXATopicConnection();
}
- _xaSession =
((XATopicConnection)_connection).createXATopicSession();
+ if (transacted)
+ {
+ _xaSession =
((XATopicConnection)_connection).createXATopicSession();
+ }
_session =
((TopicConnection)_connection).createTopicSession(transacted,
acknowledgeMode);
}
@@ -797,7 +800,10 @@
_connection =
_mcf.getDefaultAMQConnectionFactory().createXAQueueConnection();
}
- _xaSession =
((XAQueueConnection)_connection).createXAQueueSession();
+ if (transacted)
+ {
+ _xaSession =
((XAQueueConnection)_connection).createXAQueueSession();
+ }
_session =
((QueueConnection)_connection).createQueueSession(transacted,
acknowledgeMode);
}
@@ -811,7 +817,10 @@
{
_connection =
_mcf.getDefaultAMQConnectionFactory().createXAConnection();
}
- _xaSession = ((XAConnection)_connection).createXASession();
+ if (transacted)
+ {
+ _xaSession = ((XAConnection)_connection).createXASession();
+ }
_session = _connection.createSession(transacted,
acknowledgeMode);
}
When I rebuild the rar file, including the jar libs again, then undeploy
and redeploy the rar, I am at the state above where I discuss the error,
Info: 20110 [pool-26-thread-1] DEBUG
org.apache.qpid.client.AMQDestination - Based on 'outbound'/'fromjava'; {
'node': {
'type': 'queue'
}
} the selected destination syntax is ADDR
Info: 20111 [pool-26-thread-1] DEBUG org.apache.qpid.client.AMQSession
- Message returned with error code 312: no route (NO_ROUTE)
Info: 20112 [pool-26-thread-1] DEBUG
org.apache.qpid.client.AMQConnection - exceptionReceived done
by:pool-26-thread-1
org.apache.qpid.client.AMQNoRouteException: Error: NO_ROUTE [error code
312: no route]
at org.apache.qpid.client.AMQSession_0_8$6.run(AMQSession_0_8.java:783)
It seems like this is trying to send using an empty desitiation.
____
This email message is a private communication. The information transmitted, including attachments, is intended only for the person or entity to which it is addressed and may contain confidential, privileged, and/or proprietary material. Any review, duplication, retransmission, distribution, or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is unauthorized by the sender and is prohibited. If you have received this message in error, please contact the sender immediately by return email and delete the original message from all computer systems. Thank you.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: Qpid with RabbitMQ and Glassfish4 SOLVED
Posted by Gordon Sim <gs...@redhat.com>.
On 09/17/2014 10:43 PM, Nathan Kunkee wrote:
> On 09/15/2014 03:35 PM, Nathan Kunkee wrote:
>> Hi all,
>>
>> I'm trying to get QPID JCA adapter, Glassfish, and RabbitMQ to work
>> together. At this point, I believe that the Destination is not recreated
>> correctly from the initial Queue when creating a MessageProducer. I can
>> see in the log messages that the Queue is populated correctly when
>> initially created, but later when the Session is creating the
>> MessageProducer, it is empty, causing AMQNoRouteException. It would be
>> really nice if this could be addressed in your next release.
>>
>> I downloaded the 0.30-rc code (r6489 I think) and built with maven, with
>> one change as listed below. It allows use of the JCA adapter if
>> transactions are not required. When I create a MessageProducer, I get
>> the following error:
>> org.apache.qpid.client.AMQNoRouteException: Error: NO_ROUTE [error code
>> 312: no route]
>
> Hi all,
>
> I reproduced this using Wildfly, which at least caused me to look closer
> at the error message. In this case, the error was in the bounced message
> handler, which I missed earlier. RabbitMQ was rejecting the message as
> it decided the routing was too vague. When I updated my BURL destination
> string to include exchange, queue, and routing key
> (BURL:direct://outbound/hello/fromjava), then I was able to send
> outbound messages successfully.
>
> I have been able to get inbound messages from RabbitMQ working by
> setting the ActivationConfigProperty destination to the JNDI name of the
> queue, and useLocalTx to true. I also ran into issue QPID-5906 and had
> to set the -DIMMEDIATE_PREFETCH=true property. My glassfish-ejb-jar.xml
> maps the bean name, jndi name, and resource adapter module name together
> as required by Glassfish.
>
> Hopefully this is helpful to someone else!
I'm sure it will be, thanks for taking the time to update the list. I'm
afraid I have no expertise with the JCA adapter.
Regarding your patch, could you attach it to a JIRA? That's the best
mechanism for getting it applied.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: Qpid with RabbitMQ and Glassfish4 SOLVED
Posted by Nathan Kunkee <nk...@genome.wustl.edu>.
On 09/15/2014 03:35 PM, Nathan Kunkee wrote:
> Hi all,
>
> I'm trying to get QPID JCA adapter, Glassfish, and RabbitMQ to work
> together. At this point, I believe that the Destination is not recreated
> correctly from the initial Queue when creating a MessageProducer. I can
> see in the log messages that the Queue is populated correctly when
> initially created, but later when the Session is creating the
> MessageProducer, it is empty, causing AMQNoRouteException. It would be
> really nice if this could be addressed in your next release.
>
> I downloaded the 0.30-rc code (r6489 I think) and built with maven, with
> one change as listed below. It allows use of the JCA adapter if
> transactions are not required. When I create a MessageProducer, I get
> the following error:
> org.apache.qpid.client.AMQNoRouteException: Error: NO_ROUTE [error code
> 312: no route]
Hi all,
I reproduced this using Wildfly, which at least caused me to look closer
at the error message. In this case, the error was in the bounced message
handler, which I missed earlier. RabbitMQ was rejecting the message as
it decided the routing was too vague. When I updated my BURL destination
string to include exchange, queue, and routing key
(BURL:direct://outbound/hello/fromjava), then I was able to send
outbound messages successfully.
I have been able to get inbound messages from RabbitMQ working by
setting the ActivationConfigProperty destination to the JNDI name of the
queue, and useLocalTx to true. I also ran into issue QPID-5906 and had
to set the -DIMMEDIATE_PREFETCH=true property. My glassfish-ejb-jar.xml
maps the bean name, jndi name, and resource adapter module name together
as required by Glassfish.
Hopefully this is helpful to someone else!
Thanks,
Nathan
>
> RabbitMQ 3.3.4 reports that the exchange 'outbound' exists on the server
> just fine, under the /qpid virtual host. I have no errors in the
> RabbitMQ log. It makes no difference I can see if I create the queue or
> exchange manually or let the adapter create them.
>
> The code seems to connect fine, negotiate AMQP 0-9-1, username and
> passwords work (as noted below), but when actually pushing a message I
> get the no route error. I do find it odd that the actual connection
> attempt believes I'm using an ADDR value when I setup a BURL queue. Any
> ideas?
>
> If nothing else, could the trivial patch below be applied?
>
> Thanks!
> Nathan Kunkee
>
>
> How did I get this to run on Glassfish?
>
> In order to see log messages, I had to enable log4j messages, by
> dropping a .properties file in
> $GLASSFISH/glassfish/domains/domain1/lib/classes which turned on
> log4j.rootLogger=DEBUG. Then I had to add to the jvm options of the
> server instance an option to
> -Dlog4j.configuration=nkunkee.log.properties and restart.
>
> Next was configuring the JCA adapter. I had to make a resource adapter
> config first,
> asadmin create-resource-adapter-config --threadpoolid thread-pool-1
> --property
> TransactionManagerLocatorMethod=getTm:TransactionManagerLocatorClass=org.apache.qpid.ra.tm.GlassfishTransactionManagerLocator:ConnectionURL=amqp://qpid:qpid@macbook/interop?brokerlist='tcp://localhost:5672'
>
> qpid-ra-0.30
>
> Escaped for bash:
> asadmin create-resource-adapter-config --threadpoolid thread-pool-1
> --property
> ConnectionURL=amqp\\://qpid\\:qpid@macbookra/qpid\?brokerlist\\=\\\'tcp\\://localhost\\:5672\\\':TransactionManagerLocatorMethod=getTm:TransactionManagerLocatorClass=org.apache.qpid.ra.tm.GlassfishTransactionManagerLocator
>
> qpid-ra-0.30
>
> Note the name has to match the resource adapter. Note those are supposed
> to be one line. Next I can add the log4j and slf4j libraries to the rar
> file, since the Glassfish class loader seems to need them there, then
> deploy it.
> zip -u qpid-ra-0.30.rar log4j-1.2.16.jar slf4j-log4j12-1.6.4.jar
> asadmin deploy qpid-ra-0.30.rar
>
> Next I can create the connection objects:
> #note that yes, you have to specify the connect string in
> # the alternative properties; they don't cascade from the
> # ra config or ConnectionURL
> asadmin create-connector-connection-pool --raname qpid-ra-0.30
> --transactionsupport NoTransaction --connectiondefinition
> org.apache.qpid.ra.QpidRAConnectionFactory --property
> UseTryLock=0:SessionDefaultType=javax.jms.Queue:Host=linus59.gsc.wustl.edu:Port=5672:UserName=qpid:Password=qpid:ClientId=macbook:Path=/qpid
>
> qpid30-test-pool
>
> asadmin create-connector-resource --poolname qpid30-test-pool
> qpid30-test-conn
>
> asadmin create-admin-object --raname qpid-ra-0.30 --restype
> org.apache.qpid.ra.admin.QpidQueue --classname
> org.apache.qpid.ra.admin.QpidQueueImpl --property
> DestinationAddress=BURL\:direct\://outbound//fromjava qpid30-test-queue
>
> My code at the moment is fairly simple:
>
> @Resource(lookup = "qpid30-test-conn")
> private ConnectionFactory testCF;
>
> @Resource(lookup = "qpid30-test-queue")
> private Queue testQueue;
>
> public String pushMessage() {
> try {
> Connection connection;
> Session session;
> MessageProducer msgProducer;
> TextMessage msg;
>
> System.out.println("NKUNKEE--connect to send");
> connection = testCF.createConnection();
> session = connection.createSession(false,
> Session.AUTO_ACKNOWLEDGE);
> System.out.println("NKUNKEE--session is " +
> session.toString());
> msgProducer = session.createProducer(testQueue);
> msg = session.createTextMessage(visibleText);
> msgProducer.send(msg);
> System.out.println("NKUNKEE--send message:"+visibleText);
>
> session.close();
> connection.close();
> }
>
> This is attached to a button on a JSF page, so that it sends a message
> when i push the button. When I push the button, I get an error:
> Caused by: java.lang.UnsupportedOperationException: 0_8 version does not
> provide XA support
>
> I do not need full XA support in the Java sense, and turned it off when
> I made the connector pool, so the below patch gets me past that issue:
>
> Index: jca/src/main/java/org/apache/qpid/ra/QpidRAManagedConnection.java
> ===================================================================
> --- jca/src/main/java/org/apache/qpid/ra/QpidRAManagedConnection.java
> (revision 1624621)
> +++ jca/src/main/java/org/apache/qpid/ra/QpidRAManagedConnection.java
> (working copy)
> @@ -782,7 +782,10 @@
> _connection =
> _mcf.getDefaultAMQConnectionFactory().createXATopicConnection();
> }
>
> - _xaSession =
> ((XATopicConnection)_connection).createXATopicSession();
> + if (transacted)
> + {
> + _xaSession =
> ((XATopicConnection)_connection).createXATopicSession();
> + }
> _session =
> ((TopicConnection)_connection).createTopicSession(transacted,
> acknowledgeMode);
>
> }
> @@ -797,7 +800,10 @@
> _connection =
> _mcf.getDefaultAMQConnectionFactory().createXAQueueConnection();
> }
>
> - _xaSession =
> ((XAQueueConnection)_connection).createXAQueueSession();
> + if (transacted)
> + {
> + _xaSession =
> ((XAQueueConnection)_connection).createXAQueueSession();
> + }
> _session =
> ((QueueConnection)_connection).createQueueSession(transacted,
> acknowledgeMode);
>
> }
> @@ -811,7 +817,10 @@
> {
> _connection =
> _mcf.getDefaultAMQConnectionFactory().createXAConnection();
> }
> - _xaSession = ((XAConnection)_connection).createXASession();
> + if (transacted)
> + {
> + _xaSession =
> ((XAConnection)_connection).createXASession();
> + }
> _session = _connection.createSession(transacted,
> acknowledgeMode);
> }
>
>
> When I rebuild the rar file, including the jar libs again, then undeploy
> and redeploy the rar, I am at the state above where I discuss the error,
>
> Info: 20110 [pool-26-thread-1] DEBUG
> org.apache.qpid.client.AMQDestination - Based on 'outbound'/'fromjava'; {
> 'node': {
> 'type': 'queue'
> }
> } the selected destination syntax is ADDR
> Info: 20111 [pool-26-thread-1] DEBUG org.apache.qpid.client.AMQSession
> - Message returned with error code 312: no route (NO_ROUTE)
> Info: 20112 [pool-26-thread-1] DEBUG
> org.apache.qpid.client.AMQConnection - exceptionReceived done
> by:pool-26-thread-1
> org.apache.qpid.client.AMQNoRouteException: Error: NO_ROUTE [error code
> 312: no route]
> at
> org.apache.qpid.client.AMQSession_0_8$6.run(AMQSession_0_8.java:783)
>
> It seems like this is trying to send using an empty desitiation.
____
This email message is a private communication. The information transmitted, including attachments, is intended only for the person or entity to which it is addressed and may contain confidential, privileged, and/or proprietary material. Any review, duplication, retransmission, distribution, or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is unauthorized by the sender and is prohibited. If you have received this message in error, please contact the sender immediately by return email and delete the original message from all computer systems. Thank you.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org