public class ProducerTest { @test
public void test() throws Exception {
Properties props = new Properties();
props.put("metadata.broker.list", "192.168.1.104:9092");
props.put("serializer.class", StringEncoder.class.getName());
ProducerConfig producerConfig = new ProducerConfig(props);
Producer<String, String> producer = new Producer<String,String>(producerConfig);
1 个回复
为了明天time - hadoop hive 大数据 java python 2015-10-12 回答
赞同来自: dandan_14104
@test
public void test() throws Exception {
Properties props = new Properties();
props.put("metadata.broker.list", "192.168.1.104:9092");
props.put("serializer.class", StringEncoder.class.getName());
ProducerConfig producerConfig = new ProducerConfig(props);
Producer<String, String> producer = new Producer<String,String>(producerConfig);
KeyedMessage<String, String> message = new KeyedMessage<String, String>("topic1", "message aaaaaaaaaa");
producer.send(message);
}
}
就类似这样的吧 进行消息发送