Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
2.12.3
-
None
-
Unknown
-
Regression
Description
When using the camel-quartz component in an unmanged context with multiple camel contexts, for example in a JUnit test case, causes the scheduler to be created with the instance name "DefaultQuartzScheduler" which is then shared across all camel context's within the same jvm.
This is in contradiction of the previous behaviour that uses `getCamelContext.getName()` which isolates the scheduler by denoting that the default instance is specific to the camel context.
package org.apache.camel.component.quartz; import org.apache.camel.CamelContext; import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.management.JmxSystemPropertyKeys; import org.junit.Test; import org.quartz.Scheduler; import org.quartz.SchedulerException; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotSame; /** * Test regression of camel-context isolation of default scheduler instance introduced in CAMEL-7034. */ public class QuartzComponentCamelContextSchedulerIsolationTest { @Test public void testSchedulerIsolation_unmanaged() throws Exception { disableJMX(); testSchedulerIsolation(); } @Test public void testSchedulerIsolation_managed() throws Exception { enableJMX(); testSchedulerIsolation(); } private void testSchedulerIsolation() throws Exception { CamelContext context = createCamelContext(); context.start(); CamelContext anotherContext = createCamelContext(); assertNotEquals(anotherContext.getName(), context.getName()); assertNotEquals(anotherContext, context); assertNotSame(getDefaultScheduler(context), getDefaultScheduler(anotherContext)); } /** * Create a new camel context instance. */ private DefaultCamelContext createCamelContext() { return new DefaultCamelContext(); } /** * Get the quartz component for the provided camel context. */ private QuartzComponent getQuartzComponent(CamelContext context) { return context.getComponent("quartz", QuartzComponent.class); } /** * Get the default scheduler for the provided camel context. */ private Scheduler getDefaultScheduler(CamelContext context) throws SchedulerException { return getQuartzComponent(context).getFactory().getScheduler(); } /** * Disables the JMX agent. */ private void disableJMX() { System.setProperty(JmxSystemPropertyKeys.DISABLED, "true"); } /** * Enables the JMX agent. */ private void enableJMX() { System.setProperty(JmxSystemPropertyKeys.DISABLED, "false"); } }
Attachments
Issue Links
- is related to
-
CAMEL-7034 camel-quartz - Should auto assign scheduler instance name with camel management name
- Resolved