You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2009/03/19 08:19:30 UTC

svn commit: r755862 - in /servicemix/smx4/nmr/trunk: assembly/src/main/filtered-resources/ jbi/itests/src/test/java/org/apache/servicemix/jbi/itests/ jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/ nmr/core/ nmr/core/src/main/java/org...

Author: gnodet
Date: Thu Mar 19 07:19:29 2009
New Revision: 755862

URL: http://svn.apache.org/viewvc?rev=755862&view=rev
Log:
SMX4NMR-86: Thread pools created by the EndpointRegistryImpl for ChanneImpl can not be managed / configured

Modified:
    servicemix/smx4/nmr/trunk/assembly/src/main/filtered-resources/features.xml
    servicemix/smx4/nmr/trunk/jbi/itests/src/test/java/org/apache/servicemix/jbi/itests/IntegrationTest.java
    servicemix/smx4/nmr/trunk/jbi/itests/src/test/java/org/apache/servicemix/jbi/itests/ManagementTest.java
    servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/EndpointImpl.java
    servicemix/smx4/nmr/trunk/nmr/core/pom.xml
    servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ChannelImpl.java
    servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ClientChannel.java
    servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/EndpointRegistryImpl.java
    servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ServiceMix.java
    servicemix/smx4/nmr/trunk/nmr/osgi/pom.xml
    servicemix/smx4/nmr/trunk/nmr/osgi/src/main/resources/META-INF/spring/servicemix-nmr.xml

Modified: servicemix/smx4/nmr/trunk/assembly/src/main/filtered-resources/features.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/assembly/src/main/filtered-resources/features.xml?rev=755862&r1=755861&r2=755862&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/assembly/src/main/filtered-resources/features.xml (original)
+++ servicemix/smx4/nmr/trunk/assembly/src/main/filtered-resources/features.xml Thu Mar 19 07:19:29 2009
@@ -30,6 +30,10 @@
         <bundle>mvn:org.apache.servicemix.transaction/org.apache.servicemix.transaction/${version}</bundle>
     </feature>
     <feature name="nmr" version="${version}">
+        <!-- those two bundles are currently required for servicemix-utils to resolve -->
+        <bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.activation-api-1.1/${servicemix.specs.version}</bundle>
+        <bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jbi-api-1.0/${servicemix.specs.version}</bundle>
+        <bundle>mvn:org.apache.servicemix/servicemix-utils/${servicemix.utils.version}</bundle>
         <bundle>mvn:org.apache.servicemix.document/org.apache.servicemix.document/${pom.version}</bundle>
         <bundle>mvn:org.apache.servicemix.nmr/org.apache.servicemix.nmr.api/${pom.version}</bundle>
         <bundle>mvn:org.apache.servicemix.nmr/org.apache.servicemix.nmr.core/${pom.version}</bundle>
@@ -47,13 +51,11 @@
         <feature version="${version}">naming</feature>
         <feature version="${version}">transaction</feature>
         <feature version="${version}">nmr</feature>
-        <bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.activation-api-1.1/${servicemix.specs.version}</bundle>
         <bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.javamail-api-1.4/${servicemix.specs.version}</bundle>
         <bundle>mvn:org.apache.xbean/xbean-classloader/${xbean.version}</bundle>
         <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.woodstox/${woodstox.version}</bundle>
         <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.wsdl4j/${wsdl4j.version}</bundle>
         <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.ant/${ant.version}</bundle>
-        <bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jbi-api-1.0/${servicemix.specs.version}</bundle>
         <bundle>mvn:org.apache.servicemix.jbi/org.apache.servicemix.jbi.runtime/${pom.version}</bundle>
         <bundle>mvn:org.apache.servicemix.jbi/org.apache.servicemix.jbi.osgi/${pom.version}</bundle>
         <bundle>mvn:org.apache.servicemix.jbi/org.apache.servicemix.jbi.deployer/${pom.version}</bundle>

Modified: servicemix/smx4/nmr/trunk/jbi/itests/src/test/java/org/apache/servicemix/jbi/itests/IntegrationTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/itests/src/test/java/org/apache/servicemix/jbi/itests/IntegrationTest.java?rev=755862&r1=755861&r2=755862&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/itests/src/test/java/org/apache/servicemix/jbi/itests/IntegrationTest.java (original)
+++ servicemix/smx4/nmr/trunk/jbi/itests/src/test/java/org/apache/servicemix/jbi/itests/IntegrationTest.java Thu Mar 19 07:19:29 2009
@@ -73,6 +73,7 @@
             getBundle("org.apache.xbean", "xbean-classloader"),
             getBundle("org.apache.servicemix.kernel", "org.apache.servicemix.kernel.filemonitor"),
             getBundle("org.apache.servicemix.kernel", "org.apache.servicemix.kernel.management"),
