我创建了一个简单的Kafka Producer&Consumer.我使用的是kafka_2.11-0.9.0.0.这是我的制作人代码,
public class KafkaProducerTest {
public static String topicName = "test-topic-2";
public static void main(String[] args) {
// TODO Auto-generated method stub
Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092");
props.put("acks", "all");
props.put("retries", 0);
props.put("batch.size", 16384);
props.put("linger.ms", 1);
props.put("buffer.memory", 33554432);
props.put("key.serializer",
StringSerializer.class.getName());
props.put("value.serializer",
StringSerializer.class.getName());
Producer<String, String> producer = new KafkaProducer(props);
for (int i = 0; i < 100; i++) {
ProducerRecord<String, String> producerRecord = new ProducerRecord<String, String>(
topicName, Integer.toString(i), Integer.toString(i));
System.out.println(producerRecord);
producer.send(producerRecord);
}
producer.close();
}
}
Run Code Online (Sandbox Code Playgroud)
在启动捆绑ia时遇到以下错误,
2016-05-20 09:44:57,792 | …Run Code Online (Sandbox Code Playgroud) apache-karaf apache-kafka apache-spark spark-streaming-kafka
Fuse ESB使用带有OSGi的karaf服务器.
对于代码,如果任何人有步骤获取应用程序的调试器,它将有所帮助.
我目前正在使用Eclipse Indigo.在使用OSGi时,我们使用Maven来构建相同的内容.
哪个插件对OSGi的Karaf有帮助
eclipse eclipse-plugin apache-karaf fuseesb apache-servicemix
我使用$KARAF_HOME/bin/startCentOS 6.5 在服务器模式下启动了Apache Karaf 3.0.0 .然后我想运行几个命令$KARAF_HOME/bin/client并捕获这些命令的输出,以确保命令成功运行.输出确实在我的控制台上吐出,但我永远无法将其重定向到文件中.好像Karaf没有向输出流或错误流写任何内容.我尝试了以下方法:
[apache-karaf-3.0.0]$ ./bin/start clean
[apache-karaf-3.0.0]$ ./bin/client "bundle:list"
Logging in as karaf
282 [pool-2-thread-3] WARN org.apache.sshd.client.keyverifier.AcceptAllServerKeyVerifier - Server at /0.0.0.0:8101 presented unverified key:
START LEVEL 100 , List Threshold: 50
ID | State | Lvl | Version | Name
------------------------------------------------------------------------------------
91 | Active | 80 | 1.8.0 | Commons Codec
92 | Active | 80 | 2.6 | Commons Lang
93 | Active | 80 | 15.0.0 | Guava: Google Core Libraries …Run Code Online (Sandbox Code Playgroud) 当我向我的网络服务发送请求(使用 apache camel 构建并在 apache karaf 上运行)时,我总是得到
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Message part {http://localhost:8181/cxf/webservices/inputoutput}input was not recognized. (Does it exist in service WSDL?)</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)
我的 wsdl 看起来像这样
<?xml version="1.0" encoding="ISO-8859-1"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://localhost:8181/cxf/webservices/inputoutput"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://localhost:8181/cxf/webservices/inputoutput">
<!-- Type definitions for input- and output parameters for webservice -->
<wsdl:types>
<xs:schema targetNamespace="http://localhost:8181/cxf/webservices/inputoutput">
<xs:element name="input">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="surname"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="output">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="forename"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<!-- Message definitions for …Run Code Online (Sandbox Code Playgroud) 我有以下设置
创建了两个docker swarm服务
docker service create --name karaf1-service --replicas 1 --network karaf_net karaf1:2.0.0
docker service create --name karaf2-service --replicas 1 --network karaf_net karaf2:2.0.0
现在这些容器在开始时打开套接字端口,我观察一段时间它成功地创建它失败的大量时间.
ServerSocketFactory.getDefault().createServerSocket(serverPort)
Run Code Online (Sandbox Code Playgroud)
如果两个容器都在一个节点上启动,那么它几乎是成功的,但是当容器在不同的节点上创建时,它每次都会失败.
在对网络问题进行故障排除之前,容器atleast应该创建套接字.
这个容器无法打开套接字
root@bd48643080b2:/opt/apache/apache-karaf-4.1.5# netstat -tulnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8101 0.0.0.0:* LISTEN 61/java
tcp 0 0 127.0.0.1:1099 0.0.0.0:* LISTEN 61/java
tcp 0 0 0.0.0.0:41551 0.0.0.0:* LISTEN 61/java
tcp 0 0 127.0.0.11:44853 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:44444 …Run Code Online (Sandbox Code Playgroud) 我按照http://blog.nanthrax.net/2011/11/apache-karaf-cellar-and-dosgi/上的Karaf Cellar示例进行了操作.
我创建了3个OSGi包,即服务(Bundle1),服务实现(Bundle2)和客户端(Bundle3).我有2个karaf容器在不同的机器上运行,其中(Bundle1)和(Bundle2)部署在一个karaf实例上,(Bundle1)和(Bundle3)部署在其他karaf实例上.如示例中给出的那样,每件事情都很好.我从Karaf container2中删除了客户端包,并希望通过蓝图中描述的camel路由调用该服务.
<?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">
<reference id="myService" interface="org.service.cellar.EchoService" timeout="20000" availability="optional" />
<camelContext id="camel" trace="false"
xmlns="http://camel.apache.org/schema/blueprint">
<route id="client">
<from uri="timer://foo?fixedRate=true&period=10000" />
<bean ref="myService" method="process" />
<log message=" Invoking Service : ${body}" />
</route>
</camelContext>
</blueprint>
Run Code Online (Sandbox Code Playgroud)
一旦我在karaf container2中部署了上述蓝图,我就在karaf容器中看到以下异常1.我无法找出此错误的来源.任何有关此问题的评论表示赞赏.
谢谢.
2012-10-15 13:24:40,477 | ERROR | pool-11-thread-7 | EventDispatchTask | 78 - org.apache.karaf.cellar.core - 2.2.4 | Error while dispatching task
java.lang.NullPointerException
at org.apache.karaf.cellar.dosgi.RemoteServiceCallHandler.handle(RemoteServiceCallHandler.java:74)[83:org.apache.karaf.cellar.dosgi:2.2.4]
at org.apache.karaf.cellar.dosgi.RemoteServiceCallHandler.handle(RemoteServiceCallHandler.java:34)[83:org.apache.karaf.cellar.dosgi:2.2.4]
at sun.reflect.GeneratedMethodAccessor31.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1.6.0_35]
at java.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_35]
at org.apache.aries.proxy.impl.ProxyHandler$1.invoke(ProxyHandler.java:50)[7:org.apache.aries.proxy:0.3.1] … 我正在尝试使karaf-maven-plugin为我的应用程序生成一个功能文件.该应用程序取决于cxf功能,但我似乎无法使插件生成功能xml来反映这一点.
我的功能模块剪切:
<dependencies>
<dependency>
<groupId>com.test.test</groupId>
<artifactId>test</artifactId>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<version>3.0.3</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<configuration>
<startLevel>80</startLevel>
<includeTransitiveDependency>true</includeTransitiveDependency>
<aggregateFeatures>false</aggregateFeatures>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
我的模块的依赖项:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>5.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
<version>5.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.configadmin</artifactId>
<version>1.8.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.2.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>provided</scope>
</dependency> …Run Code Online (Sandbox Code Playgroud) 我正在构建一个 .kar 文件,但是当我运行时mvn package出现此错误:
[INFO] --- maven-bundle-plugin:2.4.0:bundle (default-bundle) @ common ---
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/xml/bind/v2
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-impl, Jar:jaxb-core]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/istack
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning …Run Code Online (Sandbox Code Playgroud) 我搜索了 looooot,但找不到解决我的问题的方法。
我使用 osgi、karaf 和 java 8。
我有一些模块,例如:
WEBSERVICE-这个模块里面的东西可以说API,持久性,适配器
持久性和 api 启动正常,但适配器给出了该错误:
Uses constraint violation. Unable to resolve resource adapter [adapter [288](R 288.2)]
because it is exposed to package 'javax.xml.bind.annotation' from resources
org.apache.felix.framework [org.apache.felix.framework [0](R 0)] and
jakarta.xml.bind-api [jakarta.xml.bind-api [79](R 79.0)] via two dependency
chains.
Run Code Online (Sandbox Code Playgroud)
链在适配器和 api 中。
但是,这是什么意思?
我可以将它安装为功能,它们都会启动,但我的另一包将放在 GracePeriod 中,如果我在 karaf 上执行 DIAG,它会说:
Status: GracePeriod
Declarative Services
Blueprint
01/09/19 19:00
Missing dependencies:
(&(osgi.unit.name=example_db)(objectClass=javax.persistence.EntityManager))
Run Code Online (Sandbox Code Playgroud)
请注意,我有其他 webservice 模块,其中一些工作正常,我检查了 pom,它们具有相同的依赖项和相同的版本
数据源也很好,我已经尝试添加一些功能,如 hibernate.entityManager,但它不起作用。
我正在处理 karaf 的捆绑包和插件的复杂项目结构。
附加到流程时,我无法使用 WATCH,因为找不到项目:
无法评估,因为 java.lang.IllegalStateException:找不到项目 XY。
是否可以从断点所在的文件及其包含的 maven 文件确定正确的项目名称?
由于某种原因,XY 内的内容不起作用。
这是启动配置:
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Debug Karaf",
"projectName" : "XY",
"request": "attach",
"hostName" : "localhost",
"port": 5005
}
]
Run Code Online (Sandbox Code Playgroud)
编辑:断点和逐步调试确实有效。奇怪的是,这两件事是不同的。
apache-karaf ×10
osgi ×5
maven ×3
java ×2
apache-camel ×1
apache-kafka ×1
apache-spark ×1
docker ×1
docker-swarm ×1
dosgi ×1
eclipse ×1
fuseesb ×1
karaf ×1
launch ×1
provisioning ×1
soap ×1
web-services ×1
wsdl ×1