deploying camel java-archetype projec to Fuse 6.2 - apache-camel

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

Related

Running a Spring Boot Camel inside Jboss Fuse

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.

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.

How to generate CXF beans.xml using wsdl2java maven?

When I use eclipse to generate jaxb classes and Webservice implementation by top down approach. eclipse automatically generates csf-beans.xml. However wsdl1java maven plugin doesnot generate config file. Is there are options available to plugin to enable generation of bean configuration file?
No! There isn't any option for generating cxf configuration file with wsdl2java maven plugin. You can get and customize the general cxf.xml file from Apache CXF Configuration and add it to the /WEB-INF/classes folder of your web application.
Hope this helps.

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

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