camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: Proper shutdown of endpoint listener with Spring MVC?
Date Mon, 27 Jul 2009 11:36:11 GMT

You can get a bit information how to run Camel in a web app with Spring

When spring shuts down it should stop Camel as well.
And when Camel stops it should stop its components and thus also
eventually the MINA HL7 listener.

You can enable some logging to see when its shutting down to see if it
does it correctly.

As its the mina component that has the socket listener you can enable
DEBUG logging on it:

And it should log that its starting  / stopping etc.

On Mon, Jul 27, 2009 at 12:52 PM, Johnny2R<> wrote:
> I'm developing an application to process HL7 messages, using Apache Camel
> (1.6.1), MINA, HAPI and Spring. As a lot of it is new to me, I've been
> following the example given by Roger Searjeant here:
> (Thanks, Roger!). I've been developing using NetBeans 6.7 and have a test
> class which sets everything up with FileSystemXmlApplicationContext, which
> runs just fine and can be stopped and started at will without a problem.
> However, my aim for production is that this application should live within
> the context of a Spring MVC web application, started up when the webapp
> starts up and shut down when the webapp shuts down. First time, it starts up
> fine. But if I shut down Tomcat and restart,  the webapp fails to start
> properly because of a problem with the endpoint - evidently something is
> still hanging on to the port from the previous run. The endpoint is defined
> like this:
>    <camel:camelContext>
>        <camel:endpoint id="hl7listener"
> uri="mina:tcp://localhost:8888?sync=true&amp;codec=hl7codec"/>
>    </camel:camelContext>
> My server app is a Spring-managed bean, with a defined init-method where the
> route is added to the SpringCamelContext and the SpringCamelContext is
> started, and a defined destroy-method where stop() is called on the
> SpringCamelContext, but this latter never appears to run (nothing shows in
> the log).
> It may well be that there is a much better way of doing this, using
> something like a ContextListener, in which case I'd be glad to hear of it.
> In any case, what I need is a surefire way of killing off the listener when
> the web server is restarted. Any suggestions would be most welcome.
> --
> View this message in context:
> Sent from the Camel - Users mailing list archive at

Claus Ibsen
Apache Camel Committer

Open Source Integration:

View raw message