1 Reply Latest reply on Jul 21, 2009 12:35 PM by Martin Murphy

    chaining servicemix-bean components

    Lowry Curry Newbie

      Using servicemix-bean (v 3.3.x) I've implemented MessageExchangeListener, where inside onMessageExchange i need to write code to create and send an exchange to another service (bean). What is best practice for chaining servicemix-bean components in this way? More specifically, how do i specify my Destination? Thanks,

      -Lowry

        • 1. Re: chaining servicemix-bean components
          Martin Murphy Novice

          Hi Lowry,

           

          I would recommend adding a targetService property to your bean. You can then inject this with the QName of the service you want to invoke on. If you use a property place holder, you can then externalize this service to a file in your conf directory of your servicemix installation. This should allow you maximum flexibility on where the message is sent from your bean. I built a very simple example and deployed this into FUSE ESB 3.4.0.3 and it works fine for me using this approach. My xbean for my servicemix-bean endpoint looks like this:

           

          <beans xmlns="http://www.springframework.org/schema/beans"
               xmlns:bean="http://servicemix.apache.org/bean/1.0" xmlns:file2bean="http://fusesource.com/ts/file2bean"
               xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://servicemix.apache.org/bean/1.0 http://servicemix.apache.org/schema/servicemix-bean-2009.02-SNAPSHOT.xsd
                 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
          
               <bean
                    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
                    <property name="location" value="classpath:mybeandef.properties"></property>
               </bean>
          
               <bean:endpoint service="file2bean:beanone" endpoint="endpoint"
                    bean="#myBean"></bean:endpoint>
          
               <bean id="myBean" class="com.progress.ts.file2bean.beanone.MyBean">
                    <property name="targetService" ref="targetQName"></property>
               </bean>
          
               <bean name="targetQName" class="javax.xml.namespace.QName">
                    <constructor-arg value="${namespace}"></constructor-arg>
                    <constructor-arg value="${service}"></constructor-arg>
               </bean>
          
          </beans>
          

           

          I'm attaching the projects and the properties file.

           

          Hope that helps!

          - Martin