+            getBundle("org.apache.servicemix", "servicemix-utils"),
             getBundle("org.apache.servicemix.nmr", "org.apache.servicemix.nmr.api"),
             getBundle("org.apache.servicemix.nmr", "org.apache.servicemix.nmr.core"),
             getBundle("org.apache.servicemix.nmr", "org.apache.servicemix.nmr.spring"),

Modified: servicemix/smx4/nmr/trunk/jbi/itests/src/test/java/org/apache/servicemix/jbi/itests/ManagementTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/itests/src/test/java/org/apache/servicemix/jbi/itests/ManagementTest.java?rev=755862&r1=755861&r2=755862&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/itests/src/test/java/org/apache/servicemix/jbi/itests/ManagementTest.java (original)
+++ servicemix/smx4/nmr/trunk/jbi/itests/src/test/java/org/apache/servicemix/jbi/itests/ManagementTest.java Thu Mar 19 07:19:29 2009
@@ -58,6 +58,7 @@
             getBundle("org.apache.xbean", "xbean-classloader"),
             getBundle("org.apache.servicemix.kernel", "org.apache.servicemix.kernel.filemonitor"),
             getBundle("org.apache.servicemix.kernel", "org.apache.servicemix.kernel.management"),
+            getBundle("org.apache.servicemix", "servicemix-utils"),
             getBundle("org.apache.servicemix.nmr", "org.apache.servicemix.nmr.api"),
             getBundle("org.apache.servicemix.nmr", "org.apache.servicemix.nmr.core"),
             getBundle("org.apache.servicemix.nmr", "org.apache.servicemix.nmr.spring"),

Modified: servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/EndpointImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/EndpointImpl.java?rev=755862&r1=755861&r2=755862&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/EndpointImpl.java (original)
+++ servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/EndpointImpl.java Thu Mar 19 07:19:29 2009
@@ -26,6 +26,7 @@
 import org.apache.servicemix.nmr.api.Endpoint;
 import org.apache.servicemix.nmr.api.Exchange;
 import org.apache.servicemix.nmr.api.ServiceMixException;
+import org.apache.servicemix.nmr.core.ChannelImpl;
 
 /**
  */
@@ -55,6 +56,13 @@
 
     public void setChannel(Channel channel) {
         this.channel = channel;
+        // We know process exchange is very fast, because those endpoints
+        // will simply add the exchange to the queue, so speed things up
+        // by allowing the delivery channel to deliver and process
+        // exchanges synchronously
+        if (channel instanceof ChannelImpl) {
+            ((ChannelImpl) channel).setShouldRunSynchronously(true);
+        }
     }
 
     public BlockingQueue<Exchange> getQueue() {

Modified: servicemix/smx4/nmr/trunk/nmr/core/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/core/pom.xml?rev=755862&r1=755861&r2=755862&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/core/pom.xml (original)
+++ servicemix/smx4/nmr/trunk/nmr/core/pom.xml Thu Mar 19 07:19:29 2009
@@ -37,6 +37,10 @@
             <artifactId>org.apache.servicemix.nmr.api</artifactId>
         </dependency>
         <dependency>
+            <groupId>org.apache.servicemix</groupId>
+            <artifactId>servicemix-utils</artifactId>
+        </dependency>
+        <dependency>
             <groupId>commons-logging</groupId>
             <artifactId>commons-logging</artifactId>
         </dependency>
@@ -79,7 +83,10 @@
                     <instructions>
                         <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
                         <Export-Package>${pom.artifactId}*</Export-Package>
-                        <Import-Package>org.apache.camel.*;resolution:=optional,*</Import-Package>
+                        <Import-Package>
+                            org.apache.camel.*;resolution:=optional,
+                            *
+                        </Import-Package>
                     </instructions>
                 </configuration>
             </plugin>

Modified: servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ChannelImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ChannelImpl.java?rev=755862&r1=755861&r2=755862&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ChannelImpl.java (original)
+++ servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ChannelImpl.java Thu Mar 19 07:19:29 2009
@@ -20,7 +20,6 @@
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
-import java.util.concurrent.ExecutorService;
 import java.util.concurrent.RejectedExecutionException;
 import java.util.concurrent.atomic.AtomicBoolean;
 
@@ -37,6 +36,8 @@
 import org.apache.servicemix.nmr.api.internal.InternalChannel;
 import org.apache.servicemix.nmr.api.internal.InternalEndpoint;
 import org.apache.servicemix.nmr.api.internal.InternalExchange;
+import org.apache.servicemix.executors.Executor;
+import org.apache.servicemix.executors.ExecutorAwareRunnable;
 
 /**
  * The {@link org.apache.servicemix.nmr.api.Channel} implementation.
@@ -51,12 +52,13 @@
     private static final Log LOG = LogFactory.getLog(NMR.class);
 
     private final InternalEndpoint endpoint;
-    private final ExecutorService executor;
+    private final Executor executor;
     private final NMR nmr;
     private String name;
     private AtomicBoolean closed = new AtomicBoolean();
+    private boolean shouldRunSynchronously;
 
-    public ChannelImpl(InternalEndpoint endpoint, ExecutorService executor, NMR nmr) {
+    public ChannelImpl(InternalEndpoint endpoint, Executor executor, NMR nmr) {
         this.endpoint = endpoint;
         this.executor = executor;
         this.nmr = nmr;
@@ -69,6 +71,14 @@
         }
     }
 
+    public boolean isShouldRunSynchronously() {
+        return shouldRunSynchronously;
+    }
+
+    public void setShouldRunSynchronously(boolean shouldRunSynchronously) {
+        this.shouldRunSynchronously = shouldRunSynchronously;
+    }
+
     /**
      * Access to the bus
      *
@@ -195,10 +205,13 @@
         }
         // Delegate processing to the executor
         try {
-            this.executor.execute(new Runnable() {
+            this.executor.execute(new ExecutorAwareRunnable() {
                 public void run() {
                     process(exchange);
                 }
+                public boolean shouldRunSynchronously() {
+                    return shouldRunSynchronously;
+                }
             });
         } catch (RejectedExecutionException e) {
             if (closed.get()) {

Modified: servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ClientChannel.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ClientChannel.java?rev=755862&r1=755861&r2=755862&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ClientChannel.java (original)
+++ servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ClientChannel.java Thu Mar 19 07:19:29 2009
@@ -27,6 +27,7 @@
 import org.apache.servicemix.nmr.api.NMR;
 import org.apache.servicemix.nmr.api.internal.InternalChannel;
 import org.apache.servicemix.nmr.api.internal.InternalEndpoint;
+import org.apache.servicemix.executors.Executor;
 
 /**
  * A {@link Channel} to be used as a client.
@@ -34,8 +35,8 @@
  */
 public class ClientChannel extends ChannelImpl {
 
-    public ClientChannel(NMR nmr) {
-        super(new ClientEndpoint(), Executors.newCachedThreadPool(), nmr);
+    public ClientChannel(NMR nmr, Executor executor) {
+        super(new ClientEndpoint(), executor, nmr);
         getEndpoint().setChannel(this);
     }
 

Modified: servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/EndpointRegistryImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/EndpointRegistryImpl.java?rev=755862&r1=755861&r2=755862&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/EndpointRegistryImpl.java (original)
+++ servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/EndpointRegistryImpl.java Thu Mar 19 07:19:29 2009
@@ -23,8 +23,6 @@
 import java.util.WeakHashMap;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
 
 import org.w3c.dom.Document;
 
@@ -37,6 +35,9 @@
 import org.apache.servicemix.nmr.api.event.EndpointListener;
 import org.apache.servicemix.nmr.api.internal.InternalEndpoint;
 import org.apache.servicemix.nmr.api.service.ServiceRegistry;
+import org.apache.servicemix.executors.ExecutorFactory;
+import org.apache.servicemix.executors.Executor;
+import org.apache.servicemix.executors.impl.ExecutorFactoryImpl;
 
 /**
  * Implementation of {@link EndpointRegistry} interface that defines
@@ -47,11 +48,15 @@
  */
 public class EndpointRegistryImpl implements EndpointRegistry {
 
+    public static final String EXECUTOR_PREFIX = "nmr.endpoint.";
+    public static final String EXECUTOR_DEFAULT = "default";
+
     private NMR nmr;
     private ConcurrentMap<Endpoint, InternalEndpoint> endpoints = new ConcurrentHashMap<Endpoint, InternalEndpoint>();
     private Map<InternalEndpoint, Endpoint> wrappers = new ConcurrentHashMap<InternalEndpoint, Endpoint>();
     private Map<CacheableReference, Boolean> references = new WeakHashMap<CacheableReference, Boolean>();
     private ServiceRegistry<InternalEndpoint> registry;
+    private ExecutorFactory executorFactory;
 
     public EndpointRegistryImpl() {
     }
@@ -68,6 +73,14 @@
         this.nmr = nmr;
     }
 
+    public ExecutorFactory getExecutorFactory() {
+        return executorFactory;
+    }
+
+    public void setExecutorFactory(ExecutorFactory executorFactory) {
+        this.executorFactory = executorFactory;
+    }
+
     public ServiceRegistry<InternalEndpoint> getRegistry() {
         return registry;
     }
@@ -83,6 +96,9 @@
         if (registry == null) {
             registry = new ServiceRegistryImpl<InternalEndpoint>();
         }
+        if (executorFactory == null) {
+            executorFactory = new ExecutorFactoryImpl();
+        }
     }
 
     /**
@@ -98,7 +114,14 @@
     public void register(Endpoint endpoint, Map<String, ?> properties) {
         InternalEndpointWrapper wrapper = new InternalEndpointWrapper(endpoint, properties);
         if (endpoints.putIfAbsent(endpoint, wrapper) == null) {
-            ExecutorService executor = Executors.newCachedThreadPool();
+            // Get executor
+            String name = (String) properties.get(Endpoint.NAME);
+            if (name == null || name.length() == 0) {
+                name = EXECUTOR_DEFAULT;
+            }
+            name = EXECUTOR_PREFIX + name;
+            Executor executor = executorFactory.createExecutor(name);
+            // Create channel
             ChannelImpl channel = new ChannelImpl(wrapper, executor, nmr);
             wrapper.setChannel(channel);
             wrappers.put(wrapper, endpoint);

Modified: servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ServiceMix.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ServiceMix.java?rev=755862&r1=755861&r2=755862&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ServiceMix.java (original)
+++ servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/ServiceMix.java Thu Mar 19 07:19:29 2009
@@ -24,23 +24,32 @@
 import org.apache.servicemix.nmr.api.internal.Flow;
 import org.apache.servicemix.nmr.api.internal.FlowRegistry;
 import org.apache.servicemix.nmr.api.service.ServiceHelper;
+import org.apache.servicemix.executors.ExecutorFactory;
+import org.apache.servicemix.executors.impl.ExecutorFactoryImpl;
 
 /**
  * This class is the servicemix class implementing the NMR
  */
 public class ServiceMix implements NMR {
 
+    public static final String EXECUTOR_CLIENT = "nmr.client";
+
     private EndpointRegistry endpoints;
     private ListenerRegistry listeners;
     private FlowRegistry flows;
     private WireRegistry wires;
+    private ExecutorFactory executorFactory;
 
     /**
      * Initialize ServiceMix
      */
     public void init() {
+        if (executorFactory == null) {
+            executorFactory = new ExecutorFactoryImpl();
+        }
         if (endpoints == null) {
             EndpointRegistryImpl reg = new EndpointRegistryImpl(this);
+            reg.setExecutorFactory(executorFactory);
             reg.init();
             endpoints = reg;
         }
@@ -112,13 +121,32 @@
         this.flows = flows;
     }
 
+
+    /**
+     * Access the executor factory
+     *
+     * @return the executor factory
+     */
+    public ExecutorFactory getExecutorFactory() {
+        return executorFactory;
+    }
+
+    /**
+     * Set the executor factory
+     *
+     * @param executorFactory the executor factory
+     */
+    public void setExecutorFactory(ExecutorFactory executorFactory) {
+        this.executorFactory = executorFactory;
+    }
+
     /**
      * Create a channel to interact with the NMR without exposing an endpoint.
      *
      * @return a channel
      */
     public Channel createChannel() {
-        return new ClientChannel(this);
+        return new ClientChannel(this, executorFactory.createExecutor(EXECUTOR_CLIENT));
     }
 
     /**

Modified: servicemix/smx4/nmr/trunk/nmr/osgi/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/osgi/pom.xml?rev=755862&r1=755861&r2=755862&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/osgi/pom.xml (original)
+++ servicemix/smx4/nmr/trunk/nmr/osgi/pom.xml Thu Mar 19 07:19:29 2009
@@ -80,6 +80,8 @@
                         <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
                         <Import-Package>
                             org.apache.servicemix.document,
+                            org.apache.servicemix.executors,
+                            org.apache.servicemix.executors.impl,
                             org.apache.servicemix.nmr.api,
                             org.apache.servicemix.nmr.api.event,
                             org.apache.servicemix.nmr.api.internal,

Modified: servicemix/smx4/nmr/trunk/nmr/osgi/src/main/resources/META-INF/spring/servicemix-nmr.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/osgi/src/main/resources/META-INF/spring/servicemix-nmr.xml?rev=755862&r1=755861&r2=755862&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/osgi/src/main/resources/META-INF/spring/servicemix-nmr.xml (original)
+++ servicemix/smx4/nmr/trunk/nmr/osgi/src/main/resources/META-INF/spring/servicemix-nmr.xml Thu Mar 19 07:19:29 2009
@@ -19,15 +19,21 @@
 -->
 <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:ctx="http://www.springframework.org/schema/context"
        xmlns:osgi="http://www.springframework.org/schema/osgi"
+       xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
        xmlns:util="http://www.springframework.org/schema/util"
        xsi:schemaLocation="
   http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans.xsd
+  http://www.springframework.org/schema/context
+  http://www.springframework.org/schema/context/spring-context.xsd
   http://www.springframework.org/schema/util
   http://www.springframework.org/schema/util/spring-util.xsd
   http://www.springframework.org/schema/osgi
-  http://www.springframework.org/schema/osgi/spring-osgi.xsd">
+  http://www.springframework.org/schema/osgi/spring-osgi.xsd
+  http://www.springframework.org/schema/osgi-compendium
+  http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd">
 
     <!-- ServiceMix NMR -->
     <bean id="servicemix" class="org.apache.servicemix.nmr.core.ServiceMix">
@@ -35,6 +41,7 @@
         <property name="listenerRegistry" ref="listenerRegistry" />
         <property name="flowRegistry" ref="flowRegistry" />
         <property name="wireRegistry" ref="wireRegistry" />
+        <property name="executorFactory" ref="executorFactory" />
     </bean>
     <osgi:service ref="servicemix">
         <osgi:interfaces>
@@ -68,6 +75,7 @@
     <bean id="endpointRegistry" class="org.apache.servicemix.nmr.core.EndpointRegistryImpl">
         <property name="nmr" ref="servicemix" />
         <property name="registry" ref="internalEndpointRegistry" />
+        <property name="executorFactory" ref="executorFactory" />
     </bean>
     <bean id="internalEndpointRegistry" class="org.apache.servicemix.nmr.osgi.InternalRegistryWrapper" />
     <bean class="org.apache.servicemix.nmr.osgi.OsgiServiceRegistryTracker">
@@ -107,4 +115,27 @@
     <bean id="authenticationService" class="org.apache.servicemix.nmr.core.security.JaasAuthenticationService" />
     <osgi:service ref="authenticationService" interface="org.apache.servicemix.nmr.api.security.AuthenticationService" />
 
+    <!-- ExecutorFactory -->
+    <bean id="executorFactory" class="org.apache.servicemix.executors.impl.ExecutorFactoryImpl">
+        <property name="defaultConfig">
+            <bean class="org.apache.servicemix.executors.impl.ExecutorConfig">
+                <property name="allowCoreThreadsTimeout" value="${allowCoreThreadsTimeout}" />
+                <property name="corePoolSize" value="${threadPoolCorePoolSize}"/>
+                <property name="maximumPoolSize" value="${threadPoolMaximumPoolSize}"/>
+                <property name="queueSize" value="${threadPoolQueueSize}"/>
+                <property name="bypassIfSynchronous" value="${bypassIfSynchronous}" />
+            </bean>
+        </property>
+    </bean>
+
+    <osgix:cm-properties id="cmProps" persistent-id="org.apache.servicemix.nmr">
+        <prop key="allowCoreThreadsTimeout">true</prop>
+        <prop key="threadPoolCorePoolSize">1</prop>
+        <prop key="threadPoolMaximumPoolSize">16</prop>
+        <prop key="threadPoolQueueSize">256</prop>
+        <prop key="bypassIfSynchronous">true</prop>
+    </osgix:cm-properties>
+
+    <ctx:property-placeholder properties-ref="cmProps" />
+
 </beans>