mirror of https://github.com/reiseburo/offtopic
Display the messages partition and offset when rendering a message
Fixes #22
This commit is contained in:
parent
4dc819f884
commit
0167dcde2a
|
@ -1,9 +1,8 @@
|
||||||
package offtopic
|
package offtopic
|
||||||
|
|
||||||
import kafka.consumer.ConsumerConfig;
|
import kafka.consumer.ConsumerConfig
|
||||||
import kafka.consumer.KafkaStream;
|
import kafka.javaapi.consumer.ConsumerConnector
|
||||||
import kafka.javaapi.consumer.ConsumerConnector;
|
import kafka.message.MessageAndMetadata
|
||||||
import offtopic.curator.CuratorPool
|
|
||||||
import groovy.util.logging.Slf4j
|
import groovy.util.logging.Slf4j
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,9 +50,11 @@ class KafkaSubscriber {
|
||||||
consumerMap.get(this.topic).each { stream ->
|
consumerMap.get(this.topic).each { stream ->
|
||||||
def iterator = stream.iterator()
|
def iterator = stream.iterator()
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
def message = iterator.next()
|
MessageAndMetadata message = iterator.next()
|
||||||
def data = ['raw' : new String(message.message()),
|
Map data = ['raw' : new String(message.message()),
|
||||||
'b64' : message.message().encodeBase64().toString(),
|
'b64' : message.message().encodeBase64().toString(),
|
||||||
|
'offset' : message.offset,
|
||||||
|
'partition' : message.partition,
|
||||||
'topic' : message.topic(),
|
'topic' : message.topic(),
|
||||||
'tstamp' : System.currentTimeMillis()]
|
'tstamp' : System.currentTimeMillis()]
|
||||||
this.callback.call(data)
|
this.callback.call(data)
|
||||||
|
|
|
@ -31,7 +31,7 @@ class OfftopicClient {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
KafkaSubscriber subscriber = new KafkaSubscriber(Configuration.instance.zookeepers,
|
KafkaSubscriber subscriber = new KafkaSubscriber(System.getProperty('zookeepers') ?: Configuration.instance.zookeepers,
|
||||||
topic,
|
topic,
|
||||||
"offtopic-${clientId}")
|
"offtopic-${clientId}")
|
||||||
subscriber.callback = this.messageCallback
|
subscriber.callback = this.messageCallback
|
||||||
|
|
|
@ -17,3 +17,8 @@ body {
|
||||||
|
|
||||||
.message-raw {
|
.message-raw {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.offset {
|
||||||
|
font-family: monospace;
|
||||||
|
font-size: 0.7em;
|
||||||
|
}
|
||||||
|
|
|
@ -16,7 +16,8 @@ function watchTopic(name) {
|
||||||
var messages = $('#messages');
|
var messages = $('#messages');
|
||||||
var el_id = Math.floor(Math.random() * 1000000);
|
var el_id = Math.floor(Math.random() * 1000000);
|
||||||
var el = ["<div id='" + el_id + "' class='list-group-item'>",
|
var el = ["<div id='" + el_id + "' class='list-group-item'>",
|
||||||
"<code>" + data.topic + "</code>",
|
"<code>" + data.topic + ":" + data.partition + "</code>",
|
||||||
|
"<span class='offset'>(offset: " + data.offset + ")</span>",
|
||||||
'<pre class="pre-scrollable message-raw">' + data.raw + '</pre>',
|
'<pre class="pre-scrollable message-raw">' + data.raw + '</pre>',
|
||||||
"<br/><div class='message-b64' id='" + el_id + "_b64'",
|
"<br/><div class='message-b64' id='" + el_id + "_b64'",
|
||||||
"style='display:none;'><pre>" + data.b64 + "</pre></div>"].join("\n");
|
"style='display:none;'><pre>" + data.b64 + "</pre></div>"].join("\n");
|
||||||
|
|
Loading…
Reference in New Issue