You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by dellekappa <gi...@codin.it> on 2007/08/23 17:30:23 UTC

servicemix-camel - Java based routing

Hi everybody,
I had correctly configured servicemix-camel component inside servicemix, and
I had created a new servicemix-camel-serviceunit as well, based on the
corrensonding archetype.
The problem is that if I configure my routes inside camel-context.xml it
works fine, but if I try java based routing...nothing happens. It seems that
my RouteBuilder class won't be read.
I put my RouteBuilder class inside a package named codin.sismed:

-------------------------------
package codin.sismed;

import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.spring.Main;

public class SismedRouter extends RouteBuilder {
	
	public static void main(String[] args) {
        new Main().run(args);
    }
	
    public void configure() {
    	System.out.println("Configuring routes");
    
from("jbi:service:http://sismed/services/Anagrafica/AnagraficaJBI").to("jbi:service:http://sismed/services/Anagrafica/Anagrafica_bb1");
        System.out.println("Routes configured");
    }
}
-----------------------------

and this is how appear my camel-context.xml

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

<!-- START SNIPPET: camel -->
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
	http://www.springframework.org/schema/beans/spring-beans.xsd
	http://activemq.apache.org/camel/schema/spring
	http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
  
  <camelContext id="camel"
xmlns="http://activemq.apache.org/camel/schema/spring">
  	<package>codin.sismed</package>
  </camelContext>

</beans>
<!-- END SNIPPET: camel -->

---------------------------

the service-unit and the service-assembly compiles and deployes well...but
no routes are created.
Any suggestion?

Thanks a lot
-- 
View this message in context: http://www.nabble.com/servicemix-camel---Java-based-routing-tf4318255s12049.html#a12295959
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: servicemix-camel - Java based routing

Posted by James Strachan <ja...@gmail.com>.
Apologies that this didn't work. Its all my fault! I'd messed up the
classloader code in the CamelSpringDeployer - humble appologies.

Using trunk of Camel and ServiceMix this should all be working now. As
I just commented in this thread...
http://www.nabble.com/Camel-Component-tf4389182s12049.html

I've just committed a simple Camel sample to ServiceMix...
https://svn.apache.org/repos/asf/incubator/servicemix/trunk/samples/camel/

which shows how to create a Service Unit and Service Assembly using
Camel routing. You can then run it (assuming you've locally built
Camel and ServiceMix) via

cd samples/camel
mvn install
cd camel-sa
mvn jbi:servicemix

Or deploy the SA in ServiceMix

Note that this currently depends on trunk of both Camel and ServiceMix
as I've fixed a few glitches in servicemix-camel; so you'll need to
grab the latest source and build that locally first (or tomorrow the
latest snapshot will download for you)

This sample shows you can deploy any Camel routes into ServiceMix as
an SU/SA; these could use regular Camel endpoints or NMR endpoints
within JBI (the JBI endpoints are just named "jbi:...")
http://activemq.apache.org/camel/jbi.html


On 8/23/07, dellekappa <gi...@codin.it> wrote:
> Hi everybody,
> I had correctly configured servicemix-camel component inside servicemix, and
> I had created a new servicemix-camel-serviceunit as well, based on the
> corrensonding archetype.
> The problem is that if I configure my routes inside camel-context.xml it
> works fine, but if I try java based routing...nothing happens. It seems that
> my RouteBuilder class won't be read.
> I put my RouteBuilder class inside a package named codin.sismed:
>
> -------------------------------
> package codin.sismed;
>
> import org.apache.camel.Exchange;
> import org.apache.camel.Processor;
> import org.apache.camel.builder.RouteBuilder;
> import org.apache.camel.spring.Main;
>
> public class SismedRouter extends RouteBuilder {
>
>         public static void main(String[] args) {
>         new Main().run(args);
>     }
>
>     public void configure() {
>         System.out.println("Configuring routes");
>
> from("jbi:service:http://sismed/services/Anagrafica/AnagraficaJBI").to("jbi:service:http://sismed/services/Anagrafica/Anagrafica_bb1");
>         System.out.println("Routes configured");
>     }
> }
> -----------------------------
>
> and this is how appear my camel-context.xml
>
> -----------------------------
> <?xml version="1.0" encoding="UTF-8"?>
>
> <!-- START SNIPPET: camel -->
> <beans xmlns="http://www.springframework.org/schema/beans"
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        xsi:schemaLocation="http://www.springframework.org/schema/beans
>         http://www.springframework.org/schema/beans/spring-beans.xsd
>         http://activemq.apache.org/camel/schema/spring
>         http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
>
>   <camelContext id="camel"
> xmlns="http://activemq.apache.org/camel/schema/spring">
>         <package>codin.sismed</package>
>   </camelContext>
>
> </beans>
> <!-- END SNIPPET: camel -->
>
> ---------------------------
>
> the service-unit and the service-assembly compiles and deployes well...but
> no routes are created.
> Any suggestion?
>
> Thanks a lot
> --
> View this message in context: http://www.nabble.com/servicemix-camel---Java-based-routing-tf4318255s12049.html#a12295959
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>


