camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nafees <s.nafeesunn...@gmail.com>
Subject Routes controlling + thread dsl
Date Mon, 10 Sep 2012 10:08:45 GMT
Hello All,

I am using thread dsl to implement parallel processing in my route.

I have one ROUTE_FTP --  from (ftp).to(fileUrl).bean(endRoute);

I want to use thread dsl .. so that threads pick up files n do processing
simultaneously. With camel , it was so easy to do this.

I created a ThreadPoolProfile whose size is 5 and registered with
ExecutorServiceManager

ExecutorService service ;

ThreadPoolProfile customProfile = new ThreadPoolProfile("customProfile");
		customProfile.setPoolSize(5);
		customProfile.setMaxPoolSize(5);
	
camelContext.getExecutorServiceManager().registerThreadPoolProfile(customProfile);
		service = camelContext.getExecutorServiceManager().newThreadPool(this,
localRouteName, customProfile);

from(fileUrl).noAutoStartup().routeId(localRouteName)
            	.threads()
            	.bean(processManager)
            	.bean(endRoute,localMethod).stop()
            	.setExecutorService(service);

later when route is completed , i am calling this to remove the threads.
            camelContext.getExecutorServiceManager().shutdown(service);

Everything is working perfectly. I would like to learn how better we could
make this.

Only concern i have is .. ROUTE_FTP and ROUTE_LOCAL can be given commands to
suspend, resume and cancel. 

when my action is suspend/resume/cancel , camel is unable to do the action.
How to achieve this. I want the threads also to be suspended/resumed/cancel
along with my route. 

sample pause function 
public void pause() {
		try {
			for (String routeId : routesIds) {
				ServiceStatus routeStatus = camelContext.getRouteStatus(routeId);
				if (routeStatus.isStarted()) {
					camelContext.suspendRoute(routeId);
					logger.info("Route : "+routeId+" suspended");
				} else if (routeStatus.isStopped()) {
					logger.info(true, tubeMessage.getSourceName(), "Route : " + routeId + "
is stopped , so cant pause");
				}
			}
		} catch (Exception e) {
			logger.error(true, tubeMessage.getSourceName(), "Problem while pausing
the mediation process " + e.getMessage());
		}
	}// pause

What things should be done in order to do this. Earlier , without threads(),
suspend/resume/cancel were working fine. 

Please help me

Thanks & Regards
Nafees



--
View this message in context: http://camel.465427.n5.nabble.com/Routes-controlling-thread-dsl-tp5719019.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message