2

I'm trying to initialise the ActiveMQComponent using org.apache.activemq.pool.PooledConnectionFactor via camel cdi. With the ActiveMQConnectionFactory, this is working fine.

I added some logs also and noted that when the PooledConnectionFactory, CamelContext is getting shut down. When it is building and deploying I tried many different ways with JMSConfigurations etc etc. But still no any luck.

What could be the reason for this?

Error log.

17:45:07,043 INFO  [org.apache.camel.impl.DefaultCamelContext] (MSC service thread 1-6) Apache Camel 2.19.3 (CamelContext: camel_cdi_context) is starting
17:45:07,044 INFO  [org.apache.camel.management.ManagedManagementStrategy] (MSC service thread 1-6) JMX is enabled
17:45:07,064 INFO  [org.wildfly.extension.camel] (MSC service thread 1-6) Camel context starting: camel_cdi_context
17:45:07,064 INFO  [org.wildfly.extension.camel] (MSC service thread 1-2) Bound camel naming object: java:jboss/camel/context/camel_cdi_context
17:45:07,095 INFO  [org.apache.camel.impl.DefaultRuntimeEndpointRegistry] (MSC service thread 1-6) Runtime endpoint registry is in extended mode gathering usage statistics of all incoming and outgoing endpoints (cache limit: 1000)
17:45:07,131 INFO  [stdout] (MSC service thread 1-6) Creating ActiveMQ Component
17:45:07,131 INFO  [stdout] (MSC service thread 1-6) createActiveMQComponent().connectionFactory : org.apache.activemq.ActiveMQConnectionFactory@6e871efa
17:45:07,131 INFO  [stdout] (MSC service thread 1-6) createActiveMQComponent(). : mark-1
17:45:07,135 INFO  [org.apache.camel.impl.DefaultCamelContext] (MSC service thread 1-6) Apache Camel 2.19.3 (CamelContext: camel_cdi_context) is shutting down
17:45:07,137 INFO  [org.wildfly.extension.camel] (MSC service thread 1-6) Camel context stopped: camel_cdi_context

I can proceed with the ActiveMQConnectionFactory and work on maximumConnections / timeouts in different ways. But I like to have the best.

ActiveMQComponentProducer.java

@ApplicationScoped
public class ActiveMQComponentProducer {

    @Produces
    @Named("activemqx")
    public ActiveMQComponent createActiveMQComponent() {

        System.out.println("Creating ActiveMQ Component");

        ActiveMQComponent activeMQComponent = ActiveMQComponent.activeMQComponent();
        String connectionString = "tcp://localhost:61616";

        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(connectionString);
        System.out.println("createActiveMQComponent().connectionFactory : " + connectionFactory);

        PooledConnectionFactory pooledConnectionFactory = null;
        System.out.println("createActiveMQComponent(). : mark-1");

        try {
            pooledConnectionFactory = new PooledConnectionFactory(connectionFactory);
        } catch (Exception e) {
            System.out.println("createActiveMQComponent(). : "+e);
        }
        System.out.println("createActiveMQComponent(). : mark-2");

        activeMQComponent.setConnectionFactory(pooledConnectionFactory);
        return activeMQComponent;
    }

}
  • Camel version : 2.19
  • Wildfly version : 10.1.0
  • Camel Patch Version :wildfly-camel-patch-4.9.0
ironwood
  • 8,936
  • 15
  • 65
  • 114

1 Answers1

1

It's likely that you're running into a class loading issue.

In the WildFly-Camel 4.9.0 release, PooledConnectionFactory is not automatically exported onto the deployment class path. This problem is fixed in future releases and was tracked by this issue:

https://github.com/wildfly-extras/wildfly-camel/issues/2199

As a workaround, you can add a module dependency for org.apache.activemq to your deployment via a jboss-deployment-structure.xml descriptor. Place it within META-INF for JAR deployments or WEB-INF for a WAR deployment.

<jboss-deployment-structure>
    <deployment>
        <dependencies>
            <module name="org.apache.activemq" />
        </dependencies>
    </deployment>
</jboss-deployment-structure>
James Netherton
  • 1,092
  • 1
  • 7
  • 9