[
https://issues.apache.org/jira/browse/KAFKA-130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jay Kreps updated KAFKA-130:
----------------------------
Assignee: Jay Kreps
Status: Patch Available (was: Open)
Usage is the following:
jkreps-mn:kafka-git jkreps$ bin/kafka-run-class.sh
kafka.producer.ConsoleProducer
Missing required argument "[topic]"
Option Description
------ -----------
--batch-size <Integer: size> Number of messages to send in a single
batch if they are not being sent
synchronously. (default: 200)
--compress If set, messages batches are sent
compressed
--line-reader <reader_class> The class name of the class to use for
reading lines from standard in. By
default each line is read as a
seperate message. (default: kafka.
producer.
ConsoleProducer$LineMessageReader)
--message-encoder <encoder_class> The class name of the message encoder
implementation to use. (default:
kafka.serializer.StringEncoder)
--property <prop>
--sync If set message send requests to the
brokers are synchronously, one at a
time as they arrive.
--timeout <Long: timeout_ms> If set and the producer is running in
asynchronous mode, this gives the
maximum amount of time a message
will queue awaiting suffient batch
size. The value is given in ms.
(default: 1000)
--topic <topic> REQUIRED: The topic id to produce
messages to.
--zookeeper <connection_string> REQUIRED: The zookeeper connection
string for the kafka zookeeper
instance in the form HOST:PORT
[/CHROOT].
It reads from standard input so it can take interactive input or else you can
pipe stuff to it:
cat ~/some_log_file.log| bin/kafka-run-class.sh kafka.producer.ConsoleProducer
--topic test --zookeeper localhost:2181
By default it reads lines from the log and sends them as string messages to
Kafka.
Both the class used to read objects and the Kafka producer serializer can be
customized from the arguments. The serializer is the normal
kafka.serializer.Encoder interface, and the class used to read messages from
System.in should extend the MessageReader abstract class (trait), which has the
following methods:
trait MessageReader {
def init(inputStream: InputStream, props: Properties) {}
def readMessage(): AnyRef
def close() {}
}
AKA:
interface MessageReader {
public void init(InputStream in, Properties props);
public Object readMessage();
public void close();
}
> Provide a default producer for receiving messages from STDIN
> ------------------------------------------------------------
>
> Key: KAFKA-130
> URL: https://issues.apache.org/jira/browse/KAFKA-130
> Project: Kafka
> Issue Type: New Feature
> Affects Versions: 0.6
> Reporter: Felix GV
> Assignee: Jay Kreps
> Priority: Minor
> Attachments: kafka-console-producer.patch
>
>
> It would be useful to provide a default producer we can fire up that reads
> from STDIN and sends one message per line to the broker.
> The most obvious use case for this is to pipe a tail -f command into it, to
> tail log files as they're generated. Making it depend on STDIN seems more
> flexible than a producer that just tails files though.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira