You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by sunderb <su...@dellteam.com> on 2011/09/16 20:30:53 UTC

Limit number of JMS Processor

Hi

We are connecting to weblogic JMS queue - through a standalone camel
application - Using the below camelContext file. The idea is to check for
pending message in JMS queue and process them one after the other. We would
like to limit the number of processors processing at one instance of time.
Do we need to adjust default thread pool for the same?

Thanks
sunder

 <threadPoolProfile id="defaultThreadPoolProfile" defaultProfile="true"
                       poolSize="10" maxPoolSize="20" maxQueueSize="1000"
                       rejectedPolicy="CallerRuns"/>



<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:camel="http://camel.apache.org/schema/spring"
       xmlns:broker="http://activemq.apache.org/schema/core"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
        http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
        http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core-5.5.0.xsd">

        
 	
    
    <bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>


	  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
	      <route>
	          <from uri="weblogic:queue:jms/xxincqueue"/>
	          <process ref="iIncrementalDBChangeProcessor"/>
	      </route>
	  </camelContext>



    <bean id="weblogic" class="org.apache.camel.component.jms.JmsComponent">
      <property name="connectionFactory" ref="weblogicConnectionFactory"/>
      <property name="destinationResolver"
ref="weblogicDestinationResolver"/>
    </bean>

    <bean id="weblogicDestinationResolver"
class="org.springframework.jms.support.destination.JndiDestinationResolver">
      <property name="jndiTemplate" ref="remoteJndi" /> 
    </bean>

    <bean id="weblogicConnectionFactory"
class="org.springframework.jndi.JndiObjectFactoryBean">
      <property name="jndiTemplate" ref="remoteJndi" />
      <property name="jndiName" value="jms/xxincqcf" />
    </bean>

    <bean id="remoteJndi" class="org.springframework.jndi.JndiTemplate"> 
      <property name="environment"> 
          <props> 
              <prop
key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop> 
              <prop
key="java.naming.provider.url">t3://yyhost01.us.dell.com:9001</prop> 
          </props>
      </property> 
     </bean>   


	<bean id="iIncrementalDBChangeProcessor"
class="com.xx.listener.IncrementalDBChangeProcessor"/>

</beans>

public class IncrementalDBChangeProcessor implements Processor {
	private static int count = 0;
	private static Logger logger = Logger
	.getLogger(IncrementalDBChangeProcessor.class);	
    public void process(Exchange e) {
        String message = (String) e.getIn().getBody();

        DataMapperUtility dDataBeanMapper = new DataMapperUtility();
        Object oBeanObject = dDataBeanMapper.mapToBean(message);
        count++;

    }
}

public class WLJMSListener {

	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
        // START SNIPPET: e1
    	ApplicationContext context = new
ClassPathXmlApplicationContext("weblogic-listener-camelContext.xml");
        CamelContext camel = (CamelContext) context.getBean("camel");
        
                
        camel.start();
	}

}


--
View this message in context: http://camel.465427.n5.nabble.com/Limit-number-of-JMS-Processor-tp4811575p4811575.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Limit number of JMS Processor

Posted by sunderb <su...@dellteam.com>.
Thank you

It did work. Appreciate your response.

Thanks
sunder

--
View this message in context: http://camel.465427.n5.nabble.com/Limit-number-of-JMS-Processor-tp4811575p4812384.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Limit number of JMS Processor

Posted by boday <be...@initekconsulting.com>.
try setting both the concurrentConsumers and maxConcurrentConsumers = 1...

<from
uri="weblogic:queue:jms/xxincqueue?concurrentConsumers=1&maxConcurrentConsumers=1"/>
...


sunderb wrote:
> 
> Hi
> 
> We are connecting to weblogic JMS queue - through a standalone camel
> application - Using the below camelContext file. The idea is to check for
> pending message in JMS queue and process them one after the other. We
> would like to limit the number of processors processing at one instance of
> time. Do we need to adjust default thread pool for the same?
> 
> Thanks
> sunder
> 
>  <threadPoolProfile id="defaultThreadPoolProfile" defaultProfile="true"
>                        poolSize="10" maxPoolSize="20" maxQueueSize="1000"
>                        rejectedPolicy="CallerRuns"/>
> 
> 
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        xmlns:camel="http://camel.apache.org/schema/spring"
>        xmlns:broker="http://activemq.apache.org/schema/core"
>        xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd
>         http://camel.apache.org/schema/spring
> http://camel.apache.org/schema/spring/camel-spring.xsd
>         http://activemq.apache.org/schema/core
> http://activemq.apache.org/schema/core/activemq-core-5.5.0.xsd">
> 
>         
>  	
>     
>     <bean
> class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
> 
> 
> 	  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
> 	      <route>
> 	          <from uri="weblogic:queue:jms/xxincqueue"/>
> 	          <process ref="iIncrementalDBChangeProcessor"/>
> 	      </route>
> 	  </camelContext>
> 
> 
> 
>     <bean id="weblogic"
> class="org.apache.camel.component.jms.JmsComponent">
>       <property name="connectionFactory" ref="weblogicConnectionFactory"/>
>       <property name="destinationResolver"
> ref="weblogicDestinationResolver"/>
>     </bean>
> 
>     <bean id="weblogicDestinationResolver"
> class="org.springframework.jms.support.destination.JndiDestinationResolver">
>       <property name="jndiTemplate" ref="remoteJndi" /> 
>     </bean>
> 
>     <bean id="weblogicConnectionFactory"
> class="org.springframework.jndi.JndiObjectFactoryBean">
>       <property name="jndiTemplate" ref="remoteJndi" />
>       <property name="jndiName" value="jms/xxincqcf" />
>     </bean>
> 
>     <bean id="remoteJndi" class="org.springframework.jndi.JndiTemplate"> 
>       <property name="environment"> 
>           <props> 
>               <prop
> key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop> 
>               <prop
> key="java.naming.provider.url">t3://yyhost01.us.dell.com:9001</prop> 
>           </props>
>       </property> 
>      </bean>   
> 
> 
> 	<bean id="iIncrementalDBChangeProcessor"
> class="com.xx.listener.IncrementalDBChangeProcessor"/>
> 
> </beans>
> 
> public class IncrementalDBChangeProcessor implements Processor {
> 	private static int count = 0;
> 	private static Logger logger = Logger
> 	.getLogger(IncrementalDBChangeProcessor.class);	
>     public void process(Exchange e) {
>         String message = (String) e.getIn().getBody();
> 
>         DataMapperUtility dDataBeanMapper = new DataMapperUtility();
>         Object oBeanObject = dDataBeanMapper.mapToBean(message);
>         count++;
> 
>     }
> }
> 
> public class WLJMSListener {
> 
> 	/**
> 	 * @param args
> 	 * @throws Exception 
> 	 */
> 	public static void main(String[] args) throws Exception {
>         // START SNIPPET: e1
>     	ApplicationContext context = new
> ClassPathXmlApplicationContext("weblogic-listener-camelContext.xml");
>         CamelContext camel = (CamelContext) context.getBean("camel");
>         
>                 
>         camel.start();
> 	}
> 
> }
> 


-----
Ben O'Day
IT Consultant -http://consulting-notes.com

--
View this message in context: http://camel.465427.n5.nabble.com/Limit-number-of-JMS-Processor-tp4811575p4811924.html
Sent from the Camel - Users mailing list archive at Nabble.com.