Author: jleroux
Date: Fri Jun 3 19:05:07 2011 New Revision: 1131144 URL: http://svn.apache.org/viewvc?rev=1131144&view=rev Log: Closes "JmsTopicListener started twice when distributed-cache-clear is active" reported by Martin Kreidenweis at https://issues.apache.org/jira/browse/OFBIZ-4296 Simply avoid to start a JMS Listener thread from Job Manager when DCC is on. Then set it back to previous value. Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/Delegator.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/Delegator.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/Delegator.java?rev=1131144&r1=1131143&r2=1131144&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/Delegator.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/Delegator.java Fri Jun 3 19:05:07 2011 @@ -1209,4 +1209,17 @@ public interface Delegator { */ public int storeByCondition(String entityName, Map<String, ? extends Object> fieldsToSet, EntityCondition condition, boolean doCacheClear) throws GenericEntityException; + /** + * Enables/Disables the JMS listeners globally + * (this will not effect any dispatchers already running) + * @param enable + */ + public void enableJMS(boolean enable); + + /** + * Get Enabled/Disabled JMS listeners status + * @return boolean true is JMS listeners are enabled + */ + public boolean getEnabledJMS(); + } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java?rev=1131144&r1=1131143&r2=1131144&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java Fri Jun 3 19:05:07 2011 @@ -73,6 +73,7 @@ import org.ofbiz.entity.util.EntityCrypt import org.ofbiz.entity.util.EntityFindOptions; import org.ofbiz.entity.util.EntityListIterator; import org.ofbiz.entity.util.SequenceUtil; +//import org.ofbiz.service.ServiceDispatcher; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -88,7 +89,6 @@ public class GenericDelegator implements protected ModelReader modelReader = null; protected ModelGroupReader modelGroupReader = null; - /** This flag is only here for lower level technical testing, it shouldn't be user configurable (or at least I don't think so yet); when true all operations without a transaction will be wrapped in one; seems to be necessary for some (all?) XA aware connection pools, and should improve overall stability and consistency */ public static final boolean alwaysUseTransaction = true; @@ -105,6 +105,7 @@ public class GenericDelegator implements protected Map<?,?> andCacheFieldSets = FastMap.newInstance(); protected DistributedCacheClear distributedCacheClear = null; + protected boolean enableJMS = true; protected EntityEcaHandler<?> entityEcaHandler = null; protected SequenceUtil sequencer = null; protected EntityCrypto crypto = null; @@ -308,7 +309,10 @@ public class GenericDelegator implements try { Class<?> eecahClass = loader.loadClass(entityEcaHandlerClassName); this.entityEcaHandler = UtilGenerics.cast(eecahClass.newInstance()); + boolean isJmsEnabled = getEnabledJMS(); + enableJMS(!getDelegatorInfo().useDistributedCacheClear); // To avoid duplicated JMS listeners (OFBIZ-4296) this.entityEcaHandler.setDelegator(this); + enableJMS(isJmsEnabled); } catch (ClassNotFoundException e) { Debug.logWarning(e, "EntityEcaHandler class with name " + entityEcaHandlerClassName + " was not found, Entity ECA Rules will be disabled", module); } catch (InstantiationException e) { @@ -2836,4 +2840,19 @@ public class GenericDelegator implements Debug.logVerbose("Distributed Cache Clear System disabled for delegator [" + delegatorFullName + "]", module); } } + + + /* (non-Javadoc) + * @see org.ofbiz.entity.Delegator#enableJMS() + */ + public void enableJMS(boolean enable) { + this.enableJMS = enable; + } + + /* (non-Javadoc) + * @see org.ofbiz.entity.Delegator#getEnableJMS() + */ + public boolean getEnabledJMS() { + return this.enableJMS; + } } Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java?rev=1131144&r1=1131143&r2=1131144&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java Fri Jun 3 19:05:07 2011 @@ -116,7 +116,7 @@ public class ServiceDispatcher { } // make sure we haven't disabled these features from running - if (enableJMS) { + if (enableJMS && this.delegator.getEnabledJMS()) { this.jlf = new JmsListenerFactory(this); } @@ -1100,7 +1100,7 @@ public class ServiceDispatcher { } /** - * Enabled/Disables the Job Manager/Scheduler globally + * Enables/Disables the Job Manager/Scheduler globally * (this will not effect any dispatchers already running) * @param enable */ @@ -1109,7 +1109,7 @@ public class ServiceDispatcher { } /** - * Enabled/Disables the JMS listeners globally + * Enables/Disables the JMS listeners globally * (this will not effect any dispatchers already running) * @param enable */ @@ -1117,8 +1117,17 @@ public class ServiceDispatcher { ServiceDispatcher.enableJMS = enable; } + + /** + * Get Enabled/Disabled JMS listeners status + * @return boolean true is JMS listeners are enabled + */ + public static boolean getEnableJMS() { + return ServiceDispatcher.enableJMS; + } + /** - * Enabled/Disables the startup services globally + * Enables/Disables the startup services globally * (this will not effect any dispatchers already running) * @param enable */ |
Free forum by Nabble | Edit this page |