【问题标题】:Camel K: How can i define a datasource, which can be used in the Camel K JDBC Component or the Camel K SQL Component?Camel K:我如何定义可以在 Camel K JDBC 组件或 Camel K SQL 组件中使用的数据源?
【发布时间】:2020-06-13 21:44:34
【问题描述】:

我目前正在德国开展一个项目,该项目已经在 Karaf 中使用 Camel。我想使用 Camel K 在 Kubernetes 集群内部署一个用 Blueprint XML 编写的示例 Camel 路由。在 Karaf 中定义和创建数据源很简单。在卡拉夫 CLI 只需执行:

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

然后在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>

我已经在文档和 Web 上搜索了 Camel K 和 Kubernetes 数据源,但没有找到解决方案。有人知道如何在 Kubernetes 中使用 Camel K 创建 JDBC 组件 URI 中使用的数据源吗?

【问题讨论】:

  • 我认为这是不可能的。我认为 apache camel 期望数据源已经存在。

标签: sql kubernetes apache-camel datasource


【解决方案1】:

您好,欢迎来到 StackOverflow

您基本上会问如何在 Camel K 的 Camel 上下文中定义自定义 bean。数据源定义等在 Camel 上下文中被定义为 bean。

有关类似问题和示例答案,请参阅 this link

【讨论】:

    猜你喜欢
    • 2021-12-04
    • 2021-11-27
    • 1970-01-01
    • 2020-05-03
    • 1970-01-01
    • 2022-09-23
    • 2021-01-21
    • 2020-11-02
    • 1970-01-01
    相关资源
    最近更新 更多