Hi,
If you're using smx4.x, ensure you already install camel-ibatis feature
like
features:install camel-ibatis
Freeman
On 2011-3-23, at 下午7:37, Charles Moulliard wrote:
Have you deployed the bundle camel-ibatis component on Smx4.x or
Karaf ?
On Wed, Mar 23, 2011 at 12:13 PM, Michael Dewitte
<[email protected]> wrote:
Thx,
thanks to your indications and the sample here :
I tried to go further.
I made a bundle, using blueprint, in which I placed my blueprint
and the
config files for ibatis. When I try to deploy it, I get an
exception :
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to
create
route route6 at: >>> To[ibatis:deleteUser?statementType=Delete] <<<
in
route: Route[[From[file:activemq/input]] -> [To[file:activemq/
outpu...
because of Failed to resolve endpoint:
ibatis://deleteUser?statementType=Delete due to:
org.osgi.service.blueprint.container.NoSuchComponentException: No
component
with id 'ibatis://deleteUser?statementType=Delete' could be found
The structure of the jar is as follow :
|-SqlMapConfig.xml
|-Users.xml (the maps definitions)
|-OSGI-INF
|-blueprint
|-blueprint.xml
|-META-INF
|MANIFEST.MF
Here is my SqlMapConfig.xml :
-----------------------------------------------
<sqlMapConfig>
<transactionManager type="JDBC" commitRequired="false">
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="com.mysql.jdbc.Driver"/>
<property name="JDBC.ConnectionURL"
value="jdbc:mysql://localhost:3306/forem_1"/>
<property name="JDBC.Username" value="root"/>
<property name="JDBC.Password" value="mysql"/>
</dataSource>
</transactionManager>
<sqlMap resource="User.xml"/>
</sqlMapConfig>
Here is my Users.xml :
----------------------------------------------
<sqlMap>
<delete id="deleteUser">
delete from transfert_outbound where correlationId = 2
</delete>
</sqlMap>
Here is my blueprint.xml :
----------------------------------------------
<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route>
<from uri="file:activemq/input"/>
<to uri="file:activemq/output"/>
<setBody>
<simple>
NEW FileMovedEvent(file: ${file:name}, timestamp:
${date:now:hh:MM:ss.SSS})
</simple>
</setBody>
<to uri="log:events"/>
<to uri="ibatis:deleteUser?statementType=Delete"/>
</route>
</camelContext>
</blueprint>
and here is my pom.xml
------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd
">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.servicemix.features</groupId>
<artifactId>features</artifactId>
<version>4.3.0</version>
</parent>
<groupId>testing.servicemix.example</groupId>
<artifactId>ibatistest</artifactId>
<packaging>bundle</packaging>
<version>1.0-SNAPSHOT</version>
<name>iBatis test</name>
<properties>
<!-- Camel -->
<camel-version>2.6.0</camel-version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>${camel-version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
<version>${camel-version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-ibatis</artifactId>
<version>${camel-version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
<Import-Package>*,org.apache.camel.osgi</Import-Package>
<Private-Package>org.apache.servicemix.examples.camel</Private-
Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
Any clue ???
Thx in advance,
Mike
2011/3/22 Charles Moulliard <[email protected]>
Hi Michael,
Yeap, you must create a bundle containing your camel route, myibatis
config files and place them in a folder which is in the classpath of
the bundle.
Regards,
Charles
On Tue, Mar 22, 2011 at 3:25 PM, Michael Dewitte
<[email protected]> wrote:
Thanks Charles,
but as it's deployed into karaf, does it means I have to create
an osgi
bundle, with the sqlmap in it (and the xml def of my CamelContext
too ?)
?
This particular part is not clear to me, and if i find info on
the ibatis
/
mybatis part, i can't find this precise detail on how to
package / deploy
it
to servicemix... Until now, I only had to deploy the CamelContext
using
blueprint directly via the deploy folder...
Thanks for your help,
Mike
2011/3/22 Charles Moulliard <[email protected]>
Hi Mike,
According to the doc,
This component will by default load the MyBatis SqlMapConfig
file from
the root of the classpath and expected named as SqlMapConfig.xml.
If the file is located in another location, you would have to
configure the configurationUri option on the MyBatisComponent
component.
Regards,
Charles Moulliard
Sr. Principal Solution Architect - FuseSource
Apache Committer
Blog : http://cmoulliard.blogspot.com
Twitter : http://twitter.com/cmoulliard
Linkedin : http://www.linkedin.com/in/charlesmoulliard
Skype: cmoulliard
On Tue, Mar 22, 2011 at 2:25 PM, Michael Dewitte
<[email protected]> wrote:
Hi,
one question that seems to be borderline betwwen Camel and SMX :
I want to raise some events (posting messages on a queue) based
on
events
occured on table in a database. So, in fact, I want to react
upon
insert
in
a table. To do so, I thought about a route, using a timer then a
MyBatis
then posting to a queue.
the route could look like this :
<camelContext xmlns="http://camel.apache.org/schema/
blueprint">
<route>
<from uri="timer://pollTheDatabase?delay=30000"/>
<to
uri="mbatis:selectAllNewlyInsertedPeople?
statementType=QueryForList"/>
<to uri="activemq://events" />
</route>
</camelContext>
I haven't found config sample using SpringConfig nor
blueprints.... My
question is : where do I define the SQLmap... normally it
should be
defined
in another xml file, if I was building the route in java... but
how do
if
I
want to use a route configured with blueprint ?
Or maybe am I wrong and should I use a totally different way ?
Thanks for any help,
Mike
--
Freeman Fang
------------------------
FuseSource: http://fusesource.com
blog: http://freemanfang.blogspot.com
twitter: http://twitter.com/freemanfang
Apache Servicemix:http://servicemix.apache.org
Apache Cxf: http://cxf.apache.org
Apache Karaf: http://karaf.apache.org
Apache Felix: http://felix.apache.org