Hmm...not sure it will work like that.  The HTTPComponent is an inout binding, and invokes and returns the next service in the chain.  Since you are wanting to go one component past this chain, it will never reach it.

But what you are looking for is logical IMO.  It would be cool to have some orchestrator that can execute and capture an entire flow.  For instance

  <component ...>
    <service name="foo"/>
    <service name="bar"/>
    <service name="baz"/>
  </component>

So in this case, you can specify that the message from the parent component will be routed though each of the nested services in order, and returned.  Is there anything built in that can perform that type of functionality?

Seems like it would be fairly straight forward to write a component to do this, but not sure if it violates any of the core JBI concepts.

Thoughts?

Birch

On 10/27/05, Angel Gomez <[EMAIL PROTECTED] > wrote:

    OK. Lets see.

    I made this config file:

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

  <!-- the JBI container -->
  <container id="jbi">
    <property name="rootDir" value="../wdir"/>
    <property name="createMBeanServer" value="true"/>
    <property name="installationDirPath" value="../install"/>
    <property name="monitorInstallationDirectory" value="true"/>
    <property name="dumpStats" value="true"/>
    <property name="statsInterval" value="10"/>
    <property name="transactionManager" ref="transactionManager"/>

    <components>

      <!-- Create a http server binding on port 8912 -->
      <component id="httpReceiver1" service="foo:httpBinding1"
endpoint="httpReceiver"
class="org.servicemix.components.http.HttpConnector"
      destinationService="foo:xsqlGroovy">
        <property name="host" value="localhost"/>
        <property name="port" value="8912"/>
      </component>

      <component id="httpReceiver2" service="foo:httpBinding2"
endpoint="httpReceiver"
class="org.servicemix.components.http.HttpConnector"
      destinationService="foo:xsql">
        <property name="host" value="localhost"/>
        <property name="port" value="8913"/>
      </component>

      <!-- XSQL configuration -->
      <component id="xsql" service="foo:xsql"
class="org.servicemix.components.xsql.XSQLComponent" >
        <property name="connectionManagerFactory">
          <bean
class="org.servicemix.components.xsql.DataSourceXSQLConnectionManagerFactory ">
            <property name="dataSource" ref="mysql-prueba"/>
          </bean>
        </property>
      </component>

    <!-- JB Groovy component -->
      <component id="xsqlGroovy" service="foo:xsqlGroovy"
class="org.servicemix.components.groovy.GroovyComponent"
      destinationService="foo:xsql" >
      <property name="scriptText">
        <value>
          <![CDATA[

outMessage.bodyText="""
<xsql:query xmlns:xsql="urn:oracle-xsql" connection="demomysql">
  SELECT * FROM tabla WHERE id = ${ inMessage.properties.id}
</xsql:query>
"""

        ]]>
        </value>
      </property>
    </component>

    </components>
  </container>

  <!-- Transaction manager -->
  <bean id="transactionManager"
class="org.springframework.transaction.jta.JotmFactoryBean"/>

  <!-- XSQL Datasource -->
  <bean id="mysql-prueba"
    class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
    <property name="user">
      <value>usuario</value>
    </property>
    <property name="password">
      <value></value>
    </property>
    <property name="serverName">
      <value>localhost</value>
    </property>
    <property name="databaseName">
      <value>prueba</value>
    </property>
  </bean>

</beans>

And this client program :

import java.io.*;
import java.net.URL;
import java.net.URLConnection;

public class testXsqlHttp {

    public static void main(String[] args) throws Exception {
        URLConnection connection = new
URL("http://localhost:"+args[0]).openConnection();
        connection.setDoOutput(true);
        connection.setRequestProperty("id","1");
        OutputStream os = connection.getOutputStream();
        String xsqlQuery = args[1];

        os.write(xsqlQuery.getBytes());
        os.close();

        // Read the response.
        BufferedReader in = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null) {
            System.out.println(inputLine);
        }
        in.close();

    }
}

    If i invoke the java app with this parameters ( 8913 "<xsql:query
xmlns:xsql='urn:oracle-xsql' connection='demomysql'> SELECT * FROM tabla
</xsql:query>" ) I do get the output of the query, but when I invoke the
java app with this parameters ( 8912 " " ) I only get the query itself

<?xml version="1.0" encoding="UTF-8"?><xsql:query
xmlns:xsql="urn:oracle-xsql" connection="demomysql">
  SELECT * FROM tabla WHERE id = 1
</xsql:query>

    If destinationService in xsqlGroovy is set to foo:xsql, shouldn't it
route this to the xsql service and return the output of the query ? Is
there something missing to achieve that ?

    Thank's

J B wrote:

> Not exactly sure how you are using the component, but the following
> groovy component spit out what you wanted.
>
> <component id="myServiceUsingXMLText"
>         service="my:groovyXSQLBuilder"
>         class="org.servicemix.components.groovy.GroovyComponent"
> destinationService="my:trace" destinationService="my:xsqlService">
>         <property name="scriptText">
>         <value>
>             <![CDATA[
> outMessage.bodyText = """
> <xsql:query connection="demo" bind-params="City"
> xmlns:xsql="urn:oracle-xsql">
>
>    SELECT Carrier, FlightNumber, Origin,
> TO_CHAR(ExpectedTime,'HH24:MI') Due
>      FROM FlightSchedule
>     WHERE TRUNC(ArrivalTime) = TRUNC(SYSDATE)
>     AND Destination = *${inMessage.properties.destinationName}*
>  ORDER BY ExpectedTime
>
> </xsql:query>
> """
>             ]]>
>           </value>
>         </property>
>       </component>
>
> As long as destinationName is bound to the inMessage, you should
> good.  Don't set the XSQL url in the XSQL component, and it will take
> the XML message genrated by this component as the document.  Mind you,
> I have not tested it as I do not have a DB to go against at the
> moment, but the XML is created correctly (I think).
>
> Hope it helps.
>
> Birch
>
> On 10/27/05, *J B* <[EMAIL PROTECTED] <mailto: [EMAIL PROTECTED]>> wrote:
>
>     Looking at the source, it does not appear to allow variable
>     substitution.  Seems like it wouldn't be that hard to support.
>     But as for a working solution right now, you could have a
>     component generate the XSQL document on the fly with parameters
>     passed in to it, then forward that document to the XSQL
>     component.  If you do not set the XSQL document in the
>     configuration of the XSQL component, then it will attempt to
>     create one out of the message passed to it.  A groovy component
>     could easily use the xmlbuilder to generate the document
>
>     Hope that helps.
>
>     Birch
>
>
>     On 10/27/05, *Angel Gomez* < [EMAIL PROTECTED]
>     <mailto: [EMAIL PROTECTED]>> wrote:
>
>
>             Hello.
>
>             Is it possible to pass parameters in the call to a XSQL
>         component
>         like in the Oracle documentation, with the xsql page specified
>         in the
>         configuration file?
>
>         <?xml version="1.0 "?>
>         <xsql:query connection="demo" *bind-params="City"*
>         xmlns:xsql="urn:oracle-xsql">
>
>             SELECT Carrier, FlightNumber, Origin,
>         TO_CHAR(ExpectedTime,'HH24:MI') Due
>               FROM FlightSchedule
>              WHERE TRUNC(ArrivalTime) = TRUNC(SYSDATE)
>                AND Destination = *?*
>           ORDER BY ExpectedTime
>
>         </xsql:query>
>
>             Regards.
>
>
>

Reply via email to