Our application is spring boot application with Apache camel routes.
Application's information like JMX, Runtime, Spring boot are exposed through hawtio.
But we are not able to see apache camel routes in hawtio.
After adding following dependency, we able to see camel (tab / plugins) in hawtio GUI.
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-management</artifactId>
<version>${version.camel}</version>
</dependency>
http://localhost:8080/actuator/hawtio
And also make sure jolokia and actuator end points are also exposed.
Related
I set the following pom.xml to use Camel 3.14.0:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.apps</groupId>
<artifactId>MyApp</artifactId>
<version>1.0.0</version>
<name>MyApp Camel component</name>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-bom</artifactId>
<version>3.14.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-csv</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-sql</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
</dependency>
<!-- DB dependencies -->
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.6.1</version>
<scope>system</scope>
<systemPath>D:\Drivers\hsqldb-2.6.1-jdk8.jar</systemPath>
</dependency>
</dependencies>
</project>
Then I have this command line in Windows to collect dependencies:
C:\Users\Public\apache-maven-3.2.5\bin\mvn -f pom.xml dependency:copy-dependencies
When I run it I get all jars in the destination folder (../build/target/dependency).
And then I get other run.bat file with following:
set CLASSPATH=../build/target/dependency/*;../config/
java -classpath "%CLASSPATH%" org.apache.camel.spring.Main
But when I run it, I get an error saying it can't find Main class. That class is the one used in previous use cases (Camel 2.10.6) and it worked fine. Would you please advise on what's the right class to reference here?
EDIT 1: I found in documentation that Main is now in org.apache.camel.main, so I configured that in run.bat and it's seems to be running. But now it shows the following and the odd thing about this is that it ceased picking the file from the path configured in context.xml. Any ideas?
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
EDIT 2: I looked on the error and found I needed to include dependency
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
It still seems to work (message regarding slf4 is gone) but still won't pick file from path.
Now, reason I decided to move to last LTS version was because I needed to use a component property only available in newer version of Camel than the one I've been using. So I decided to give a shot to latest version, but now I'm stuck with error saying it can't find the class.
I've somewhat used Camel in the past but only based on examples provided by someone else, never from scratch so I'm no expert at all and unfortunately I need to solve this in a hurry. I guess the easiest would be to use a java bean but I'm no java developer so I thought it might be ok using Spring XML DSL. I'm using java 1.8.0_92.
Camel documentation doesn't seem to provide so many details as per spring xml, so any help will be greatly appreciated.
Frameworks and documentation
First and foremost its good to understand that Apache Camel is integration framework, Spring is application framework with probably its most notable feature being dependency injection. Due to this the documentation kinda expects the developer to be familiar with spring-framework and able juggle between camel and spring documentation.
Camel main
Camel-main in the other hand is tool you can use to run camel applications without any framework so it has no knowledge about spring framework. There's camel-spring-main but more on that later.
Spring-boot
When it comes to spring it might be easier to just use spring-boot which you can think of as collection of maven dependencies you can use to auto-configure your spring application with default configurations.
I recommend that you create a new project using camel maven archetype camel-archetype-spring-boot. This should provide you with good starting point and example on how to get started with camel and spring.
To use spring-xml files with camel-spring-boot you can add annotation #ImportResource(classpath:META-INF/spring/camel-context.xml) over your SpringBootApplication class (class annotated with #SpringBootApplication, named MySpringBootApplication when using the template).
Change the path to match the location and name of your xml-file and delete or comment the example RouteBuilder class from the project to prevent it from interrupting with anything.
# You can run spring-boot application using maven
mvn spring-boot:run
# Alternatively you should be able to run it from jar using
java -jar application.jar
Downside for spring-boot is that it'll flood our project with bunch of extra dependencies. For example to just keep the application running the template project uses spring-boot-start-web, spring-boot-starter-undertow and spring-boot-starter-actuator dependencies.
Camel Spring Main
There's also archetype camel-archetype-spring you can use to create camel spring application without spring-boot. It uses the camel-spring-main I mentioned above and can be run using maven with command mvn camel:run.
However I find this archetype a bit lacking. First it lacks visible main class which is inconsistent if you compare it to some camel-archetype-main. Secondly there seems to be problems with its packaging configurations as I didn't find an easy way to run it from jar. Most attempts I tried resulted in ClassNotFoundException for org/apache/camel/spring/Main even tough I had all maven dependencies in place. It runs fine from IDE however.
Convert your project to JAVA-DSL and use camel main
Since your route doesn't seem all that complex you could probably convert it to Java-DSL from XML in minutes and just run it with camel-main without any application framework. There's archetype for this as well called camel-archetype-main.
I have the following camel context that builds and installs on karaf ok, at least no errors.
Receives Current Grade from Camu
The request raw from bpms
{{api.key}}
The problem is
is waiting for dependencies [(&(component=netty4-http)(objectClass=org.apache.camel.spi.ComponentResolver))]
I have installed the camel-http feature and the camel-nett4 feature with no impact. Thge pom is ok with the nett4 dependency
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-netty4-http</artifactId>
<version>2.21.0.fuse-730078-redhat-00001</version>
</dependency>
what do I try next
is waiting for dependencies - means that your application waiting for service at apache karaf. at this case netty4-http you have to re
I have a standalone java application that uses cxf. I have some features to be added into the bus. thus I added a feature (implementing AbstractFeature) and injecting some headers to outgoing messages. The clients to the endpoints are defined in a core module of my project.
This is working pretty well on containers like tomcat etc.. I can see the injection done and my app working expectedly. But when it comes to the standalone java app. The bus again getting configured with the same feature class. But the requests are not going through the bus. Because the injection class is not triggered while I am debugging it.
well the issue was with some missing libraries. CXF runtime frontend jaxws library is the key to get your bus used. for maven; adding below dependency solves the issue
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
I'm trying to use Apache httpclient-win to get at IIS-hosted Web resources secured by Windows Authentication. I've managed to use the Camel HTTP4 component without authentication. I've also managed to use httpclient-win with authentication successfully from straight Java code. But now, I'm having a hard time figuring out how to use httpclient-win in a Camel route hosted in an OSGi container (ServiceMix).
I managed to create an OSGi bundle that embeds the dependencies required by httpclient-win by adding this section to my POM file:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>BundleName</Bundle-SymbolicName>
<Embed-Dependency>httpclient|httpcore|httpclient-win|jna|jna-platform;scope=compile|runtime|provided</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>
I haven't done the security part but deployed http, netty4 and restlet to Apache Karaf which is an OSGI container.
What exactly do you have problem with?
I'm using Spring DSL, apache camel 2.10 and trying to create a route that calls a php script.
<route id="HTTPtoJMS">
<from uri="jetty:http://0.0.0.0:8888/placeorder" />
<inOnly uri="jms:incomingOrders" />
<to uri="language:php:/home/rosh/test/getAllBills.php" />
</route>
I start it as a war in apache tomcat 7, and the webapp starts without exceptions.
However, at runtime, I get :
java.lang.IllegalArgumentException: No script engine could be created for: php
What am I doing wrong?
I browsed the very few resources on how to call php from spring dsl, such as http://camel.apache.org/book-languages-appendix.html , but couldn't find what i am doing wrong.
I have in my pom.xml the dependency for scripting languages.
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-script</artifactId>
<version>${camel.version}</version>
</dependency>
Thanks.
The camel-script component uses the Java Scripting API. And you would need to install a PHP Scripting Engine in your JVM to support this. There is a few that comes out of the box with the JVM, I think one such is JavaScript.