You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Mark <el...@gmail.com> on 2013/09/11 04:04:23 UTC

Camel-jetty and hawt.io

I have some Camel routes that I have running in a standalone java app, and
I'd like to embed hawt in the JVM.  Is it possible to do since Camel and
Hawt will want their own jetty instance running in the JVM?

Thanks in advance,
Mark

Re: Camel-jetty and hawt.io

Posted by James Strachan <ja...@gmail.com>.
The easiest thing is gonna be to run it stand alone:
http://hawt.io/getstarted/index.html

   java -jar hawtio-app-1.2-M10.jar

or put your camel routes into a WAR and deploy it and hawtio's
hawtio-default.WAR into a stand alone Jetty.

But if you really wanna keep an embedded Camel main application with jetty
inside; you could in java code invoke the hawtio embedded main; or if you
want to hand-wire the hawtio war into the same Jetty server used by the
Camel Jetty component; you'll have to dig into the camel-jetty / jetty code
I'm afraid; I've never tried. It looks like the JettyHttpComponent doesn't
expose the Jetty Server object it creates unfortunately.

So you might have to create your own derivation of JettyHttpComponent,
register it into your camel context and override this method so you can
keep track of the Jetty Server object; then add in the hawtio web app using
Jetty's Java API:
https://github.com/apache/camel/blob/master/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java#L944

Thats sounding like hard work though so I'd do one of these things:

1) - use hawtio stand alone as above

2) -  put your camel routes in a WAR & deploy it in jetty with
hawtio-default.war

3) -  run the hawtio embedded main()
https://github.com/hawtio/hawtio/blob/master/hawtio-embedded/src/main/java/io/hawt/embedded/Main.java#L25

on a different port from inside your application main(), before you invoke
the camel's main() (so you make sure both main() functions are properly
invoked) - but make sure you disable the join flag, so the hawtio main
returns and doesn't wait for its jetty server to keep running.
https://github.com/hawtio/hawtio/issues/508


Options 1 or 2 are the simplest :)


On 11 September 2013 15:50, Mark <el...@gmail.com> wrote:
>
> Then what?  I added the dependency to the pom.xml.  I can't find any
> documentation and what the next step would be.
>
>
>
>
> On Wed, Sep 11, 2013 at 10:16 AM, James Strachan
> <ja...@gmail.com>wrote:
>
> > On 11 September 2013 15:11, Mark <el...@gmail.com> wrote:
> >
> > > There may be a larger problem WRT dependencies though.  Is there a
way to
> > > embed hawt into an existing jetty instance programatically?
> > >
> >
> > Sure, just add the hawtio-default.war
> >
> >
> >
> > >
> > >
> > >
> > > On Wed, Sep 11, 2013 at 6:30 AM, James Strachan <
> > james.strachan@gmail.com
> > > >wrote:
> > >
> > > > On 11 September 2013 03:04, Mark <el...@gmail.com> wrote:
> > > > > I have some Camel routes that I have running in a standalone java
> > app,
> > > > and
> > > > > I'd like to embed hawt in the JVM.  Is it possible to do since
Camel
> > > and
> > > > > Hawt will want their own jetty instance running in the JVM?
> > > >
> > > > Sure. Or you could run hawtio stand alone and connect remotely to
it:
> > > > http://hawt.io/getstarted/index.html
> > > >
> > > > Or you could use hawtio-embedded (which just starts up an embedded
> > > > Jetty server). If you're stand alone camel routes are doing the same
> > > > and starting a Jetty too then you could:
> > > >
> > > > * make sure they are listening on different ports; so you'd have 2
> > > > embedded Jetty Server instances.
> > > >
> > > > * if you want to reuse the same port and Jetty Server; you'll
probably
> > > > need to do some custom Java code or Dependency Injection stuff to
wire
> > > > the same Jetty Server into both Camel and hawtio but using different
> > > > web app contexts. Though its probably not worth the effort though ;)
> > > >
> > > > So just using different ports would be the simplest ;) At least you
> > > > should be able to share the same Jetty jars :)
> > > >
> > > > --
> > > > James
> > > > -------
> > > > Red Hat
> > > >
> > > > Email: jstracha@redhat.com
> > > > Web: http://fusesource.com
> > > > Twitter: jstrachan, fusenews
> > > > Blog: http://macstrac.blogspot.com/
> > > >
> > > > Open Source Integration
> > > >
> > >
> >
> >
> >
> > --
> > James
> > -------
> > Red Hat
> >
> > Email: jstracha@redhat.com
> > Web: http://fusesource.com
> > Twitter: jstrachan, fusenews
> > Blog: http://macstrac.blogspot.com/
> >
> > Open Source Integration
> >




