From d62dd50b7bbbb3f68bb6e0924655308d807f48a4 Mon Sep 17 00:00:00 2001 From: Brian Clements Date: Fri, 10 Jan 2014 14:32:44 -0600 Subject: [PATCH] Issue #2608 quartz components use single scheduler configured quartz components to use a single scheduler added workaround to camel limitation which requires management name set on context added quartz properties file copied from the quartz jar (can be used to set thread count) Former-commit-id: 3959c9e02332beb653ab8154f7902c96161b47e3 [formerly 3959c9e02332beb653ab8154f7902c96161b47e3 [formerly 2b16524026b3c8834e5846f8cd800ae4e1a95e07]] Former-commit-id: 1a5991dcf52e5f078ecf55299d53741ecd25a27f Former-commit-id: f0b260d1ce0b612193da23bbfb8f42f4b7e34779 --- edexOsgi/build.edex/esb/conf/spring/edex.xml | 26 ++- .../build.properties | 3 +- .../resources/quartz.properties | 13 ++ .../ManagementNameLifecycleStrategy.java | 176 ++++++++++++++++++ 4 files changed, 216 insertions(+), 2 deletions(-) create mode 100644 edexOsgi/com.raytheon.uf.edex.esb.camel/resources/quartz.properties create mode 100644 edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/quartz/ManagementNameLifecycleStrategy.java diff --git a/edexOsgi/build.edex/esb/conf/spring/edex.xml b/edexOsgi/build.edex/esb/conf/spring/edex.xml index 8f08ea06e1..572b7f23fb 100644 --- a/edexOsgi/build.edex/esb/conf/spring/edex.xml +++ b/edexOsgi/build.edex/esb/conf/spring/edex.xml @@ -344,5 +344,29 @@ - + + + + + + + + + + + + + + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.edex.esb.camel/build.properties b/edexOsgi/com.raytheon.uf.edex.esb.camel/build.properties index 34d2e4d2da..342f3ffdb3 100644 --- a/edexOsgi/com.raytheon.uf.edex.esb.camel/build.properties +++ b/edexOsgi/com.raytheon.uf.edex.esb.camel/build.properties @@ -1,4 +1,5 @@ source.. = src/ output.. = bin/ bin.includes = META-INF/,\ - . + .,\ + resources/ diff --git a/edexOsgi/com.raytheon.uf.edex.esb.camel/resources/quartz.properties b/edexOsgi/com.raytheon.uf.edex.esb.camel/resources/quartz.properties new file mode 100644 index 0000000000..33aa837cfb --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.esb.camel/resources/quartz.properties @@ -0,0 +1,13 @@ +org.quartz.scheduler.instanceName = DefaultQuartzScheduler +org.quartz.scheduler.rmi.export = false +org.quartz.scheduler.rmi.proxy = false +org.quartz.scheduler.wrapJobExecutionInUserTransaction = false + +org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool +org.quartz.threadPool.threadCount = 10 +org.quartz.threadPool.threadPriority = 5 +org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread = true + +org.quartz.jobStore.misfireThreshold = 60000 + +org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/quartz/ManagementNameLifecycleStrategy.java b/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/quartz/ManagementNameLifecycleStrategy.java new file mode 100644 index 0000000000..01a553ade2 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/quartz/ManagementNameLifecycleStrategy.java @@ -0,0 +1,176 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.edex.esb.camel.quartz; + +import java.util.Collection; +import java.util.concurrent.ThreadPoolExecutor; + +import org.apache.camel.CamelContext; +import org.apache.camel.Component; +import org.apache.camel.Endpoint; +import org.apache.camel.ErrorHandlerFactory; +import org.apache.camel.Processor; +import org.apache.camel.Route; +import org.apache.camel.Service; +import org.apache.camel.VetoCamelContextStartException; +import org.apache.camel.impl.DefaultCamelContext; +import org.apache.camel.spi.LifecycleStrategy; +import org.apache.camel.spi.RouteContext; + +/** + * Ensures that the management name field of the camel context is set. If it is + * found to be null, it will be populated with the name of the context. This is + * to work around a limitation in the QuartzComponent that it uses the + * management name as a hash key for contexts. + * https://issues.apache.org/jira/browse/CAMEL-7132 + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jan 13, 2014 2608       bclement     Initial creation
+ * 
+ * 
+ * + * @author bclement + * @version 1.0 + */ +public class ManagementNameLifecycleStrategy implements LifecycleStrategy { + + /* (non-Javadoc) + * @see org.apache.camel.spi.LifecycleStrategy#onContextStart(org.apache.camel.CamelContext) + */ + @Override + public void onContextStart(CamelContext context) + throws VetoCamelContextStartException { + if (context.getManagementName() == null + && context instanceof DefaultCamelContext) { + ((DefaultCamelContext) context) + .setManagementName(context.getName()); + } + } + + /* (non-Javadoc) + * @see org.apache.camel.spi.LifecycleStrategy#onContextStop(org.apache.camel.CamelContext) + */ + @Override + public void onContextStop(CamelContext context) { + } + + /* (non-Javadoc) + * @see org.apache.camel.spi.LifecycleStrategy#onComponentAdd(java.lang.String, org.apache.camel.Component) + */ + @Override + public void onComponentAdd(String name, Component component) { + } + + /* (non-Javadoc) + * @see org.apache.camel.spi.LifecycleStrategy#onComponentRemove(java.lang.String, org.apache.camel.Component) + */ + @Override + public void onComponentRemove(String name, Component component) { + } + + /* (non-Javadoc) + * @see org.apache.camel.spi.LifecycleStrategy#onEndpointAdd(org.apache.camel.Endpoint) + */ + @Override + public void onEndpointAdd(Endpoint endpoint) { + } + + /* (non-Javadoc) + * @see org.apache.camel.spi.LifecycleStrategy#onEndpointRemove(org.apache.camel.Endpoint) + */ + @Override + public void onEndpointRemove(Endpoint endpoint) { + } + + /* (non-Javadoc) + * @see org.apache.camel.spi.LifecycleStrategy#onServiceAdd(org.apache.camel.CamelContext, org.apache.camel.Service, org.apache.camel.Route) + */ + @Override + public void onServiceAdd(CamelContext context, Service service, Route route) { + } + + /* (non-Javadoc) + * @see org.apache.camel.spi.LifecycleStrategy#onServiceRemove(org.apache.camel.CamelContext, org.apache.camel.Service, org.apache.camel.Route) + */ + @Override + public void onServiceRemove(CamelContext context, Service service, + Route route) { + } + + /* (non-Javadoc) + * @see org.apache.camel.spi.LifecycleStrategy#onRoutesAdd(java.util.Collection) + */ + @Override + public void onRoutesAdd(Collection routes) { + } + + /* (non-Javadoc) + * @see org.apache.camel.spi.LifecycleStrategy#onRoutesRemove(java.util.Collection) + */ + @Override + public void onRoutesRemove(Collection routes) { + } + + /* (non-Javadoc) + * @see org.apache.camel.spi.LifecycleStrategy#onRouteContextCreate(org.apache.camel.spi.RouteContext) + */ + @Override + public void onRouteContextCreate(RouteContext routeContext) { + } + + /* (non-Javadoc) + * @see org.apache.camel.spi.LifecycleStrategy#onErrorHandlerAdd(org.apache.camel.spi.RouteContext, org.apache.camel.Processor, org.apache.camel.ErrorHandlerFactory) + */ + @Override + public void onErrorHandlerAdd(RouteContext routeContext, + Processor errorHandler, ErrorHandlerFactory errorHandlerBuilder) { + } + + /* (non-Javadoc) + * @see org.apache.camel.spi.LifecycleStrategy#onErrorHandlerRemove(org.apache.camel.spi.RouteContext, org.apache.camel.Processor, org.apache.camel.ErrorHandlerFactory) + */ + @Override + public void onErrorHandlerRemove(RouteContext routeContext, + Processor errorHandler, ErrorHandlerFactory errorHandlerBuilder) { + } + + /* (non-Javadoc) + * @see org.apache.camel.spi.LifecycleStrategy#onThreadPoolAdd(org.apache.camel.CamelContext, java.util.concurrent.ThreadPoolExecutor, java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public void onThreadPoolAdd(CamelContext camelContext, + ThreadPoolExecutor threadPool, String id, String sourceId, + String routeId, String threadPoolProfileId) { + } + + /* (non-Javadoc) + * @see org.apache.camel.spi.LifecycleStrategy#onThreadPoolRemove(org.apache.camel.CamelContext, java.util.concurrent.ThreadPoolExecutor) + */ + @Override + public void onThreadPoolRemove(CamelContext camelContext, + ThreadPoolExecutor threadPool) { + } + +}