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


Java KafkaProducerMessageHandler类代码示例

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


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

示例1: testSyncProducerMetadata

import org.springframework.integration.kafka.outbound.KafkaProducerMessageHandler; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testSyncProducerMetadata() throws Exception {
	Binder binder = getBinder(createConfigurationProperties());
	DirectChannel output = new DirectChannel();
	String testTopicName = UUID.randomUUID().toString();
	ExtendedProducerProperties<KafkaProducerProperties> properties = createProducerProperties();
	properties.getExtension().setSync(true);
	Binding<MessageChannel> producerBinding = binder.bindProducer(testTopicName, output, properties);
	DirectFieldAccessor accessor = new DirectFieldAccessor(extractEndpoint(producerBinding));
	KafkaProducerMessageHandler wrappedInstance = (KafkaProducerMessageHandler) accessor.getWrappedInstance();
	assertThat(new DirectFieldAccessor(wrappedInstance).getPropertyValue("sync").equals(Boolean.TRUE))
			.withFailMessage("Kafka Sync Producer should have been enabled.");
	producerBinding.unbind();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-kafka,代码行数:16,代码来源:KafkaBinderTests.java

示例2: kafkaHandler

import org.springframework.integration.kafka.outbound.KafkaProducerMessageHandler; //导入依赖的package包/类
@ServiceActivator(inputChannel = "toKafka")
@Bean
public MessageHandler kafkaHandler() throws Exception {
  KafkaProducerMessageHandler<String, String> handler =
      new KafkaProducerMessageHandler<>(kafkaTemplate());
  handler.setTopicExpression(new LiteralExpression(KafkaConfig.getTopic()));
  handler.setMessageKeyExpression(new LiteralExpression(KafkaConfig.getMessageKey()));
  return handler;
}
 
开发者ID:jkutner,项目名称:heroku-metrics-spring,代码行数:10,代码来源:HerokuReplayApplication.java

示例3: kafkaMessageHandler

import org.springframework.integration.kafka.outbound.KafkaProducerMessageHandler; //导入依赖的package包/类
@Bean
@ServiceActivator(inputChannel = "producingChannel")
public MessageHandler kafkaMessageHandler() {
  KafkaProducerMessageHandler<String, String> handler =
      new KafkaProducerMessageHandler<>(kafkaTemplate());
  handler.setMessageKeyExpression(new LiteralExpression("kafka-integration"));

  return handler;
}
 
开发者ID:code-not-found,项目名称:spring-kafka,代码行数:10,代码来源:ProducingChannelConfig.java


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