在eclipse中编写kafka生产者代码时,我得到了下面提到的一个错误,在这里我想编写一个简单的生产者代码并在kafka控制台上显示消息consumer我启动了zookeeper和kafka服务器并完美地创建了topic。
代码如下:
import java.util.Properties;
import kafka.javaapi.producer.Producer;
import kafka.producer.KeyedMessage;
import kafka.producer.ProducerConfig;
public class ProducerTest {
public static void mian(String ar[]){
Properties prop=new Properties();
prop.put("zk.connect","localhost:2181");
prop.put("serializer.class","kafka.serializer.StringEncoder");
prop.put("metadata.broker.list","localhost:9092");
ProducerConfig config=new ProducerConfig(prop);
Producer producer=new Producer(config);
String msg="Sa resta rasta ra";
producer.send(new KeyedMessage("test",msg));
}
}
Missing required argument "[authorizer-properties]"
Option Description
----*emphasized text*-- -----------
--add Indicates you are trying to add ACLs.
--allow-host <allow-host> Host from which principals listed in --
allow-principal will have access. If
you have specified --allow-principal
then the default for this option
will be set to * which allows access
from all hosts.
--allow-principal <allow-principal> principal is in principalType:name
format. User:* is the wild card
任何人请帮我解决这个错误。
1条答案
按热度按时间hmmo2u0o1#
我不知道为什么会收到这个错误消息,但是现在它自动消失了,我只是为连接创建了一个分离的方法,并从main方法调用这个方法。