3 Replies Latest reply on Dec 1, 2009 8:43 PM by Marcel Casado

    Using Camel to route external x internal endpoints

    Roger Cracel Newbie

      I have setup a simple project where I have a CXF endpoint configured in an OSGi bundle as such:

       

           <jaxws:endpoint id="myEndpoint"
                implementor="org.apache.servicemix.samples.wsdl_first.PersonImpl" 
                address="nmr:personService1" />
      

       

      now, my understanding is that this published the aforementioned endpoint on the NMR, and as such it can be accessed by other 'bundles' deployed withing the ESB. To test this, I created another bundle (also OSGi) and configured an external endpoint as such:

       

          <cxf:cxfEndpoint
               id="commentingServiceRouter"
               address="http://localhost:9003/CamelContext/RouterPort"
               serviceClass="org.apache.servicemix.samples.wsdl_first.Person">
               <cxf:properties>
                    <entry key="dataFormat" value="PAYLOAD"></entry>
               </cxf:properties>
          </cxf:cxfEndpoint>
      

       

      and finally setup my camel context as such:

       

           <osgi:camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
                <route>
                     <from uri="cxf:bean:commentingServiceRouter"></from>
                     <bean ref="myTransform" method="transform"></bean>
                     <to uri="nmr:personService1"></to>
                </route>
           </osgi:camelContext>
      

       

      just a side note, myTransform is nothing more than logging the communication between the two endpoints and, as I understand, should have no impact on the communication itself as long as I returned the object received intact. Is this a correct assumption?

       

          public Object transform(Object body) throws Exception {
              LineNumberReader sr = new LineNumberReader(new InputStreamReader((InputStream)body));
              String line = sr.readLine();
              while (line != null) {
                  LOG.info(line);
                  line = sr.readLine();
              }
              return body;
          }
      

       

      now, when I try to run this example, I get the following exception:

       

      16:04:56,655 | WARN  | 63432014@qtp14-0 | ManagementEndpointRegistry       | ement.ManagementEndpointRegistry   99 | No managed endpoint registered with id: 74bca7e8-60ba-4125-abda-b8a11b41bd47
      16:04:56,656 | ERROR | ervice1-thread-3 | NMRDestination                   | nmr.core.InternalEndpointWrapper   86 | error preparing message
      javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: Source object passed to ''{0}'' has no contents.
           at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:756)
           at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:349)
           at org.apache.servicemix.cxf.transport.nmr.NMRMessageHelper.convertMessageToInputStream(NMRMessageHelper.java:51)
           at org.apache.servicemix.cxf.transport.nmr.NMRDestination.process(NMRDestination.java:113)
           at org.apache.servicemix.nmr.core.InternalEndpointWrapper.process(InternalEndpointWrapper.java:86)
           at org.apache.servicemix.nmr.core.ChannelImpl.process(ChannelImpl.java:255)
           at org.apache.servicemix.nmr.core.ChannelImpl$1.run(ChannelImpl.java:215)
           at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
           at java.lang.Thread.run(Thread.java:637)
      Caused by: javax.xml.transform.TransformerException: Source object passed to ''{0}'' has no contents.
           at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:704)
           at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:744)
           ... 9 more
      16:04:56,657 | WARN  | ervice1-thread-3 | NMR                              | .servicemix.nmr.core.ChannelImpl  293 | Error processing exchange [
        id:        1c02f19a-1605-4d85-8972-0790b5f07ca2
        mep:       InOut
        status:    Active
        role:      Provider
        target:    PropertyMatchingReference[{NAME=personService1}]
        In: [
          content: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://servicemix.apache.org/samples/wsdl-first/types">
         <soapenv:Header></soapenv:Header>
         <soapenv:Body>
            <typ:GetPerson>
               <typ:personId>33</typ:personId>
            </typ:GetPerson>
         </soapenv:Body>
      </soapenv:Envelope>
          properties: [
            operationName = <null>
          ]
        ]
      ]
      

       

      additionally, I also noticed a couple of warnings during deployment of my bundle:

       

      16:04:52,625 | WARN  | tenderThread-106 | SpringCamelContext               | .camel.spring.SpringCamelContext  127 | No spring-event endpoint enabled for: org.springframework.osgi.service.importer.event.OsgiServiceDependencyWaitStartingEvent[source=org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean@14eb033f]
      16:04:52,626 | WARN  | tenderThread-106 | SpringCamelContext               | .camel.spring.SpringCamelContext  127 | No spring-event endpoint enabled for: org.springframework.osgi.service.importer.event.OsgiServiceDependencyWaitEndedEvent[source=org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean@14eb033f]
      

       

      any ideas on what I am doing wrong?

       

      thank you

        • 1. Re: Using Camel to route external x internal endpoints
          Claus Ibsen Master

          Try without the transform/logger as you use PAYLOAD which I assume is stream based and thus not by default possible to read multiple times.

          • 2. Re: Using Camel to route external x internal endpoints
            Roger Cracel Newbie

            Thank you for your response, however removing the logger had no effect. I have a feeling there must be a mistake in the way I register the endpoint, which the following message seem to indicate:

             

            07:48:15,517 | WARN  | 10603633@qtp16-0 | ManagementEndpointRegistry       | ement.ManagementEndpointRegistry   99 | No managed endpoint registered with id: c231f925-ec6e-4d6d-ad64-27615b9d278e
            
            07:48:15,518 | ERROR | ervice1-thread-5 | NMRDestination                   | nmr.core.InternalEndpointWrapper   86 | error preparing message
            javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: Source object passed to ''{0}'' has no contents.
                 at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:756)
                 at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:349)
                 at org.apache.servicemix.cxf.transport.nmr.NMRMessageHelper.convertMessageToInputStream(NMRMessageHelper.java:51)
                 at org.apache.servicemix.cxf.transport.nmr.NMRDestination.process(NMRDestination.java:113)
                 at org.apache.servicemix.nmr.core.InternalEndpointWrapper.process(InternalEndpointWrapper.java:86)
                 at org.apache.servicemix.nmr.core.ChannelImpl.process(ChannelImpl.java:255)
                 at org.apache.servicemix.nmr.core.ChannelImpl$1.run(ChannelImpl.java:215)
                 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
                 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
                 at java.lang.Thread.run(Thread.java:637)
            Caused by: javax.xml.transform.TransformerException: Source object passed to ''{0}'' has no contents.
                 at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:704)
                 at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:744)
                 ... 9 more
            07:48:15,520 | WARN  | ervice1-thread-5 | NMR                              | .servicemix.nmr.core.ChannelImpl  293 | Error processing exchange [
              id:        540d569b-eca1-4da7-9804-11254e127e3a
              mep:       InOut
              status:    Active
              role:      Provider
              target:    PropertyMatchingReference[{NAME=personService1}]
              In: [
                content: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://servicemix.apache.org/samples/wsdl-first/types">
               <soapenv:Header></soapenv:Header>
               <soapenv:Body>
                  <typ:GetPerson>
                     <typ:personId>33</typ:personId>
                  </typ:GetPerson>
               </soapenv:Body>
            </soapenv:Envelope>
                properties: [
                  operationName = <null>
                ]
              ]
            ]
            
            

             

            • 3. Re: Using Camel to route external x internal endpoints
              Marcel Casado Novice

              Probably you already figure out this one but maybe can help somebody else. Try adding   on your camel route.