You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by Srivatsan Vengada Nallazhagappan <Sr...@infosys.com> on 2014/05/26 15:01:02 UTC
Simple Kafka producer in Windows does not run
Hi,
The program given below is not running in Windows through Eclipse while its runs in Unix platform (works fine when I run the same program in Unix where broker is running).
Is the kafka producer not supported in windows? I am able to ping the ip address from windows machine however. Please help.
package kpkg;
import java.util.Properties;
import kafka.javaapi.producer.Producer;
import kafka.producer.KeyedMessage;
import kafka.producer.ProducerConfig;
public class KProducer {
/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
Properties props = new Properties();
//props.put("zk.connect", "10.xx.xx.xx:2181");
props.put("metadata.broker.list", "10. xx.xx.xx:9092");
//props.put("host.name", "10.87.93.57");
props.put("serializer.class", "kafka.serializer.StringEncoder");
props.put("request.required.acks", "1");
ProducerConfig config = new ProducerConfig(props);
Producer<String, String> producer = new Producer<String, String>(config);
KeyedMessage<String, String> km = new KeyedMessage<String, String>("SriKafkaTopic" , "SriFirstMessage");
// The message is sent to a randomly selected partition registered in ZK
//ProducerData<String, String> data = new ProducerData<String, String>("test-topic", "test-message");
//producer.send(data);
producer.send(km);
producer.close();
}
}
Here is the exception error that I get.
log4j:WARN No appenders could be found for logger (kafka.utils.VerifiableProperties).
log4j:WARN Please initialize the log4j system properly.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" kafka.common.FailedToSendMessageException: Failed to send messages after 3 tries.
at kafka.producer.async.DefaultEventHandler.handle(DefaultEventHandler.scala:90)
at kafka.producer.Producer.send(Producer.scala:76)
at kafka.javaapi.producer.Producer.send(Producer.scala:33)
at kpkg.KProducer.main(KProducer.java:30)
**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely
for the use of the addressee(s). If you are not the intended recipient, please
notify the sender by e-mail and delete the original message. Further, you are not
to copy, disclose, or distribute this e-mail or its contents to any other person and
any such actions are unlawful. This e-mail may contain viruses. Infosys has taken
every reasonable precaution to minimize this risk, but is not liable for any damage
you may sustain as a result of any virus in this e-mail. You should carry out your
own virus checks before opening the e-mail or attachment. Infosys reserves the
right to monitor and review the content of all messages sent to or from this e-mail
address. Messages sent to or from this e-mail address may be stored on the
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***
Re: Simple Kafka producer in Windows does not run
Posted by Jun Rao <ju...@gmail.com>.
Which version of Kafka are you using? The log before FailedToSendMessage
should tell you the cause. Could you paste that?
Thanks,
Jun
On Mon, May 26, 2014 at 6:01 AM, Srivatsan Vengada Nallazhagappan <
SrivatsanVengada_N@infosys.com> wrote:
> Hi,
> The program given below is not running in Windows through Eclipse
> while its runs in Unix platform (works fine when I run the same program in
> Unix where broker is running).
> Is the kafka producer not supported in windows? I am able to ping the ip
> address from windows machine however. Please help.
>
> package kpkg;
>
> import java.util.Properties;
> import kafka.javaapi.producer.Producer;
> import kafka.producer.KeyedMessage;
> import kafka.producer.ProducerConfig;
>
>
> public class KProducer {
>
> /**
> * @param args
> */
> public static void main(String[] args)
> {
> // TODO Auto-generated method stub
> Properties props = new Properties();
> //props.put("zk.connect", "10.xx.xx.xx:2181");
> props.put("metadata.broker.list", "10. xx.xx.xx:9092");
> //props.put("host.name", "10.87.93.57");
> props.put("serializer.class",
> "kafka.serializer.StringEncoder");
> props.put("request.required.acks", "1");
>
> ProducerConfig config = new ProducerConfig(props);
> Producer<String, String> producer = new Producer<String,
> String>(config);
> KeyedMessage<String, String> km = new KeyedMessage<String,
> String>("SriKafkaTopic" , "SriFirstMessage");
> // The message is sent to a randomly selected partition
> registered in ZK
> //ProducerData<String, String> data = new
> ProducerData<String, String>("test-topic", "test-message");
> //producer.send(data);
> producer.send(km);
> producer.close();
> }
>
> }
>
> Here is the exception error that I get.
>
> log4j:WARN No appenders could be found for logger
> (kafka.utils.VerifiableProperties).
> log4j:WARN Please initialize the log4j system properly.
> SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
> SLF4J: Defaulting to no-operation (NOP) logger implementation
> SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further
> details.
> Exception in thread "main" kafka.common.FailedToSendMessageException:
> Failed to send messages after 3 tries.
> at
> kafka.producer.async.DefaultEventHandler.handle(DefaultEventHandler.scala:90)
> at kafka.producer.Producer.send(Producer.scala:76)
> at kafka.javaapi.producer.Producer.send(Producer.scala:33)
> at kpkg.KProducer.main(KProducer.java:30)
>
>
>
> **************** CAUTION - Disclaimer *****************
> This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended
> solely
> for the use of the addressee(s). If you are not the intended recipient,
> please
> notify the sender by e-mail and delete the original message. Further, you
> are not
> to copy, disclose, or distribute this e-mail or its contents to any other
> person and
> any such actions are unlawful. This e-mail may contain viruses. Infosys
> has taken
> every reasonable precaution to minimize this risk, but is not liable for
> any damage
> you may sustain as a result of any virus in this e-mail. You should carry
> out your
> own virus checks before opening the e-mail or attachment. Infosys reserves
> the
> right to monitor and review the content of all messages sent to or from
> this e-mail
> address. Messages sent to or from this e-mail address may be stored on the
> Infosys e-mail system.
> ***INFOSYS******** End of Disclaimer ********INFOSYS***
>