Hi guys,
I have question related to the best way to connect to ActiveMQ from a
consumer and a producer. So does the way to connect to ActiveMQ from a
consumer and  a producer have to be the same? that is, using caching in both
sides, connection pooling, max number of connections...etc

My current configuration is as below:

Consumer <-> ActiveMQ <-> Producer (where all routes live)

Below is the consumer settings to connect to ActiveMQ


<?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:jms="http://www.springframework.org/schema/jms";
       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://www.springframework.org/schema/jms
       http://www.springframework.org/schema/jms/spring-jms.xsd
       ">

    <bean id="jmsConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory" >
        <property name="brokerURL" value="${hub.brokerURL}" />
    </bean>

    <bean id="cachingConnectionFactory"
class="org.springframework.jms.connection.CachingConnectionFactory">
        <property name="targetConnectionFactory" ref="jmsConnectionFactory"
/>
        <property name="sessionCacheSize" value="10" />
    </bean>

    <bean id="jmsConfig"
class="org.apache.camel.component.jms.JmsConfiguration">
        <property name="connectionFactory" ref="cachingConnectionFactory" />
    </bean>

    <bean id="activemq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="configuration" ref="jmsConfig" />
    </bean>


    <camel:proxy id="financeService"
serviceInterface="com.wyn.hub.client.service.FinanceService"
                 serviceUrl="jms:queue:finance" />

    <camel:proxy id="salesService"
serviceInterface="com.wyn.hub.client.service.SalesService"
                 serviceUrl="jms:queue:sales" />

 </beans>

------------------------------------------------------------

And this is the producer settings to connect to ActiveMQ

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans";
           xmlns:context="http://www.springframework.org/schema/context";
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
       xmlns:camel="http://camel.apache.org/schema/spring";
       xmlns:p="http://www.springframework.org/schema/p";
       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://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd";>
         
                
        
        <camel:camelContext id="camel-server">
           <camel:package>com.wyn.camel.route</camel:package>
                <camel:jmxAgent id="agent" createConnector="true" />
        </camel:camelContext>

        <bean id="jmsConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory"
p:brokerURL="${jms.broker.URL}"/>

        <bean id="pooledConnectionFactory"
                  class="org.apache.activemq.pool.PooledConnectionFactory"
                  init-method="start" destroy-method="stop">

                <property name="connectionFactory" ref="jmsConnectionFactory" />
                <property name="maxConnections" value="10" />
                <property name="expiryTimeout" value="-1" />
                <property name="idleTimeout" value="0" />
        </bean>

        <bean id="jmsConfig"
class="org.apache.camel.component.jms.JmsConfiguration">
                <property name="connectionFactory" 
ref="pooledConnectionFactory" />

                <property name="transacted" value="true" />
                <property name="concurrentConsumers" value="15" />
                <property name="deliveryPersistent" value="true" />
                <property name="requestTimeout" value="10000" />
                <property name="cacheLevelName"  value="CACHE_CONSUMER" />

        </bean>

        <bean id="activemq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
                <property name="configuration" ref="jmsConfig" />
                <property name="transacted" value="true" />
                <property name="cacheLevelName" value="CACHE_CONSUMER" />
        </bean>
</beans>

Appreciate your input.  



--
View this message in context: 
http://camel.465427.n5.nabble.com/Connecting-to-ActiveMQ-by-a-consumer-and-a-producer-best-practice-tp5780718.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to