Running a Spring Boot Camel inside Jboss Fuse - apache-camel

I have a application running Spring Boot Camel which consume message from a ActiveMQ and write to a file:
#Override
public void configure() throws Exception {
from("activemq:queue:MyQueue").to("file:/tmp/somemessages/");
}
Very simple and works fine if run mvn spring-boot:run.
But now i need generate a bundle jar to install in my RedHat Fuse OSGi container. Everything was installed and started without error, see:
So, my camel-app is Active but after produce some messages in my ActiveMQ Queue nothing works as i expect, so the file was not generated.
How can i see if something is wrong ? Application Console Log or something like this ?

This is not a good practice. Spring Boot is intended for running Standalone. In an OSGi based runtime such as Red Hat Fuse or Apache Karaf/ServiceMix you should deploy OSGi apps, which with Camel is camel-blueprint (you can also use Java routes with blueprint). So take a look at examples how to do that, and there should be examples shipped with Red Hat Fuse you can look at.

How can i see if something is wrong ? Application Console Log or something like this ?
The simple answer is you can run diagnostic command on your bundle by running following command inside your shell console:
bundle:diag {your-bundle-id}
You may replace {your-bundle-id} by preferred bundle id that is 231 in the picture. There is also a complete list of Apache Karaf commands that may be useful for further requirements.

Related

camel blueprint force usage of log4j

Has anyone been able to use camel-blueprint together with logback? It seems that there are dependencies in camel blueprint which forces you to use log4j even though the log4j dependencies are removed from the pom. After running the project it starts to download the slf4j-log4j12 and then then complains of multiple bindings because it finds both log4j and logback.
I did the same with a camel java project and it worked fine to switch to logback. Does camel-blueprint force you to use log4j as its logging implementation?
Answer found via nabble forum in through discussion with the camel community. For more details go here:
http://camel.465427.n5.nabble.com/camel-blueprint-force-usage-of-log4j-td5772826.html#a5772852
Essentially there are certain dependencies in the maven plugin which uses log4j. For production in JBoss Fuse or Karaf, its Pax logging.

deploying camel java-archetype projec to Fuse 6.2

I have created a java-archetype project for Camel. It is a simple REST hello world to receive a get request and return a string body. When I run this as Java application from Eclipse it works as intended.
When I take the jar and deploy it the Fuse "deploy" folder I can see in the logs that the bundle has started. The state is active and green. However the Camel tab does not appear.
The same works if I use blueprint but does not seem to do so using the java dsl. Is there an extra magic code you need to add for Fuse to pick up the camel context? Thanks
Yes for OSGi to startup you can use a spring or blueprint with a <camelContext> that starts Camel. If you use pure Java code you have to fight with OSGi and use an OSGI activator and setup all kind of OSGi stuff that gets you tiresome.
So add a blueprint xml file and add the <camelContext> and then you can refer to Java route builders, just as you can when doing spring xml: http://camel.apache.org/spring.html

ServiceMix (FuseESB) fails to find Camel javascript support when jar starts up

When deploying a Camel route to FuseESB, as FuseESB tries to start up the jar file, it gives the following exception in the log:
Found initial references null for OSGi service (&(language=js)
(objectClass=org.apache.camel.spi.LanguageResolver))
This causes the bundle to enter a grace period for a few minutes, after which it times out and its status moves to failed. Note that I'm not using javascript in the application, but I assume it is loaded as part of loading Camel core.
Details of my setup:
Code in question is written using an OSGi blueprint xml file to define the beans.
Code is packaged as a jar, as opposed to an OSGi bundle.
Code is deployed by being dropped into the deploy directory so it is deployed by the FAB deployer.
I believe I have the relevant Camel features installed.
Output from features:list:
[installed ] [2.10.0.fuse-71-047] camel-script-javascript camel-2.10.0.fuse-71-047
[installed ] [2.10.0.fuse-71-047] camel-script camel-2.10.0.fuse-71-047
I have worked around this by:
reverting to a spring xml file to define the beans
packaging the code as a bundle, not a jar
I still don't understand why the Blueprint version didn't work, but the question is now less urgent than it was.
With FAB you should declare the dependencies to your Camel components in your pom.xml file, and use scope=provided.
See more details at: http://fuse.fusesource.org/bundle/overview.html

NoSuchMethodError for errorHandler when deploying into ServiceMix

I have a servicemix module, which is basicly a camel based route.
It works fine during development and also when deploying in older version of FUSE. However, when deploying in a later version of FUSE, I get
Caused by: java.lang.NoSuchMethodError:
com.company.integration.MyRouteBuilder.errorHandler(Lorg/apache/camel/builder/ErrorHandlerBuilder;)Lorg/apache/camel/builder/RouteBuilder;
I do not quite get why :-)
The old version used camel 2.6, the new uses Camel 2.9. Both have RouteBuilder.errorHandler as far as i can tell..
br
I wouldn't spend too much time trying to figure that out myself...I'd just start testing with the same version of Camel that I'm going to deploy it under...otherwise even if you get around this issue, others will likely pop up, etc.
If you do have a requirement to run multiple apps that depend on different versions of Camel, then OSGi supports this as long as install the necessary camel bundle versions and setup your applicaiton bundle manifests correctly, etc.
Reinstalling (or rather, recreating the instance) helped.

Apache Camel route as a Windows Service

I have a Apache Camel route that is exported as a runnable jar file from eclipse. I use a simple bat file to run this route...
C:\PROGRA~1\Java\jre6\bin\java -jar C:\dev\_exports\mdt\cpnnectors_v1.jar
How can I run this as a window service instead with the output from the console to a log file?
I think there are some general windows tools you can use to turn Java apps into services. And I vaugely recall something added to the JDK6 or 7 to support that natively. Anyway try to google a bit.
Tanuki has been around for a long time and they offer such a tool
http://wrapper.tanukisoftware.com/doc/english/download.jsp
I know it is a bit of a late answer but I have managed to deploy my Camel Routes to Apache Karaf and Karaf comes with a service wrapper for both for windows and a deamon wrapper for linux. Basically I know have my Camel routes deployed to Karaf and it is running as a service on windows with really minor hassle.
Karaf is easy to install and the help file also show you how to install the wrapper.

Resources