angryip
angryip

Reputation: 2300

Routes not executing : camel / fuse / activemq

I am following some tutorials here towards understanding how I can use camel routes on a deployed Jboss EAP 6.4 server. The goal of my current application is fairly simple, in that I want to read from an ActiveMQ topic, and log it out. Below code summarizes my actions:

package com.mycompany;

import javax.ejb.Startup;
import javax.enterprise.context.ApplicationScoped;
import javax.jms.ConnectionFactory;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.cdi.ContextName;
import org.apache.camel.component.jms.JmsComponent;

@ApplicationScoped
@Startup
@ContextName("com.mycompany")
public class CamelRoute extends RouteBuilder {

    @Override
    public void configure() throws Exception {
        System.out.println("### we are in the main");

        final ConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616");
        getContext().addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(factory));

        System.out.println("#### route being called");
        from("jms:topic:activemq/topic/myTopic").log("###### we are in here with this message ${body}");

    }
}

I also have a Launcher class to test my routes:

package com.mycompany;

import org.apache.camel.main.Main;

public class Launcher {

    public static void main(final String... args) throws Exception {
        final Main main = new Main();
        main.addRouteBuilder(new CamelRoute());
        main.run(args);
    }
}

If I start my routes via the following maven command, I can receive all messages that come to the activemq topic. So I know that if I manually start the route, I can at least retrieve the data.

mvn clean install exec:java -Dexec.mainClass=com.mycompany.Launcher

However, once I deploy my application to the server ( as a jar, enabled ), the same cannot be said. None of my system.out statements are noticeable in the logs. I almost feel as if I am missing additional configuration to "jump-start" the application.

Note: I added the EJB annotations for startup in the CamelRoute class, but that did not solve the problem. Am I missing something obvious here?

Output from the jboss eap 6.4 log once I deploy the jar:

04:18:21,390 INFO  [org.jboss.as.repository] (HttpManagementService-threads - 49) JBAS014900: Content added at location C:\bin\jboss-fuse\jboss-eap-6.4\standalone\data\content\99\f271f8372007ee6a2bce37668656acb80ef160\content
04:18:21,427 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "camel-java-1.0.0-SNAPSHOT.jar" (runtime-name: "camel-java-1.0.0-SNAPSHOT.jar")
04:18:21,431 INFO  [org.wildfly.extension.camel] (MSC service thread 1-4) @ContextName annotation found
04:18:21,442 WARN  [org.jboss.weld.deployer] (MSC service thread 1-6) JBAS016012: Deployment deployment "camel-java-1.0.0-SNAPSHOT.jar" contains CDI annotations but beans.xml was not found.
04:18:21,464 INFO  [org.jboss.as.server] (HttpManagementService-threads - 49) JBAS015859: Deployed "camel-java-1.0.0-SNAPSHOT.jar" (runtime-name : "camel-java-1.0.0-SNAPSHOT.jar")

Upvotes: 0

Views: 634

Answers (1)

James Netherton
James Netherton

Reputation: 1266

There's a pointer in your log output which indicates the likely cause of this issue:

JBAS016012: Deployment deployment "camel-java-1.0.0-SNAPSHOT.jar" contains CDI annotations but beans.xml was not found.

You'll need to make sure you add a META-INF/beans.xml to your JAR. Implicit bean archives were not added until CDI 1.1. EAP 6.x / JavaEE 6 uses CDI 1.0. If beans.xml is not present within the deployment, your Camel CDI application will never be boostrapped and started.

Upvotes: 1

Related Questions