Announcement Announcement Module
Collapse
No announcement yet.
Multiple connectionFactory in xml config Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiple connectionFactory in xml config

    Hi,

    Is it possible to have multiple connectionFactory in the xml config.
    Reason being, I have input coming from MQ q and send the response to a ActiveMQ q.

  • #2
    I don't see a reason why not... Assuming you tried, what did you do and what happened?

    Comment


    • #3
      it complains when I start up the app, with this
      Exception in thread "main" org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'AMQConnectionFactory' defined in class path resource [common.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'sessionCacheSize' of bean class [org.apache.activemq.ActiveMQConnectionFactory]: Bean property 'sessionCacheSize' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
      =======================

      If i remove my mq stuff and revert the changes as per the demo app, it works fine


      Heres my cfg, please advise if I'm doing something wrong?

      <bean id="MQConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
      <property name="hostName" value="mypc"/>
      <property name="port" value="1414"/>
      <property name="channel" value="S_EE"/>
      <property name="queueManager" value="QM_EE"/>
      <property name="transportType" value="1"/>
      </bean>

      <bean id="connectionFactory" class="org.springframework.jms.connection.CachingC onnectionFactory">
      <property name="targetConnectionFactory" ref="jmsQueueConnectionFactory" />
      </bean>

      <bean id="jmsQueueConnectionFactory" class="org.springframework.jms.connection.UserCred entialsConnectionFactoryAdapter">
      <property name="targetConnectionFactory" ref="MQConnectionFactory"/>
      <property name="username" value=" "/>
      <property name="password" value=" "/>
      </bean>

      <bean id="requestQueue" class="com.ibm.mq.jms.MQQueue">
      <constructor-arg value="dud_sync_out"/>
      </bean>

      <bean id="replyQueue" class="com.ibm.mq.jms.MQQueue">
      <constructor-arg value="dud_sync_in"/>
      </bean>

      <bean id="q.out1" class="com.ibm.mq.jms.MQQueue">
      <constructor-arg value="dud_async_out"/>
      </bean>

      <bean id="q.out2" class="com.ibm.mq.jms.MQQueue">
      <constructor-arg value="dud_async_in"/>
      </bean>


      <!-- ACTIVE MQ -->
      <bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFacto ry">
      <property name="brokerURL" value="tcp://localhost:61616"/>
      <property name="sessionCacheSize" value="10"/>
      <property name="cacheProducers" value="false"/>
      </bean>


      <bean id="requestQueue" class="org.apache.activemq.command.ActiveMQQueue">
      <constructor-arg value="queue.demo"/>
      </bean>


      <bean id="replyQueue" class="org.apache.activemq.command.ActiveMQQueue">
      <constructor-arg value="queue.reply"/>
      </bean>

      <bean id="q.out1" class="org.apache.activemq.command.ActiveMQQueue">
      <constructor-arg value="q_out1"/>
      </bean>

      <bean id="q.out2" class="org.apache.activemq.command.ActiveMQQueue">
      <constructor-arg value="q_out2"/>
      </bean>

      <integrationoller id="poller" default="true">
      <integration:interval-trigger interval="1000"/>
      </integrationoller>
      Last edited by dudleygb; Mar 6th, 2009, 03:20 AM.

      Comment


      • #4
        Read the stacktrace, it tells you you're setting a property that is not available on the ActiveMQConnectionFactory. From the config I can see that you are doing that in fact. Did you use code completion in Spring IDE to write this configuration file?

        Comment


        • #5
          agreed, and yes I used autocomplete in eclipse.
          but it seems to be that you have to use the words connectionFactory and as soon as you put two bean id=connectionFactory, it gives an error

          There are multiple occurrences of ID value 'connectionFactory'.

          If you change the id of each connectionFactory to connectionFactory1 and connectionFactory2 then you get

          No bean named 'connectionFactory' is defined

          So u have to have at least one bean with connectionFactory, but u cant have two.
          Is there a way?

          Comment


          • #6
            You can only have one bean with the same id within a single Spring ApplicationContext.

            What you need to do is simply provide the 'connection-factory' attribute to your Spring Integration JMS gateways. If none is provided, the default name it looks for is "connectionFactory". If you need to provide different names, then just set it explicitly. For example:
            Code:
            <jms:inbound-gateway connection-factory="whateverYouCallIt" ... />

            Comment


            • #7
              brilliant thanx, let me give it a try


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

              works like a charm thank you, thats the final bit of info I needed, YAY
              Last edited by dudleygb; Mar 6th, 2009, 09:14 AM.

              Comment

              Working...
              X