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
|
||||
|
||||
import kafka.consumer.ConsumerConfig;
|
||||
import kafka.consumer.KafkaStream;
|
||||
import kafka.javaapi.consumer.ConsumerConnector;
|
||||
import offtopic.curator.CuratorPool
|
||||
import kafka.consumer.ConsumerConfig
|
||||
import kafka.javaapi.consumer.ConsumerConnector
|
||||
import kafka.message.MessageAndMetadata
|
||||
import groovy.util.logging.Slf4j
|
||||
|
||||
/**
|
||||
|
@ -51,9 +50,11 @@ class KafkaSubscriber {
|
|||
consumerMap.get(this.topic).each { stream ->
|
||||
def iterator = stream.iterator()
|
||||
while (iterator.hasNext()) {
|
||||
def message = iterator.next()
|
||||
def data = ['raw' : new String(message.message()),
|
||||
MessageAndMetadata message = iterator.next()
|
||||
Map data = ['raw' : new String(message.message()),
|
||||
'b64' : message.message().encodeBase64().toString(),
|
||||
'offset' : message.offset,
|
||||
'partition' : message.partition,
|
||||
'topic' : message.topic(),
|
||||
'tstamp' : System.currentTimeMillis()]
|
||||
this.callback.call(data)
|
||||
|
|
|
@ -31,7 +31,7 @@ class OfftopicClient {
|
|||
return
|
||||
}
|
||||
|
||||
KafkaSubscriber subscriber = new KafkaSubscriber(Configuration.instance.zookeepers,
|
||||
KafkaSubscriber subscriber = new KafkaSubscriber(System.getProperty('zookeepers') ?: Configuration.instance.zookeepers,
|
||||
topic,
|
||||
"offtopic-${clientId}")
|
||||
subscriber.callback = this.messageCallback
|
||||
|
|
|
@ -17,3 +17,8 @@ body {
|
|||
|
||||
.message-raw {
|
||||
}
|
||||
|
||||
.offset {
|
||||
font-family: monospace;
|
||||
font-size: 0.7em;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,8 @@ function watchTopic(name) {
|
|||
var messages = $('#messages');
|
||||
var el_id = Math.floor(Math.random() * 1000000);
|
||||
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>',
|
||||
"<br/><div class='message-b64' id='" + el_id + "_b64'",
|
||||
"style='display:none;'><pre>" + data.b64 + "</pre></div>"].join("\n");
|
||||
|
|
Loading…
Reference in New Issue