Murat Yildiz
Murat Yildiz

Reputation: 1

Camel K: How can i define a datasource, which can be used in the Camel K JDBC Component or the Camel K SQL Component?

I'm currently working on a project in Germany, which is already using Camel inside Karaf. And i would like to deploy an sample Camel route written in Blueprint XML inside a Kubernetes cluster using Camel K. Defining and creating the datasource was simple in Karaf. On Karaf CLI just execute:

karaf@root()> jdbc:ds-create -t derby -u test -i datasource01

And then deploy below XML

<?xml version="1.0" encoding="UTF-8"?>
<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">

    <bean id="datasource01" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver"/>
        <property name="url" value="jdbc:derby:database01" />
    </bean>

    <bean id="datasource02" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver"/>
        <property name="url" value="jdbc:derby:database02" />
    </bean>

    <camelContext xmlns="http://camel.apache.org/schema/blueprint">
        <route>
            <...>
            <to uri="jdbc:datasource01"/>
            <...>
            <to uri="jdbc:datasource02"/>
            <...>
        </route>
    </camelContext>
</blueprint>

I have searched the documentations and web for Camel K and Kubernetes datasources and haven't found the solution. Does anybody know how the datasource which is used in the JDBC Componenent URI can be created using Camel K inside Kubernetes ?

Upvotes: 0

Views: 964

Answers (1)

burki
burki

Reputation: 7005

Hi and welcome to StackOverflow

You basically ask how to define custom beans inside the Camel context in Camel K. Datasource definitions etc are defined as beans in the Camel context.

See this link for a similar question and an example answer.

Upvotes: 1

Related Questions