--
James
-------
Red Hat

Email: jstracha@redhat.com
Web: http://fusesource.com
Twitter: jstrachan, fusenews
Blog: http://macstrac.blogspot.com/

Open Source Integration

Re: Camel-jetty and hawt.io

Posted by Mark <el...@gmail.com>.
Then what?  I added the dependency to the pom.xml.  I can't find any
documentation and what the next step would be.




On Wed, Sep 11, 2013 at 10:16 AM, James Strachan
<ja...@gmail.com>wrote:

> On 11 September 2013 15:11, Mark <el...@gmail.com> wrote:
>
> > There may be a larger problem WRT dependencies though.  Is there a way to
> > embed hawt into an existing jetty instance programatically?
> >
>
> Sure, just add the hawtio-default.war
>
>
>
> >
> >
> >
> > On Wed, Sep 11, 2013 at 6:30 AM, James Strachan <
> james.strachan@gmail.com
> > >wrote:
> >
> > > On 11 September 2013 03:04, Mark <el...@gmail.com> wrote:
> > > > I have some Camel routes that I have running in a standalone java
> app,
> > > and
> > > > I'd like to embed hawt in the JVM.  Is it possible to do since Camel
> > and
> > > > Hawt will want their own jetty instance running in the JVM?
> > >
> > > Sure. Or you could run hawtio stand alone and connect remotely to it:
> > > http://hawt.io/getstarted/index.html
> > >
> > > Or you could use hawtio-embedded (which just starts up an embedded
> > > Jetty server). If you're stand alone camel routes are doing the same
> > > and starting a Jetty too then you could:
> > >
> > > * make sure they are listening on different ports; so you'd have 2
> > > embedded Jetty Server instances.
> > >
> > > * if you want to reuse the same port and Jetty Server; you'll probably
> > > need to do some custom Java code or Dependency Injection stuff to wire
> > > the same Jetty Server into both Camel and hawtio but using different
> > > web app contexts. Though its probably not worth the effort though ;)
> > >
> > > So just using different ports would be the simplest ;) At least you
> > > should be able to share the same Jetty jars :)
> > >
> > > --
> > > James
> > > -------
> > > Red Hat
> > >
> > > Email: jstracha@redhat.com
> > > Web: http://fusesource.com
> > > Twitter: jstrachan, fusenews
> > > Blog: http://macstrac.blogspot.com/
> > >
> > > Open Source Integration
> > >
> >
>
>
>
> --
> James
> -------
> Red Hat
>
> Email: jstracha@redhat.com
> Web: http://fusesource.com
> Twitter: jstrachan, fusenews
> Blog: http://macstrac.blogspot.com/
>
> Open Source Integration
>

Re: Camel-jetty and hawt.io

Posted by James Strachan <ja...@gmail.com>.
On 11 September 2013 15:11, Mark <el...@gmail.com> wrote:

> There may be a larger problem WRT dependencies though.  Is there a way to
> embed hawt into an existing jetty instance programatically?
>

Sure, just add the hawtio-default.war



