Obvious in hindsight. Thanks very much!

----

My next stumpling block is inside the JmsReceiverComponent:

....
       template.execute(new SessionCallback() {
           public Object doInJms(Session session) throws JMSException {
Destination defaultDestination = template.getDefaultDestination();
               if (defaultDestination == null) {
defaultDestination = template.getDestinationResolver().resolveDestinationName(session, template.getDefaultDestinationName(), template.isPubSubDomain());
               }
consumer = session.createConsumer(defaultDestination, selector);
               return null;
           }
       }, true);
consumer.setMessageListener(this); // ****** IllegalStateException THROWN FROM HERE ******
....

---

I am finding that the template.execute is closing the session as it completes
Closing the session causes my consumer to become closed also
Because the consumer is closed, the setMessageListener API fails with an IllegalStateException

Do you know is this behaviour something I can affect by configuring (what?) differently or is it somehow a quirk of my JMS Provider or what?

Note that I am using
- ServiceMix 1.0
- The JmsReceiverComponent (not the JmsInUsingJCABinding like in the SM examples)

My configuration is as follows

===
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:my="http://servicemix.org/demo/";>

 <!-- the JBI container -->
 <container id="jbi">
   <property name="createMBeanServer" value="true"/>
   <property name="dumpStats" value="true"/>
   <property name="statsInterval" value="10"/>


   <components>
     <!-- 1st. Subscribe to a JMS destination Q1 -->
<component id="inputReceiver" service="my:inputReceiver" class="org.servicemix.components.jms.JmsReceiverComponent" destinationService="my:outputSender">
       <property name="template">
         <bean class="org.springframework.jms.core.JmsTemplate102">
<property name="connectionFactory"><ref bean="myQueueConnectionFactory"/></property> <property name="destinationResolver"><ref bean="myJmsDestinationResolver"/></property> <property name="defaultDestinationName" value="java:comp/env/jms/queue/Q1"/>
           <property name="pubSubDomain" value="false"/>
         </bean>
       </property>
       <property name="selector" value=""/>
     </component>
     <!-- 2nd. Publish the result to a JMS destination Q2 -->
<component id="outputSender" service="my:outputSender" class="org.servicemix.components.jms.JmsSenderComponent">
       <property name="template">
         <bean class="org.springframework.jms.core.JmsTemplate102">
<property name="connectionFactory"><ref bean="myQueueConnectionFactory"/></property> <property name="destinationResolver"><ref bean="myJmsDestinationResolver"/></property> <property name="defaultDestinationName" value="java:comp/env/jms/queue/Q2"/>
           <property name="pubSubDomain" value="false"/>
           <property name="explicitQosEnabled" value="true"/>
           <property name="timeToLive" value="60000"/>
         </bean>
       </property>
</component> </components> </container>

 <!-- Use my own JNDI - The JMS objects are already binded in here -->
 <bean id="myJndi" class="org.springframework.jndi.JndiTemplate">
     <property name="environment">
       <props>
<prop key="java.naming.factory.initial">com.fujitsu.interstage.j2ee.jndi.InitialContextFactoryForClient</prop>
       </props>
     </property>
 </bean>

 <!-- The QueueConnectionFactory is in my JNDI -->
<bean id="myQueueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
   <property name="jndiTemplate" ref="myJndi"/>
   <property name="jndiName" value="java:comp/env/jms/queue/QCF"/>
 </bean>

 <!-- The JMS Destinations are resolved by looking them up in my JNDI -->
<bean id="myJmsDestinationResolver" class="org.springframework.jms.support.destination.JndiDestinationResolver">
   <property name="jndiTemplate" ref="myJndi"/>
 </bean>

<!-- Needed for SpringJBIContainer? --> <bean id="transactionManager" class="org.jencks.factory.TransactionManagerFactoryBean"/>

</beans>

===

Thanks again.
Peter.

Guillaume Nodet wrote:

The container (ServiceMix specific element) must only contains components. The other beans that you defined (myQueueConnectionFactory and myJndi) must appear
outside of the container element.

You can see the bean defined in the spring configuration in the log.
The org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [jbi];
statement says that there is only one bean defined named jbi.

Cheers,
Guillaume Nodet

Peter Smith wrote:

<snip>

Reply via email to