我正在使用Kafka的高级消费者.因为我正在使用Kafka作为我的应用程序的"事务队列",所以我需要确保我不会错过或重读任何消息.我有两个问题:
如何将偏移量提交给zookeeper?在每次成功使用消息后,我将关闭自动提交和提交偏移量.我似乎无法找到如何使用高级消费者执行此操作的实际代码示例.谁能帮我这个?
另一方面,我听说承诺动物园管理员可能会很慢,所以另一种方式可能是在本地跟踪偏移?这种替代方法是否可取?如果是的话,你会怎么做?
message-queue distributed-transactions apache-kafka apache-zookeeper
我的build.gradle目前是:
project(':rss-middletier') {
apply plugin: 'java'
dependencies {
compile project(':rss-core')
compile 'asm:asm-all:3.2'
compile 'com.sun.jersey:jersey-server:1.9.1'
compile group: 'org.javalite', name: 'activejdbc', version: '1.4.9'
}
jar {
from(configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }) {
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
}
manifest { attributes 'Main-Class':
'com.netflix.recipes.rss.server.MiddleTierServer' }
}
}
Run Code Online (Sandbox Code Playgroud)
但是,我不想直接将这些编译的类打包到jar中,而是首先通过运行以下任务来检测它们:
task instrument(dependsOn: 'build', type: JavaExec) {
main = 'org.javalite.instrumentation.Main'
classpath = buildscript.configurations.classpath
classpath += project(':rss-middletier').sourceSets.main.runtimeClasspath
jvmArgs '-DoutputDirectory=' + project(':rss-middletier').sourceSets
.main.output.classesDir.getPath()
}
Run Code Online (Sandbox Code Playgroud)
只有在我对这些类进行了检测之后,我才会将它们打包成一个JAR文件.有没有办法让我可以在包装之前做这个仪器?
非常感谢!!!