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


Java ZookeeperConnect类代码示例

本文整理汇总了Java中org.springframework.integration.kafka.support.ZookeeperConnect的典型用法代码示例。如果您正苦于以下问题:Java ZookeeperConnect类的具体用法?Java ZookeeperConnect怎么用?Java ZookeeperConnect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ZookeeperConnect类属于org.springframework.integration.kafka.support包,在下文中一共展示了ZookeeperConnect类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: consumer

import org.springframework.integration.kafka.support.ZookeeperConnect; //导入依赖的package包/类
@Bean
IntegrationFlow consumer() {

    log.info("starting consumer..");

    KafkaHighLevelConsumerMessageSourceSpec messageSourceSpec = Kafka.inboundChannelAdapter(
            new ZookeeperConnect(this.kafkaConfig.getZookeeperAddress()))
            .consumerProperties(props ->
                    props.put("auto.offset.reset", "smallest")
                            .put("auto.commit.interval.ms", "100"))
            .addConsumer("myGroup", metadata -> metadata.consumerTimeout(100)
                    .topicStreamMap(m -> m.put(this.kafkaConfig.getTopic(), 1))
                    .maxMessages(10)
                    .valueDecoder(String::new));

    Consumer<SourcePollingChannelAdapterSpec> endpointConfigurer = e -> e.poller(p -> p.fixedDelay(100));

    return IntegrationFlows
            .from(messageSourceSpec, endpointConfigurer)
            .<Map<String, List<String>>>handle((payload, headers) -> {
                payload.entrySet().forEach(e -> log.info(e.getKey() + '=' + e.getValue()));
                return null;
            })
            .get();
}
 
开发者ID:joshlong,项目名称:spring-and-kafka,代码行数:26,代码来源:DemoApplication.java

示例2: consumer

import org.springframework.integration.kafka.support.ZookeeperConnect; //导入依赖的package包/类
@Bean IntegrationFlow consumer() {
  KafkaHighLevelConsumerMessageSourceSpec messageSourceSpec = Kafka.inboundChannelAdapter(
      new ZookeeperConnect("0.0.0.0:2181"))
        .consumerProperties(props ->
            props.put("auto.offset.reset", "smallest")
                 .put("auto.commit.interval.ms", "100"))
        .addConsumer("myGroup", metadata -> metadata.consumerTimeout(100)
          .topicStreamMap(m -> m.put("test-topic", 1))
          .maxMessages(10)
          .valueDecoder(String::new));

  Consumer<SourcePollingChannelAdapterSpec> endpointConfigurer = e -> e.poller(p -> p.fixedDelay(100));

  return IntegrationFlows
    .from(messageSourceSpec, endpointConfigurer)
    .<Map<String, List<String>>>handle((payload, headers) -> {
        payload.entrySet().forEach(e -> System.out.println(e.getKey() + '=' + e.getValue()));
        return null;
    })
    .get();
}
 
开发者ID:jadekler,项目名称:git-java-kafka-example,代码行数:22,代码来源:ConsumerConfiguration.java

示例3: consumer

import org.springframework.integration.kafka.support.ZookeeperConnect; //导入依赖的package包/类
@Bean
IntegrationFlow consumer() {

	log.info("starting consumer..");

	KafkaHighLevelConsumerMessageSourceSpec messageSourceSpec = Kafka
			.inboundChannelAdapter(
					new ZookeeperConnect(this.kafkaConfig
							.getZookeeperAddress()))
			.consumerProperties(
					props -> props.put("auto.offset.reset", "smallest")
							.put("auto.commit.interval.ms", "100"))
			.addConsumer(
					"myGroup",
					metadata -> metadata
							.consumerTimeout(100)
							.topicStreamMap(
									m -> m.put(this.kafkaConfig.getTopic(),
											1)).maxMessages(1)
							.valueDecoder(String::new));

	Consumer<SourcePollingChannelAdapterSpec> endpointConfigurer = e -> e.poller(p -> p.fixedDelay(100));

	return IntegrationFlows
			.from(messageSourceSpec, endpointConfigurer)
			.<Map<String, ConcurrentHashMap<String, String>>> handle(
					(payload, headers) -> {
						payload.entrySet().forEach(
								e -> orderEntryService.createOrderEntryFromJson(e.getValue()));
						return null;
					}).get();
}
 
开发者ID:codecentric,项目名称:event-based-shopping-system,代码行数:33,代码来源:CommoditiesReservationConsumerConfiguration.java


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