0 Replies Latest reply on Jun 13, 2012 2:03 PM by Łukasz Dywicki

    Support for operation selectors in SCA references

    Łukasz Dywicki Novice

      During work on sql quickstart I tried to create one reference with two bindings having different operation selectors. I discovered that this is not supported because always latest binding is executed. I found workaround - create different reference for every operation, however it looks really strange:

       

       

          <composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
              name="camel-sql-binding" targetNamespace="urn:switchyard-quickstart:camel-sql-binding:0.1.0">
          
              <component name="CamelComponent">
                  <service name="GreetingService">
                      <interface.java interface="org.switchyard.quickstarts.camel.sql.binding.GreetingService" />
                  </service>
      
                  <camel:implementation.camel>
                      <route xmlns="http://camel.apache.org/schema/spring">
                          <log message="Input: ${body}" />
                          <choice>
                              <when>
                                  <simple>${body} == null</simple>
                                  <log message="Retrieve" />
                                  <to uri="switchyard://GreetingsDatabaseRetrieve"/>
                              </when>
                              <otherwise>
                                  <log message="Store" />
                                  <to uri="switchyard://GreetingsDatabaseStore"/>
                              </otherwise>
                          </choice>
                          <log message="Output: ${body}" />
                      </route>
                  </camel:implementation.camel>
      
                  <reference name="GreetingsDatabaseStore">
                      <swyd:interface.esb inputType="java:java.lang.String" remotable="false" />
                  </reference>
                  <reference name="GreetingsDatabaseRetrieve">
                      <swyd:interface.esb inputType="java:java.lang.String" outputType="java:java.util.List" remotable="false" />
                  </reference>
              </component>
      
              <reference name="GreetingsDatabaseStore" multiplicity="0..1" promote="GreetingsDatabaseStore">
                  <swyd:interface.esb inputType="java:java.lang.String" remotable="false" />
                  <camel:binding.sql>
                      <camel:operationSelector operationName="store" />
                      <camel:query>INSERT INTO greetings (name) VALUES (#)</camel:query>
                      <camel:dataSourceRef>java:jboss/datasources/GreetDS</camel:dataSourceRef>
                  </camel:binding.sql>
              </reference>
      
              <reference name="GreetingsDatabaseRetrieve" multiplicity="0..1" promote="GreetingsDatabaseRetrieve">
                  <swyd:interface.esb inputType="java:java.lang.String" outputType="java:java.util.List" remotable="false" />
                  <camel:binding.sql>
                      <camel:operationSelector operationName="retrieve" />
                      <camel:query>SELECT * FROM greetings</camel:query>
                      <camel:dataSourceRef>java:jboss/datasources/GreetDS</camel:dataSourceRef>
                  </camel:binding.sql>
              </reference>
          </composite>
      
      

       

      When I change interface.esb to interface.java - it's still the same. From logical point of view it's one reference (database) with different queries to execute. Rob pointed to org.switchyard.deploy.internal.Deployment.deployReferenceBindings which do not touch selectors.Now the question is - should it support selectors or shouldn't? Rob and David pointed to fact that operation selectors are used for inbound communication with services, and never thought about usage of them with references.