camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem jiang <willem.ji...@gmail.com>
Subject Re: cxfrs: Address already in use at Redeployment
Date Fri, 16 Nov 2012 07:32:44 GMT
Hi,

camel-cxfrs consumer will not shutdown the jetty server when you shutdown the server.
When you use Spring, the CXF bus will be shutdown when the Application Context is shutdown
and camel-cxf cannot do any thing about it.
So you hit the issue when you using the CDI in this way.

You may consider to use the CXF servlet transport[1] to avoid this redeploy issue.

[1]http://cxf.apache.org/docs/servlet-transport.html 

-- 
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang 
Weibo: willemjiang





On Wednesday, November 14, 2012 at 10:46 PM, Chris Pro wrote:

> Hello
> 
> I use Camel (2.10.2) inside Glassfish (3.1.2.2) with the CdiCamelContext as Singleton.
I don't want to use Spring, so I use CDI. I have many JMS-Routes, which works all fine. But
I have a strange issue with "cxfrs" and "Address already in use" after a redeployment.
> The "cxfrs" route looks like that:
> public class RestCamelRoute extends RouteBuilder
> { 
> public RestCamelRoute()
> { }
> 
> @Override
> public void configure() throws Exception
> {
> from("cxfrs://http://127.0.0.1:61621?resourceClasses=" + ValidationRestService.class.getName())
> .process(new Processor()
> {
> public void process(Exchange exchange) throws Exception
> {
> //custom processing here
> }
> })
> .log("-> JAX RS Request Body: \n: ${body}")
> .log("-> JAX RS Request headers: \n: ${headers}")
> .setBody(constant("SUCCESSFULLY"));
> }
> }
> 
> 
> I can deploy that route on Glassfish only once successfully. When I redeploy the route
I see "Address already in use" messages in the log-files. It looks like that the embedded
Jetty-Server is not stopped within an undeployment. 
> 
> The @PreDestroy method is called at the undeployment, which only do "camelCtx.stop()".
Is it possible, that "camelCtx.stop()" is not stopping the jetty server, so the port "61621"
stays open? 
> 
> Here the CDI Singleton:
> @Singleton
> @Startup
> public class CamelBootStrap
> {
> Logger logger = Logger.getLogger(CamelBootStrap.class.getName());
> 
> @Inject
> CdiCamelContext camelCtx;
> 
> @Inject
> RestCamelRoute restCamelRoute;
> 
> @PostConstruct
> public void init() throws Exception
> {
> try
> {
> logger.info (http://logger.info)("$$$$$$ Create CamelContext and register Camel Routes
... $$$$$$");
> 
> camelCtx.addRoutes(restCamelRoute);
> 
> // Start Camel Context
> camelCtx.start();
> 
> logger.info (http://logger.info)("$$$$$$ CamelContext created and camel routes started.
$$$$$$");
> }
> catch (Exception e)
> {
> if(camelCtx != null)
> {
> camelCtx.stop();
> logger.info (http://logger.info)("!!!!! CamelContext stopped within INIT !!!!!");
> }
> }
> }
> 
> 
> /**
> * Camel Stoppen
> * @throws Exception
> */
> @PreDestroy
> public void stop() throws Exception
> {
> camelCtx.stop();
> logger.info (http://logger.info)("!!!!! CamelContext stopped within PreDestroy !!!!!");
> System.out.println("$$$$$$$$$$ CAMEL STOPPED $$$$$$$$$$");
> }
> }
> 
> Would be great if someone could help me.
> 
> Greetings
> Chris




Mime
View raw message