camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zappee <>
Subject Re: camel rest route
Date Sun, 21 Feb 2016 15:49:31 GMT
Hi Claus,

Thank you for the links. Especially for the first one. 
I do not use Spring, instead of I use simple CDI and my camel route is not
packaged into war so I do not have any web.xml file.

I've just followed your links and I was able to create a bootstrap java

public class Bootstrap {

    private static final Logger LOGGER =

    private CamelContext context;

    public void init() {
        try {
  "bootstrapping apache camel");
            context.addRoutes(new UserServiceRouteBuilder());
        } catch (Exception e) {
            LOGGER.error("an error occurred during bootstrapping camel
routes", e);

    public void shutdown() {
        try {
  "apache camel routes stopped");
        } catch (Exception e) {
            LOGGER.error("camel stop error", e);

I had to move my-camel-restapi.jar from the lib folder to the root of the
ear file because I got a strange exception. Now the structure of my ear
looks like this:

 |  |- dependencies, ex.: camel jars
 |  |- my-common.jar
 |- my-web-ui.war
 |- my-stateless-ejb.jar
 |- *my-camel-restapi.jar <- it contains my camel rest route*

And my camel rote is improved a little bit:

public class UserServiceRouteBuilder extends RouteBuilder {
    private static final String APPLICATION_JSON_UTF_8 =
    public void configure() throws Exception {
        User user = new User();

                .dataFormatProperty("prettyPrint", "true");

                .description("user rest service")

It works fine, if I make a GET call to http://localhost:8081/user/hello then
I get a proper json answer. Beautiful :) I like Camel, it is a great java
integration tool/framework. It makes Java stronger :)

But I do not understand something. How it is possible to map the restapi to
http port 8081? It means for me that somehow camel starts a small web
container or whatever else on port 8081 inside my GlassFish server. What
happened inside the EE container of the GlassFish?

If I have more, separated camel group of routes packages in different,
separated jars, bootstrapped them separately then I need to use different
ports during the bootstrapping process to avoid the "port in use" error
message. Am I correct? Or I can configure separated routes to use the same
host and port (of course paths need to be different)? How many MB memory is
consumed by my separated jar files with the small "web containers", listen
on different ports?

Can I bootstrap my routes - locate in different jars - by a common from example my-commons.jar? In that case theoretically I
need only one "something" which is listening on ex. port 8081 and all my
routes (rest api) will be available on the same port.


View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message