Need to know the way to work with Apache Camel - apache-camel

I am new to Apache Camel. I have read several documentation of it and went through the examples (only of XML DSL) that Apache provide with its jar. I have a spring MVC project running over tomcat, and in the same project I need to include an Integration Framework. I have installed JBoss plugin for tooling so that I can drag and drop components but palette isn't showing any component but a message 'A palette is not working'. So, please suggest me how should I proceed to implement the same. For now I am referring Camel in Action. And, if possible, then provide an example to send a https request to any URL with some header parameters and transform its response and print it on console or write it to any file or give another https request to any other URL with the payload.

you mentioned that you installed the JBoss plugin for tooling, do you mean that you installed the JBoss Fuse Tooling?
Which version of Eclipse or JBoss Developer Studio are you using? Which OS are you using?
In Fuse Tooling, several examples are provided based on archetypes, I let you check the "CHAPTER 5. CREATING A NEW FUSE PROJECT" in
https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.2.1/pdf/Tooling_User_Guide/Red_Hat_JBoss_Fuse-6.2.1-Tooling_User_Guide-en-US.pdf

Related

keycloak version to use with (react, spring boot, postgres)

what is the best version of keycloak to use with spring boot as backend and react as frontend and I can setup easily with a postgres database, I've tested the latest version 19.0.1 but I couldn't set it up with react and spring boot and it doesn't take the postgres DB I specified in env variables.
can you please suggest me the best version to use and some tutorials, videos or articles to learn more about it and how to implement it in production.
thanks in advance.
I recommand you don't use Keycloak Spring adapters, it is deprecated.
The latest Keycloak version works perfectly. Maybe you just misconfigured or use the wrong libs.
For client (react app), pick a library from certified list
For resource-server (Spring REST API), use either:
spring-boot-starter-oauth2-resource-server (but require quite some Java conf)
spring-addons-webmvc-jwt-resource-server (a lot is configurable from properties, including CORS and roles mapping)
Regarding the connection to Postgres, maybe should you return to the doc and read more carefully.
I'd recomend using the keycloak-spring-boot-starter.
Here is an article on how to set it up: https://www.baeldung.com/spring-boot-keycloak
I would also recomend to always use the most recent version. Especially for a security tool like keycloak. If it doesn't work with the tutorial just set it up in the version the tutorial references and then migrate to a newer version step by step using migration guides.

Embedding jetty for Apache camel

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

How to reload camel context automatically in openshift 3.x using fis-java

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).

Deploy New Route with Hawtio

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.

Which Java EE container works for Apache Camel/CXF/ActiveMQ web applications using EJBs?

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.

Resources