在 Apache karaf 上捆绑使用 Apache camel
Using Apache camel in bundles on Apache karaf
我正在尝试将一些文件的内容写入 Apache karaf 的日志文件(仅用于一些测试)。为此,我对 Camel 使用了以下路线:
from("file:C:/input?noop=true").process(new LogProcessor()).to(
"stream:out");
LogProcessor 现在什么都不做,我的 pom.xml 看起来像这样(用 maven 构建它):
<?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/xsd/maven-4.0.0.xsd">
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<modelVersion>4.0.0</modelVersion>
<groupId>osgi</groupId>
<artifactId>osgi</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>osgi Bundle</name>
<description>osgi OSGi bundle project.</description>
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>2.14.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-stream</artifactId>
<version>2.14.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>osgi</Bundle-SymbolicName>
<Bundle-Version>1.0-SNAPSHOT</Bundle-Version>
<Bundle-Activator>osgi.Activator</Bundle-Activator>
<Export-Package>
osgi*;version=1.0-SNAPSHOT
</Export-Package>
<Import-Package>
*
</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
我也执行了
features:install camel-stream
在 karaf 上,当然 camel 本身也安装在 karaf 上。
但我还是明白了
[...]No component found with scheme: stream[...]
karaf 出错。
已经浏览了很多论坛和资料,但找不到任何解决方案...感谢任何帮助!
这是一种预感,但我猜您已经在 Bundle Activator 中创建了 DefaultCamelContext。然后 Stream Component 不会加载到该上下文中,除非你自己这样做:
StreamComponent stream = new StreamComponent();
camelContext.addComponent("stream", stream);
我正在尝试将一些文件的内容写入 Apache karaf 的日志文件(仅用于一些测试)。为此,我对 Camel 使用了以下路线:
from("file:C:/input?noop=true").process(new LogProcessor()).to(
"stream:out");
LogProcessor 现在什么都不做,我的 pom.xml 看起来像这样(用 maven 构建它):
<?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/xsd/maven-4.0.0.xsd">
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<modelVersion>4.0.0</modelVersion>
<groupId>osgi</groupId>
<artifactId>osgi</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>osgi Bundle</name>
<description>osgi OSGi bundle project.</description>
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>2.14.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-stream</artifactId>
<version>2.14.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>osgi</Bundle-SymbolicName>
<Bundle-Version>1.0-SNAPSHOT</Bundle-Version>
<Bundle-Activator>osgi.Activator</Bundle-Activator>
<Export-Package>
osgi*;version=1.0-SNAPSHOT
</Export-Package>
<Import-Package>
*
</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
我也执行了
features:install camel-stream
在 karaf 上,当然 camel 本身也安装在 karaf 上。
但我还是明白了
[...]No component found with scheme: stream[...]
karaf 出错。
已经浏览了很多论坛和资料,但找不到任何解决方案...感谢任何帮助!
这是一种预感,但我猜您已经在 Bundle Activator 中创建了 DefaultCamelContext。然后 Stream Component 不会加载到该上下文中,除非你自己这样做:
StreamComponent stream = new StreamComponent();
camelContext.addComponent("stream", stream);