-- 
James
-------
http://macstrac.blogspot.com/

Re: servicemix-camel - Java based routing

Posted by dellekappa <gi...@codin.it>.
Hi James,
thanks for your reply.
I thought my RouteBuilder class should be inside the src/main/java folder of
the servicemix-camel-serviceunit project, as the archetype suggests. Anyway
I tried to do as you suggest, I created a new maven project for my
RouteBuilder class and put my SismedRouter class into it. It compiles and
installs well, I can see the jar inside the local maven repository. Then I
added the dependency on the pom.xml of the servicemix-camel-serviceunit
project to this jar. Compiled and installed the serviceunit, and I can see,
inside the lib folder of generated installer zip, the jar included. Compiled
and installed the service-assembly as well, and deployed too, but I get the
same result.
It seems that camel cannot find my class or doesn't search for it.
I post serviceunit pom.xml:

<?xml version="1.0" encoding="UTF-8"?><project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>codin.sismed</groupId>
  <artifactId>camel-routes-su</artifactId>
  <packaging>jbi-service-unit</packaging>
  <name>Sismed servicemix-camel serviceunit</name>
  <version>1.0-SNAPSHOT</version>
  <url>http://www.myorganization.org</url>
  <build>
    <defaultGoal>install</defaultGoal>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.servicemix.tooling</groupId>
        <artifactId>jbi-maven-plugin</artifactId>
        <version>${servicemix-version}</version>
        <extensions>true</extensions>
      </plugin>
      <plugin>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-maven-plugin</artifactId>
        <version>${camel-version}</version>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
      <groupId>org.apache.servicemix</groupId>
      <artifactId>servicemix-camel</artifactId>
      <version>${servicemix-version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.servicemix</groupId>
      <artifactId>servicemix-core</artifactId>
      <version>${servicemix-version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>codin.sismed</groupId>
      <artifactId>sismed-camel-routing</artifactId>
      <version>0.0.1</version>
    </dependency>
  </dependencies>
  <properties>
    <servicemix-version>3.2-incubating-SNAPSHOT</servicemix-version>
    <camel-version>1.1.0</camel-version>
  </properties>
</project>

Any other suggestions...thanks for your help


James.Strachan wrote:
> 
> On 8/23/07, dellekappa <gi...@codin.it> wrote:
>>
>> Hi everybody,
>> I had correctly configured servicemix-camel component inside servicemix,
>> and
>> I had created a new servicemix-camel-serviceunit as well, based on the
>> corrensonding archetype.
>> The problem is that if I configure my routes inside camel-context.xml it
>> works fine, but if I try java based routing...nothing happens. It seems
>> that
>> my RouteBuilder class won't be read.
>> I put my RouteBuilder class inside a package named codin.sismed:
>>
>> -------------------------------
>> package codin.sismed;
>>
>> import org.apache.camel.Exchange;
>> import org.apache.camel.Processor;
>> import org.apache.camel.builder.RouteBuilder;
>> import org.apache.camel.spring.Main;
>>
>> public class SismedRouter extends RouteBuilder {
>>
>>         public static void main(String[] args) {
>>         new Main().run(args);
>>     }
>>
>>     public void configure() {
>>         System.out.println("Configuring routes");
>>
>> from("jbi:service:http://sismed/services/Anagrafica/AnagraficaJBI").to("jbi:service:http://sismed/services/Anagrafica/Anagrafica_bb1");
>>         System.out.println("Routes configured");
>>     }
>> }
>> -----------------------------
>>
>> and this is how appear my camel-context.xml
>>
>> -----------------------------
>> <?xml version="1.0" encoding="UTF-8"?>
>>
>> <!-- START SNIPPET: camel -->
>> <beans xmlns="http://www.springframework.org/schema/beans"
>>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>        xsi:schemaLocation="http://www.springframework.org/schema/beans
>>         http://www.springframework.org/schema/beans/spring-beans.xsd
>>         http://activemq.apache.org/camel/schema/spring
>>         http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
>>
>>   <camelContext id="camel"
>> xmlns="http://activemq.apache.org/camel/schema/spring">
>>         <package>codin.sismed</package>
>>   </camelContext>
>>
>> </beans>
>> <!-- END SNIPPET: camel -->
>>
>> ---------------------------
>>
>> the service-unit and the service-assembly compiles and deployes
>> well...but
>> no routes are created.
>> Any suggestion?
> 
> Hmm - it should work. Are you sure your class is inside a jar on the
> claspath? e.g. your jar is in the pom.xml of the camel-service-unit's
> pom.xml so its added to the dependency list & classloader?
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/servicemix-camel---Java-based-routing-tf4318255s12049.html#a12309519
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: servicemix-camel - Java based routing

Posted by James Strachan <ja...@gmail.com>.
On 8/23/07, dellekappa <gi...@codin.it> wrote:
>
> Hi everybody,
> I had correctly configured servicemix-camel component inside servicemix, and
> I had created a new servicemix-camel-serviceunit as well, based on the
> corrensonding archetype.
> The problem is that if I configure my routes inside camel-context.xml it
> works fine, but if I try java based routing...nothing happens. It seems that
> my RouteBuilder class won't be read.
> I put my RouteBuilder class inside a package named codin.sismed:
>
> -------------------------------
> package codin.sismed;
>
> import org.apache.camel.Exchange;
> import org.apache.camel.Processor;
> import org.apache.camel.builder.RouteBuilder;
> import org.apache.camel.spring.Main;
>
> public class SismedRouter extends RouteBuilder {
>
>         public static void main(String[] args) {
>         new Main().run(args);
>     }
>
>     public void configure() {
>         System.out.println("Configuring routes");
>
> from("jbi:service:http://sismed/services/Anagrafica/AnagraficaJBI").to("jbi:service:http://sismed/services/Anagrafica/Anagrafica_bb1");
>         System.out.println("Routes configured");
>     }
> }
> -----------------------------
>
> and this is how appear my camel-context.xml
>
> -----------------------------
> <?xml version="1.0" encoding="UTF-8"?>
>
> <!-- START SNIPPET: camel -->
> <beans xmlns="http://www.springframework.org/schema/beans"
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        xsi:schemaLocation="http://www.springframework.org/schema/beans
>         http://www.springframework.org/schema/beans/spring-beans.xsd
>         http://activemq.apache.org/camel/schema/spring
>         http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
>
>   <camelContext id="camel"
> xmlns="http://activemq.apache.org/camel/schema/spring">
>         <package>codin.sismed</package>
>   </camelContext>
>
> </beans>
> <!-- END SNIPPET: camel -->
>
> ---------------------------
>
> the service-unit and the service-assembly compiles and deployes well...but
> no routes are created.
> Any suggestion?

Hmm - it should work. Are you sure your class is inside a jar on the
claspath? e.g. your jar is in the pom.xml of the camel-service-unit's
pom.xml so its added to the dependency list & classloader?

-- 
James
-------
http://macstrac.blogspot.com/