4 Replies Latest reply on Jun 11, 2013 10:40 AM by Marcel König

    Switchyard Property delegation to remote service

    Marcel König Newbie



      I have a main module(jar) with all service classes and a switchyard.xml which defines these main services.

      Then I will have multiple other jars which will define own services by referencing the main services provided by the main module.

      Now I want to delegate properties to these main service but it won't work. I tried different positions of the properties but none of them worked.


      As example I created the following modules:


      The main module: test-switchyard.jar which creates the following service


      public class PropertiesService implements Properties {


           /** The target component. */

           @Property(name = "target")

           private String target;


           /** The encoding. */

           @Property(name = "encoding")

           private String encoding;


           /** The context. */


           private Context context;



            * (non-Javadoc)


            * @see com.web4db.esb.services.Properties#readProperties(java.lang.String)



           public String readProperties(final String message) throws HandlerException {

               return "Property encoding: " + encoding + " target: " + target + " context-encoding: " + context.getPropertyValue("encoding")

                       + "context-target: " + context.getPropertyValue("target");




      the switchyard.xml:

      <sca:component name="Properties">

                   <bean:implementation.bean class="com.web4db.esb.services.PropertiesService" />

                   <sca:service name="Properties">

                       <sca:interface.java interface="com.web4db.esb.services.Properties" />





      Then the sub-module CallTestProperties.jar


      <switchyard xmlns="urn:switchyard-config:switchyard:1.0" xmlns:swyd="urn:switchyard-config:switchyard:1.0" xmlns:bean="urn:switchyard-component-bean:config:1.0" xmlns:camel="urn:switchyard-component-camel:config:1.0" xmlns:file="urn:switchyard-component-camel-file:config:1.0" xmlns:ftp="urn:switchyard-component-camel-ftp:config:1.0" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912">

         <sca:composite name="testimport-esb" targetNamespace="urn:web4db-esb:core:0.1.0">

           <sca:service name="TestImportService" promote="Route/TestImportService">














           <sca:component name="Route">


               <camel:xml path="/CallTestPropertiesRoute.xml"/>


             <sca:service name="TestImportService">

               <interface.esb inputType="java:java.lang.String"/>


             <sca:reference name="Properties">       

             <sca:interface.java interface="com.web4db.esb.services.Properties"/>

                 <sca:property name="target" value="TXT" />   

                 <sca:property name="encoding" value="UTF-8" />    







      <route xmlns="http://camel.apache.org/schema/spring">

           <from uri="switchyard://TestImportService"  />

           <to uri="switchyard://Properties" />               

           <log message="TestImport: ${body}" />                               




      When I test it I get the following result:

      12:31:32,036 INFO  [route17] (Camel (camel-32) thread #66 - ftp://test:******@localhost:21//) TestImport: Property encoding: null target: null context-encoding: null

      context-target: null


      But I am expecting to get this:

      TestImport: Property encoding: UTF-8 target: TXT context-encoding: null context-target: null


      What I am doing wrong?




        • 1. Re: Switchyard Property delegation to remote service
          Keith Babo Master

          If the question is "can I define property values in one application and read those in another application" the answer is no.  Even if you define a dependency between the applications it will not work.  We are planning on introducing shared domains in a future release, which would be the way you could solve this:


          domain : domain1
               setProperty("foo", "bar")
          application : app1
                target-domain : domain1
                 getProperty("foo") = bar [resolved from domain1]
          application : app2
                target-domain : domain1
                getProperty("foo") = bar [resolved from domain1]


          For now, if you want to share a property value between applications, use a System property via standalone.xml or -D.

          • 2. Re: Switchyard Property delegation to remote service
            Marcel König Newbie

            Hi Keith,


            do you know when this feature will be available?

            I cannot use your workaround because we dynamically create our esb services.

            And we are migrating from jboss esb to switchyard, where we extensivly use the action property feature like this:

            <action name=..." class="....">

                                <property name="ejb3" value="true" />

                                <property name="method" value="..." />


            What would be the best approach to migrate something like this:

            Calling a service/component (of another or local application) multiple times within one camel route with different properties/parameter per call?


            Workarounds are also welcome.


            Another question/problem I came up by searching for workarounds is:

            Can I create a bean-component-service with classes located in a different application?

            I always get an error when I create such components.




            • 3. Re: Switchyard Property delegation to remote service
              Keith Babo Master

              Shared domains will not be in 1.0 or 1.1, so we will have to solve this another way for now. 


              You can configure a bean service using properties today in a way very similar to JBossESB.  The docs have details on how that's done. 


              You cannot configure CDI beans invoked from a Camel route directly (e.g. <bean ref="FooBean"> or beanRef("FooBean") via properties, but you can call a CDI Bean service (e.g. to("switchyard://FooService")) from a Camel route and that bean service can be configured with properties as described above.


              If you want to share configuration between applications, you either need to use system properties or you need to pass the shared configuration as context properties when invoking between apps.


              In terms of packaging a bean service implementation in one application and using that in another application, I've never tried it.  In theory, you should be able to declare a module dependency (all deployments are modules in AS 7) from one application to another application and that should allow you to resolve the implementation class.

              • 4. Re: Switchyard Property delegation to remote service
                Marcel König Newbie

                I think the best workaround for me would be to put all services/components into the switchyard.xml of the app with it's own namingcontext. Additionally I want to package all my bean services in one app which then can be called from others.


                But I don't get it to work.

                As example I have attached the global app test-switchyard which provides the classes of the TestService and the CallTestProperties.jar creates a component referencing the TestService of the test-switchyard app.


                When I try to deploy the CallTestProperties.jar I always get this error:

                14:47:27,476 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-9) MSC00001: Failed to start service jboss.deployment.unit."CallTestProperties.jar".SwitchYardS

                ervice: org.jboss.msc.service.StartException in service jboss.deployment.unit."CallTestProperties.jar".SwitchYardService: org.switchyard.exception.SwitchYardExceptio

                n: Unknown Service name '{urn:web4db-esb:core:0.1.0}Test'.

                        at org.switchyard.as7.extension.services.SwitchYardService.start(SwitchYardService.java:85)

                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_23]

                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_23]

                        at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_23]

                Caused by: org.switchyard.exception.SwitchYardException: Unknown Service name '{urn:web4db-esb:core:0.1.0}Test'.

                        at org.switchyard.component.bean.deploy.BeanComponentActivator.activateService(BeanComponentActivator.java:85)

                        at org.switchyard.deploy.internal.Deployment.deployImplementations(Deployment.java:460)

                        at org.switchyard.deploy.internal.Deployment.start(Deployment.java:140)

                        at org.switchyard.as7.extension.deployment.SwitchYardDeployment.start(SwitchYardDeployment.java:106)

                        at org.switchyard.as7.extension.services.SwitchYardService.start(SwitchYardService.java:78)

                        ... 5 more



                If I copy the classes of test-switchyard into CallTestProperties.jar the deployment would work fine.

                Do you have any idea how I can solve that problem? (Any classloading issue?)