6 Replies Latest reply on Sep 11, 2012 8:34 AM by jodonya

    switchyard config file problem

    jodonya

      I have really tried to get my switchyard configuration file correct but I am still missing out on something

       

      I am getting the error below

       

      [ERROR] Failed to execute goal org.switchyard:switchyard-plugin:0.6.0-SNAPSHOT:configure (default) on project myproject: Model [org.switchyard.config.model.switchyard.v1.V1SwitchYardModel] is invalid: cvc-complex-type.2.4.a: Invalid content was found starting with element 'component'. One of '{WC[##other:"http://docs.oasis-open.org/ns/opencsa/sca/200912"]}' is expected. -> [Help 1]

       

       

      now, here is my configuration file

       

      <?xml version="1.0" encoding="UTF-8"?>

      <switchyard xmlns="urn:switchyard-config:switchyard:1.0"

                                     xmlns:rules="urn:switchyard-component-rules:config:1.0"

                  xmlns:camel="urn:switchyard-component-camel:config:1.0">

          <composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" name="myproject" targetNamespace="urn:myproject:0.1.0">

         

                              <service name="FirstService" promote="FirstService">

                                              <camel:binding.jms>

                                                        <camel:queue>firstQueue</camel:queue>

                                                        <camel:connectionFactory>#ConnectionFactory</camel:connectionFactory>

                                              </camel:binding.jms>

                                    </service>

       

       

                                    <service name="SecondService" promote="SecondService">

                                              <camel:binding.jms>

                                                        <camel:queue>secondQueue</camel:queue>

                                                        <camel:connectionFactory>#ConnectionFactory</camel:connectionFactory>

                                              </camel:binding.jms>

                                    </service>

       

       

                                    <service name="GreetingService" promote="GreetingService">

                                              <camel:binding.jms>

                                                        <camel:queue>GreetingServiceQueue</camel:queue>

                                                        <camel:connectionFactory>#ConnectionFactory</camel:connectionFactory>

                                              </camel:binding.jms>

                                    </service>

                          <service name="ServiceName" promote="ServiceName">

                                    <interface.java interface="path.to.interfacename"></interface.java>

                          </service>

       

                          <rules:implementation.rules agent="true">

                                    <rules:resource location="META-INF/ChangeSet.xml" type="CHANGE_SET"/>

                          </rules:implementation.rules>

       

       

                </composite>

      </switchyard>

       

       

      I adapted most of the stuff from switchyard quickstarts, the camel-jms-binding, could there be something that my eyeballs can't see that is really wrong with this config file?

        • 1. Re: switchyard config file problem
          kcbabo

          Looks like the <component> definition around your "ServiceName" service and implementation is missing.  The quickstarts can be a useful guide for seeing how different types of apps run, but I would recommend using the tooling over cut/copy from quickstarts when creating a new app.

           

          Here's the tooling details and a getting started guide to creating an app:

          https://docs.jboss.org/author/display/SWITCHYARD/Quick+Start

          https://docs.jboss.org/author/display/SWITCHYARD/Installing+Eclipse+Tooling

           

          The tooling is much faster/easier to use and it's very hard to produce broken configurations with it.

          1 of 1 people found this helpful
          • 2. Re: switchyard config file problem
            jodonya

            thanks Keith, I realized my problem was actually the mixup (for lack of a better word) created by a mix of annotations and xml configuration , I got insights when I looked at another post you made in this forum regarding the same. I decided to move most of my configs into SY xml file and now I dont have the same confusion.

             

            Now, one more question;

             

            How can I invoke the rule service in switchyard, I saw you guys were using the invoker (SwitchYard invoker) in the SY tests, can you please give me an insight on how to do that in my bean service or do I need to still do the traditional stuff Knowledge Builder and Knowledge session? I have a rules service already configured but I just done know how to get it fired.

            • 3. Re: switchyard config file problem
              kcbabo

              Just so I'm clear, you have two services in your application:

               

              1) A rules service.

              2) A bean service.

               

              You want #2 to invoke #1?  If so, you can define a reference in the bean service to the rules service and invoke it through a Java interface.  If you post your switchyard.xml, we can give you an idea of what this would look like.

              • 4. Re: switchyard config file problem
                jodonya

                Thanks Keith,

                 

                below is my SY config file, I want say, the TickService to invoke TradeRules service , TradeRules extends Trade, so, my config looks extactly like below, I tried calling the tradeRules.send inside my TickService my I can see a trace of the rules service going to the server.

                 

                Thanks again

                 

                <?xml version="1.0" encoding="UTF-8"?>

                <switchyard xmlns="urn:switchyard-config:switchyard:1.0">

                    <composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" name="mytrader" targetNamespace="urn:mytrader:0.1.0">

                        <service name="BarService" promote="BarService">

                            <camel:binding.jms xmlns:camel="urn:switchyard-component-camel:config:1.0">

                                <camel:queue>barQueue</camel:queue>

                                <camel:connectionFactory>#ConnectionFactory</camel:connectionFactory>

                            </camel:binding.jms>

                        </service>

                        <component name="Trade">

                            <implementation.rules xmlns="urn:switchyard-component-rules:config:1.0" agent="true" clock="REALTIME" eventProcessing="CLOUD" multithreadEvaluation="false">

                                <action name="send" type="FIRE_ALL_RULES"/>

                                <audit interval="100" log="event" type="THREADED_FILE"/>

                                <resource location="META-INF/ChangeSet.xml" type="CHANGE_SET"/>

                            </implementation.rules>

                            <service name="Trade">

                                <interface.java interface="com.magick.mytrader.trade.Trade"/>

                            </service>

                        </component>

                        <component name="TickService">

                            <implementation.bean xmlns="urn:switchyard-component-bean:config:1.0" class="com.magick.mytrader.TickServiceBean"/>

                            <service name="TickService">

                                <interface.java interface="com.magick.mytrader.TickService"/>

                            </service>

                            <reference name="TradeRules">

                                <interface.java interface="com.magick.mytrader.trade.TradeRules"/>

                            </reference>

                        </component>

                        <component name="BarService">

                            <implementation.bean xmlns="urn:switchyard-component-bean:config:1.0" class="com.magick.mytrader.BarServiceBean"/>

                            <service name="BarService">

                                <interface.java interface="com.magick.mytrader.BarService"/>

                            </service>

                        </component>

                        <service name="TickService" promote="TickService">

                            <camel:binding.jms xmlns:camel="urn:switchyard-component-camel:config:1.0">

                                <camel:queue>tickQueue</camel:queue>

                                <camel:connectionFactory>#ConnectionFactory</camel:connectionFactory>

                            </camel:binding.jms>

                        </service>

                        <component name="TradeRules">

                            <implementation.bean xmlns="urn:switchyard-component-bean:config:1.0" class="com.magick.mytrader.trade.TradeRulesBean"/>

                            <service name="TradeRules">

                                <interface.java interface="com.magick.mytrader.trade.TradeRules"/>

                            </service>

                        </component>

                    </composite>

                </switchyard>

                • 5. Re: switchyard config file problem
                  kcbabo

                  I'm not sure what the interface looks like for com.magick.mytrader.trade.TradeRules, but the way this would be invoked from a Bean service would be:

                   

                  1) Inject a reference to the service into your bean

                  2) Call a method on the injected interface

                   

                  public class TickServiceBean implements TickService {
                     @Inject @Reference
                      TradeRules tradeRules.
                  
                     public void myMethod(Tick tick) {
                        tradeRules.doSomething(tick);
                      }
                  }
                  

                   

                  Note that you do not use the test Invoker class inside of service implementations - that's only for unit tests. 

                   

                  ~ keith

                  • 6. Re: switchyard config file problem
                    jodonya

                    thanks Keith, I managed to fire my rules, I realized I was missing out on setting the globals, the fact was not getting provided, after I provided the global configuration for tick, everything was fine and I could fired the methods in rule service as you have indicated above,

                     

                    thanks again