Default Wildfly-10.0.0.Final with Artemis configuration. Fails to create connection.
avico81 Mar 28, 2016 7:42 AMHello
I'm trying to create the simplest Wildfly10/Artemis InVM connector/Mdb using the minimum additional configuration needed so I can build on it for other projects.
I tried different connectors. I used JNDI/Annotation/Configuration based APIs and all failed to create a connection to Artemis.
The error is:
ActiveMQNotConnectedException[errorType=NOT_CONNECTED message=AMQ119007: Cannot connect to server(s). Tried with all available servers.]
I can see that the AMQ server is up as well as the queues and MDBs (from the logs):
2016-03-28 11:59:22,939 INFO [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 60) AMQ221007: Server is now live 2016-03-28 11:59:22,939 INFO [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 60) AMQ221001: Apache ActiveMQ Artemis Message Broker version 1.1.0.wildfly-011 [nodeID=88ba9758-f432-11e5-affc-99c7d59c0e83] 2016-03-28 11:59:22,941 INFO [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 60) AMQ221003: trying to deploy queue jms.queue.DLQ 2016-03-28 11:59:22,990 INFO [org.wildfly.extension.messaging-activemq] (ServerService Thread Pool -- 64) WFLYMSGAMQ0002: Bound messaging object to jndi name java:/ConnectionFactory 2016-03-28 11:59:22,991 INFO [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 63) AMQ221003: trying to deploy queue jms.queue.Avi 2016-03-28 11:59:22,994 INFO [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 61) AMQ221003: trying to deploy queue jms.queue.ExpiryQueue ... 2016-03-28 11:59:24,960 INFO [org.jboss.as.ejb3] (MSC service thread 1-6) WFLYEJB0042: Started message driven bean 'AviMdb' with 'activemq-ra.rar' resource adapter
Can someone provide with a working example of an InVM connector (on a war mvn project) or alternatively tell me what I'm missing here?
(The standalone.xml is attached)
import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; import javax.jms.MessageProducer; import javax.jms.ObjectMessage; import javax.jms.Queue; import javax.jms.Session; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.api.jms.JMSFactoryType; import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; ... Connection connection; MessageProducer producer; Session session; final TransportConfiguration transportConfiguration = new TransportConfiguration(InVMConnectorFactory.class.getName()); final ConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, transportConfiguration); final Queue queue = ActiveMQJMSClient.createQueue("java:/jms/queue/Avi"); try { connection = cf.createConnection(); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); producer = session.createProducer(queue); connection.start(); } catch (final Exception e) { e.printStackTrace(); } Student avi = new Student("Avi", 35); //Student is Serializable final ObjectMessage objMsg = session.createObjectMessage(avi); producer.send(objMsg); ... if (session != null) { try { session.close(); } catch (final Exception e) { e.printStackTrace(); } } if (connection != null) { try { connection.close(); } catch (final JMSException e) { e.printStackTrace(); }
This always fails on line 22 ('connection = cf.createConnection();')
I also tried Netty using the one in the imports, same result.
I also attached the MDB file but it seems irrelevant since my issue is creating the connection.
Thanks a lot
-
standalone.xml.zip 4.5 KB
-
AviMdb.java 804 bytes