本文整理汇总了Java中kafka.utils.TestUtils.createNewProducer方法的典型用法代码示例。如果您正苦于以下问题:Java TestUtils.createNewProducer方法的具体用法?Java TestUtils.createNewProducer怎么用?Java TestUtils.createNewProducer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kafka.utils.TestUtils
的用法示例。
在下文中一共展示了TestUtils.createNewProducer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initProducer
import kafka.utils.TestUtils; //导入方法依赖的package包/类
private void initProducer(String bootstrapServer) {
producer = TestUtils.createNewProducer(
bootstrapServer,
1,
60 * 1000L,
1024L * 1024L,
0,
0L,
5 * 1000L,
SecurityProtocol.PLAINTEXT,
null,
Option$.MODULE$.apply(new Properties()),
new StringSerializer(),
new ByteArraySerializer(),
Option$.MODULE$.apply(new Properties()));
}
示例2: setUp
import kafka.utils.TestUtils; //导入方法依赖的package包/类
/**
* Starts a single kafka broker, and a single embedded zookeeper server in their own threads.
* Sub-classes should invoke {@link #zkConnect()} and {@link #bootstrapUrl()}s to
* obtain the urls (and ports) of the started zookeeper and kafka broker.
*/
@Override
public void setUp() {
super.setUp();
Properties consumerDeserializerProperties = new Properties();
consumerDeserializerProperties.setProperty("key.deserializer", DEFAULT_DESERIALIZER);
consumerDeserializerProperties.setProperty("value.deserializer", DEFAULT_DESERIALIZER);
producer = TestUtils.createNewProducer(
bootstrapServers(), // bootstrap-server url
1, // acks
60 * 1000L, // maxBlockMs
1024L * 1024L, // buffer size
0, // numRetries
0L, // lingerMs
5 * 1000L, // requestTimeout
SecurityProtocol.PLAINTEXT,
null,
Option.apply(new Properties()),
new StringSerializer(),
new StringSerializer(),
Option.apply(new Properties()));
consumer = TestUtils.createNewConsumer(
bootstrapServers(),
"group", // groupId
"earliest", // auto-offset-reset
4096L, // per-partition fetch size
"org.apache.kafka.clients.consumer.RangeAssignor", // partition Assigner
30000,
SecurityProtocol.PLAINTEXT,
Option$.MODULE$.<File>empty(),
Option$.MODULE$.<Properties>empty(),
Option$.MODULE$.<Properties>apply(consumerDeserializerProperties));
}
示例3: setUp
import kafka.utils.TestUtils; //导入方法依赖的package包/类
@Override
public void setUp() {
super.setUp();
producer = TestUtils.createNewProducer(
bootstrapServers(),
1,
60 * 1000L,
1024L * 1024L,
0,
0L,
5 * 1000L,
SecurityProtocol.PLAINTEXT,
null,
Option$.MODULE$.<Properties>apply(new Properties()),
new StringSerializer(),
new ByteArraySerializer(),
Option$.MODULE$.<Properties>apply(new Properties()));
consumer = TestUtils.createNewConsumer(
bootstrapServers(),
"group",
"earliest",
4096L,
"org.apache.kafka.clients.consumer.RangeAssignor",
30000,
SecurityProtocol.PLAINTEXT,
Option$.MODULE$.<File>empty(),
Option$.MODULE$.<Properties>empty(),
Option$.MODULE$.<Properties>empty());
}