当前位置: 首页>>代码示例>>Java>>正文


Java DefaultKafkaConsumerFactory.createConsumer方法代码示例

本文整理汇总了Java中org.springframework.kafka.core.DefaultKafkaConsumerFactory.createConsumer方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultKafkaConsumerFactory.createConsumer方法的具体用法?Java DefaultKafkaConsumerFactory.createConsumer怎么用?Java DefaultKafkaConsumerFactory.createConsumer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.kafka.core.DefaultKafkaConsumerFactory的用法示例。


在下文中一共展示了DefaultKafkaConsumerFactory.createConsumer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getKafkaConsumer

import org.springframework.kafka.core.DefaultKafkaConsumerFactory; //导入方法依赖的package包/类
private KafkaConsumer getKafkaConsumer(Binding binding) {
	DirectFieldAccessor bindingAccessor = new DirectFieldAccessor(binding);
	KafkaMessageDrivenChannelAdapter adapter = (KafkaMessageDrivenChannelAdapter) bindingAccessor
			.getPropertyValue("lifecycle");
	DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapter);
	ConcurrentMessageListenerContainer messageListenerContainer =
			(ConcurrentMessageListenerContainer) adapterAccessor.getPropertyValue("messageListenerContainer");
	DirectFieldAccessor containerAccessor = new DirectFieldAccessor(messageListenerContainer);
	DefaultKafkaConsumerFactory consumerFactory = (DefaultKafkaConsumerFactory) containerAccessor
			.getPropertyValue("consumerFactory");
	return (KafkaConsumer) consumerFactory.createConsumer();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-kafka,代码行数:13,代码来源:KafkaBinderTests.java

示例2: setUp

import org.springframework.kafka.core.DefaultKafkaConsumerFactory; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
	Map<String, Object> consumerProps = KafkaTestUtils.consumerProps("group-id", "false", embeddedKafka);
	consumerProps.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
	DefaultKafkaConsumerFactory<String, String> cf = new DefaultKafkaConsumerFactory<>(consumerProps);
	consumer = cf.createConsumer();
	embeddedKafka.consumeFromAnEmbeddedTopic(consumer, "counts-id");
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-kafka,代码行数:9,代码来源:KstreamBinderPojoInputStringOutputIntegrationTests.java

示例3: setUp

import org.springframework.kafka.core.DefaultKafkaConsumerFactory; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
	Map<String, Object> consumerProps = KafkaTestUtils.consumerProps("group", "false", embeddedKafka);
	consumerProps.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
	DefaultKafkaConsumerFactory<String, String> cf = new DefaultKafkaConsumerFactory<>(consumerProps);
	consumer = cf.createConsumer();
	embeddedKafka.consumeFromAnEmbeddedTopic(consumer, "counts");
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-kafka,代码行数:9,代码来源:KStreamBinderWordCountIntegrationTests.java

示例4: setUp

import org.springframework.kafka.core.DefaultKafkaConsumerFactory; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
	Map<String, Object> consumerProps = KafkaTestUtils.consumerProps("group-id", "false", embeddedKafka);
	//consumerProps.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, Deserializer.class.getName());
	consumerProps.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
	DefaultKafkaConsumerFactory<Integer, String> cf = new DefaultKafkaConsumerFactory<>(consumerProps);
	consumer = cf.createConsumer();
	embeddedKafka.consumeFromAnEmbeddedTopic(consumer, "counts-id");
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-kafka,代码行数:10,代码来源:KStreamBinderPojoInputAndPrimitiveTypeOutputTests.java


注:本文中的org.springframework.kafka.core.DefaultKafkaConsumerFactory.createConsumer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。