mirror of https://github.com/reiseburo/offtopic
commit
6da638a19a
|
@ -1,3 +1,5 @@
|
|||
build/
|
||||
.gradle/
|
||||
*.sw*
|
||||
.idea
|
||||
*.iml
|
||||
|
|
13
build.gradle
13
build.gradle
|
@ -8,11 +8,11 @@ plugins {
|
|||
apply plugin: 'groovy'
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
version = '0.1.0'
|
||||
version = '0.1.1'
|
||||
group = 'offtopic'
|
||||
description =' Offtopic is a simple web application built with Ratpack for inspecting and consuming events from Kafka.'
|
||||
sourceCompatibility = '1.7'
|
||||
targetCompatibility = '1.7'
|
||||
sourceCompatibility = '1.8'
|
||||
targetCompatibility = '1.8'
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -39,11 +39,18 @@ dependencies {
|
|||
|
||||
compile 'org.apache.kafka:kafka_2.10:0.8.1.1+'
|
||||
|
||||
compile 'org.slf4j:log4j-over-slf4j:1.7.6'
|
||||
compile 'org.slf4j:slf4j-simple:1.7.6'
|
||||
|
||||
testCompile 'org.spockframework:spock-core:0.7-groovy-2.0'
|
||||
testCompile 'cglib:cglib-nodep:2.2.+'
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
configurations {
|
||||
compile.exclude module: 'log4j'
|
||||
compile.exclude module: 'slf4j-log4j12'
|
||||
}
|
||||
|
||||
test {
|
||||
testLogging {
|
||||
|
|
|
@ -4,11 +4,13 @@ import kafka.consumer.ConsumerConfig;
|
|||
import kafka.consumer.KafkaStream;
|
||||
import kafka.javaapi.consumer.ConsumerConnector;
|
||||
import offtopic.curator.CuratorPool
|
||||
import groovy.util.logging.Slf4j
|
||||
|
||||
/**
|
||||
* KafkaSubscriber is a Kafka consumer consumer, largely cribbed from:
|
||||
* https://cwiki.apache.org/confluence/display/KAFKA/Consumer+Group+Example
|
||||
*/
|
||||
@Slf4j
|
||||
class KafkaSubscriber {
|
||||
|
||||
String topic
|
||||
|
@ -38,7 +40,7 @@ class KafkaSubscriber {
|
|||
|
||||
public void consume() {
|
||||
if (this.consumer == null) {
|
||||
println "no consumer, gtfo"
|
||||
log.warn "no consumer, gtfo"
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package offtopic
|
||||
|
||||
import groovy.util.logging.Slf4j
|
||||
|
||||
/**
|
||||
* OfftopicClient coordinates the interactions between KafkaSubscriber objects
|
||||
* and the websocket interactions
|
||||
*/
|
||||
@Slf4j
|
||||
class OfftopicClient {
|
||||
public int clientId = 0
|
||||
|
||||
|
@ -44,9 +47,9 @@ class OfftopicClient {
|
|||
this.subscribers.each { subscriber ->
|
||||
Thread runner = new Thread({
|
||||
subscriber.connect()
|
||||
println "subscriber connected"
|
||||
log.info "subscriber connected"
|
||||
subscriber.consume()
|
||||
println "consume over!"
|
||||
log.info "consume over!"
|
||||
})
|
||||
runner.start()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue