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

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.

Related

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

Need to know the way to work with 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

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.

programmatically get server load information from Apache ServiceMix using JMX

Is it possible to get the server load information of a webserver deployed on a ServiceMix / Fuse ESB.
I dont want to use Jconsole but get the information by running a java file and writing the values into text file.
Could someone point me to some code that I can run on my machine?
Cheers,
Kunal
You can also intall jolokia i ServiceMix which exposes a REST interface over JMX. This makes it much easier for non Java developers and programming languages to access the metrics. It's just a HTTP call to get the data.
http://www.jolokia.org/
We use this library for the http://hawt.io management console so we can get the data easily from a moderne HTML5 web console.
I won't write the code you ask for, but..
Everything in JConsole is accessed through JMX. And everything in JMX is accessible via code as well (basic tutorial here).
So just locate the value/values you are intressted in using JConsole, then just extract them using the JMX api in code.

Accessing EJB in WAR from remote standalone client

I have an EJB accessed remotely from a Swing client as well as locally by servlet/JSP. I want to switch the packaging for my EJB from a EJB/WAR/EAR to a EJB/WAR since it is simpler to work with.
What do I mean by simpler? In Eclipse, for example, I can have a single project with my EJB/web classes rather than having a EJB + WAR + EAR project (My client is a separate project in Eclipse).
Is it possible to package a EJB in a WAR and have it be accessible remotely?
The intent of EJB-in-WAR was primarily to simplify packaging for local EJBs used by the WAR. However, I cannot find a restriction for remote EJBs packaged in a WAR even though there are restrictions on other technologies (specifically, entity beans and JAX-RPC endpoints are not allowed), which leads me to believe remote views are allowed in WARs from a specification perspective. I don't have broad knowledge of vendor implementations, but I have tested that it works on WebSphere Application Server.
According to the web profile and EJB 3.1 specs, Java EE web profile products are only required to provide EJB Lite, which doesn't support remote clients to EJBs.
But they can provide remote ejb client connection as a product optional component.
So if you want to package remote EJBs in a WAR you'll have to look for a Java EE web server that provides this service and be aware that the same behaviour isn't required in other Java EE 6 web servers.
Useful links:
http://download.oracle.com/otndocs/jcp/javaee_web_profile-6.0-fr-eval-oth-JSpec/
http://download.oracle.com/otndocs/jcp/ejb-3.1-fr-eval-oth-JSpec/

Resources