>
>
>
> On Wed, Sep 11, 2013 at 6:30 AM, James Strachan <james.strachan@gmail.com
> >wrote:
>
> > On 11 September 2013 03:04, Mark <el...@gmail.com> wrote:
> > > I have some Camel routes that I have running in a standalone java app,
> > and
> > > I'd like to embed hawt in the JVM.  Is it possible to do since Camel
> and
> > > Hawt will want their own jetty instance running in the JVM?
> >
> > Sure. Or you could run hawtio stand alone and connect remotely to it:
> > http://hawt.io/getstarted/index.html
> >
> > Or you could use hawtio-embedded (which just starts up an embedded
> > Jetty server). If you're stand alone camel routes are doing the same
> > and starting a Jetty too then you could:
> >
> > * make sure they are listening on different ports; so you'd have 2
> > embedded Jetty Server instances.
> >
> > * if you want to reuse the same port and Jetty Server; you'll probably
> > need to do some custom Java code or Dependency Injection stuff to wire
> > the same Jetty Server into both Camel and hawtio but using different
> > web app contexts. Though its probably not worth the effort though ;)
> >
> > So just using different ports would be the simplest ;) At least you
> > should be able to share the same Jetty jars :)
> >
> > --
> > James
> > -------
> > Red Hat
> >
> > Email: jstracha@redhat.com
> > Web: http://fusesource.com
> > Twitter: jstrachan, fusenews
> > Blog: http://macstrac.blogspot.com/
> >
> > Open Source Integration
> >
>



-- 
James
-------
Red Hat

Email: jstracha@redhat.com
Web: http://fusesource.com
Twitter: jstrachan, fusenews
Blog: http://macstrac.blogspot.com/

Open Source Integration

Re: Camel-jetty and hawt.io

Posted by Mark <el...@gmail.com>.
There may be a larger problem WRT dependencies though.  Is there a way to
embed hawt into an existing jetty instance programatically?



On Wed, Sep 11, 2013 at 6:30 AM, James Strachan <ja...@gmail.com>wrote:

> On 11 September 2013 03:04, Mark <el...@gmail.com> wrote:
> > I have some Camel routes that I have running in a standalone java app,
> and
> > I'd like to embed hawt in the JVM.  Is it possible to do since Camel and
> > Hawt will want their own jetty instance running in the JVM?
>
> Sure. Or you could run hawtio stand alone and connect remotely to it:
> http://hawt.io/getstarted/index.html
>
> Or you could use hawtio-embedded (which just starts up an embedded
> Jetty server). If you're stand alone camel routes are doing the same
> and starting a Jetty too then you could:
>
> * make sure they are listening on different ports; so you'd have 2
> embedded Jetty Server instances.
>
> * if you want to reuse the same port and Jetty Server; you'll probably
> need to do some custom Java code or Dependency Injection stuff to wire
> the same Jetty Server into both Camel and hawtio but using different
> web app contexts. Though its probably not worth the effort though ;)
>
> So just using different ports would be the simplest ;) At least you
> should be able to share the same Jetty jars :)
>
> --
> James
> -------
> Red Hat
>
> Email: jstracha@redhat.com
> Web: http://fusesource.com
> Twitter: jstrachan, fusenews
> Blog: http://macstrac.blogspot.com/
>
> Open Source Integration
>

Re: Camel-jetty and hawt.io

Posted by James Strachan <ja...@gmail.com>.
On 11 September 2013 03:04, Mark <el...@gmail.com> wrote:
> I have some Camel routes that I have running in a standalone java app, and
> I'd like to embed hawt in the JVM.  Is it possible to do since Camel and
> Hawt will want their own jetty instance running in the JVM?

Sure. Or you could run hawtio stand alone and connect remotely to it:
http://hawt.io/getstarted/index.html

Or you could use hawtio-embedded (which just starts up an embedded
Jetty server). If you're stand alone camel routes are doing the same
and starting a Jetty too then you could:

* make sure they are listening on different ports; so you'd have 2
embedded Jetty Server instances.

* if you want to reuse the same port and Jetty Server; you'll probably
need to do some custom Java code or Dependency Injection stuff to wire
the same Jetty Server into both Camel and hawtio but using different
web app contexts. Though its probably not worth the effort though ;)

So just using different ports would be the simplest ;) At least you
should be able to share the same Jetty jars :)

-- 
James
-------
Red Hat

Email: jstracha@redhat.com
Web: http://fusesource.com
Twitter: jstrachan, fusenews
Blog: http://macstrac.blogspot.com/

Open Source Integration