We use Apache Camel as a standalone application for ~ 2 years. It works very
well but the need to restart the process to upgrade the application each time
we add new routes becomes an issue.
We are searching for a new deployment solution that could allow us to deploy
new routes without having to restart the main process.
There is no problem for us to rewrite our Java DSL routes in XML but the issue
is that most of them (and probably future ones too) make use of custom beans,
processors, components etc. to inject some logic that is too complex to
be expressed in pure XML/Java DSL route.
After searching through Camel documentation, hot deploying XML routes seems to
be possible with spring-boot or with Karaf/OSGI.
But i have no idea if it is possible to "hot-deploy" bean, processors,
components etc. classes that are needed by theses XML routes. OSGI/Karaf looks
promising but i have never used boths technologies and it is not easy to grasp their purpose at first glance.
Which deployment method and which technology could allow us to "hot deploy' routes and beans classes ?
If you want to hot-deploy Java code, then you need an application server like platform such as Apache Karaf/ServiceMix/JBoss Fuse etc or a traditional like Tomcat, JBoss, WildFly etc (for WAR files).
Then you can do a "hot deployment" as a deployment of the application.
To hot-deploy a single class or some classes inside a running JVM is harder, and you would need special tooling such as JRebel.
You could try to use camel-blueprint to setup the context/route.
By exposing your bean as osgi service, you can use those beans in routes.
I would suggest you to take a look into apache camel blueprint maven archetype and camel component archetype to get started.
Hot deploy in Apache Karaf is simple, simply drop the bundle into $KARAF_HOME/deploy and it will reload automatically.
Reference:
camel-archetype-component camel-archetype-blueprint
Do let me know if this help.
PS: I don't have enough reputation for commenting hence the answer.
Related
I have a file transfer routing developed in Apache camel. I want to embed Jetty server into this project so that i can keep the service running without deploying it to another server. It will be really helpful if someone can put some code.
Thank You.
You should use Camel's Jetty component and declare a consumer, which will automatically bring up an embedded Jetty:
from("jetty:http://localhost:{{port}}/myapp/myservice")
.process(new MyProcessor());
You have 2 options, they are quite popular:
Use maven camel:run plugin, you have to just enable this in your pom file and run the command. (I am not too sure whether they use Jetty internally, but it works)
Spring boot, Its quite easy to create a project nowadays, using the web portal.
There is one more maven plugin as well for Jetty , which is mvn jetty:run
I have previous experience in Apache Camel and JBoss Fuse and I am new to Openshift version 3.x I am trying to deploy a camel application which is developed using java dsl and spring DI.
I am using an external properties file to load the consumer and producer endpoint in camel.In JBoss Fuse I used the configAdmin services with the update-stratergy=reload as shown below in my blueprint.xml
<!-- OSGI blueprint property placeholder -->
<cm:property-placeholder id="routesConfig" persistent-id="org.sample.camel.routes.config" update-strategy="reload"/>
The above configuration will reload the camelContext automatically when there is a change in the properties file
How can I achieve the same functionality using fis-java-openshift:1.0 template image in openshift 3.x
We wrote some docs on how to work with configuration.
Generally speaking on kubernetes the use of service discovery and kubernetes secrets avoids most of the use cases for environment specific configuration.
Ideally we would use the same Continuous Delivery pipelines to change code or configuration to ensure things are properly tested before they hit production.
However if you really really want to reload configuration on the fly in Java containers you can store configuration in a ConfigMap and mount it as a file inside the pod; then have the Java code watch the file (eg with spring boot or ConfigAdmin).
The technologies I'm using are: Apache CXF, Spring 3.x, Struts 2.x and Hibernate 3.x
I'm facing a strange problem while TransactionManager with using Apache CXF. For my application I'm using CXF logging with my web-service and CN:checknames to ignore certificates on the server. When I deploy the application on server it works perfectly fine with logs being generated and certificates being ignored. But in the second step I'm developing a front-end for different areas of the application thus configuring annotation driven transaction manager in the application.xml. But when ever I try to use this line <context:annotation-config/> the CXF starts generating different logging scheme and CN:check is completely ignored.
Any help will be much appreciated. :)
My guess is your getting two instances of service/proxy bean constructed. It's hard to say without seeing your complete Spring configuration, especially any component scans. I suggest putting a log statement in it's constructor to see if it is the case. If so, ensure there is only one component scan active.
I am trying to get started with Hawtio. How do I deploy a complete new route? I have Hawtio running on local tomcat. I can see in the Camel tab that two routes are predeployed. Then I go to the wiki tab and under the Spring folder, I can define additional camel configurations. But how do I get these configurations to be deployed so I can debug them?
I already answered this on the Camel user list, but just in case folks are looking here; there are two options:
the preferred option is to just use Fabric in JBoss Fuse; which then automatically adds/updates/removes any camel routes created/edited/deleted via the Fuse management Console (which is based on hawtio). You can also take advantage of Fabric's support for rolling upgrades; so you can avoid changing all your containers at once and instead can move containers across to the new version or rollback etc. This all works across many containers with no single point of failure with full version control (a replicated git repository is used for all changes).
if you're not using a Fuse Fabric and are using spring, deploy this
jar into your container (or add it as a dependency in your own WAR based on hawtio-default.war like the sample war in hawtio. This then defaults to watching the spring directory in the wiki for any spring
XML files to deploy/update (including camel spring XML files, ActiveMQ
spring XML files, CXF spring XML files etc)
here's an example project called HawtioCamelWiki which implements the above; using the spring watcher; its a single WAR which has a git based wiki internally so you can create and edit camel routes or spring XML files and they update on the fly
hawtio is a lightweight and modular web console with lots of plugins. So you cannot create any Route with hawtio itself. What you can do is create a standalone apache-camlel application and deploy as a war in the tomcat. Subsequently, you can get all the routes, Queues,Endpoints in the hawtio web console.
Same way you can get the ActiveMQ in to the hawtio as well.
Hope this would help you.
The Camel web page says
The following projects can leverage Apache Camel as a routing and mediation engine:
Apache ServiceMix - a popular distributed open source ESB and JBI container
Apache ActiveMQ - a mature, widely used open source message broker
Apache CXF - a smart web services suite (JAX-WS and JAX-RS)
Apache Karaf - a small OSGi based runtime in which applications can be deployed
Apache MINA - a high-performance NIO-driven networking framework
However, I would like to run Camel inside a Java EE web application and have access to web services, JMS, and EJB (CDI, message driven beans, JPA, etc.) Preferably using an open source Java EE server.
If I recommend this to my company, then then all the usual Java EE wizards such as wsdl2java need to work out of the box. There also needs to be documentation and tutorials so we can hire people to jump in and start using it.
Glassfish failed across the board. The wsdl2java wizard for CXF fails using the Glassfish runtime classes (I ran it manually and hacked my code tree.) There is no documentation nor any tutorials for wiring in OpenMQ (and google searches on the topic are discouraging.) Simple library-only samples run fine, of course, but without having ActiveMQ as the native JMS it seems to be a dead end. CXF integration seems unworkable as well. My first attempt at copying a WS sample complains "No component found with scheme: cxf" which appears to be a bundle or classpath issue.
I'm starting to think I should go back to ServiceMix and drop back to servlets without EJBs and CDI, even though I really hated not being able to use Eclipse gracefully for edit/compile/debug (you pretty much have to build and run from an outside DOS prompt window and remote debug in.)
You can use Apache Camel with any container of choice. We try to not have any restrictions or barriers. You can also run it standalone. The web page just mentions some of the containers you can use.
Apache Camel is just a bunch of JAR files you can deploy and use in any container of choice. For example with WAR files you can deploy to Tomcat, TomEE, etc.