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


Java ExtendedProducerProperties类代码示例

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


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

示例1: createProducerMessageHandler

import org.springframework.cloud.stream.binder.ExtendedProducerProperties; //导入依赖的package包/类
@Override
protected MessageHandler createProducerMessageHandler(ProducerDestination destination,
		ExtendedProducerProperties<KinesisProducerProperties> producerProperties, MessageChannel errorChannel) {

	KinesisMessageHandler kinesisMessageHandler = new KinesisMessageHandler(this.amazonKinesis);
	kinesisMessageHandler.setSync(producerProperties.getExtension().isSync());
	kinesisMessageHandler.setSendTimeout(producerProperties.getExtension().getSendTimeout());
	kinesisMessageHandler.setStream(destination.getName());
	if (producerProperties.isPartitioned()) {
		kinesisMessageHandler
				.setPartitionKeyExpressionString("'partitionKey-' + headers." + BinderHeaders.PARTITION_HEADER);
	}
	kinesisMessageHandler.setFailureChannel(errorChannel);
	kinesisMessageHandler.setBeanFactory(getBeanFactory());

	return kinesisMessageHandler;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-aws-kinesis,代码行数:18,代码来源:KinesisMessageChannelBinder.java

示例2: testProvisionProducerSuccessfulWithExistingStream

import org.springframework.cloud.stream.binder.ExtendedProducerProperties; //导入依赖的package包/类
@Test
public void testProvisionProducerSuccessfulWithExistingStream() {
	AmazonKinesis amazonKinesisMock = mock(AmazonKinesis.class);
	KinesisBinderConfigurationProperties binderProperties = new KinesisBinderConfigurationProperties();
	KinesisStreamProvisioner provisioner = new KinesisStreamProvisioner(amazonKinesisMock, binderProperties);
	ExtendedProducerProperties<KinesisProducerProperties> extendedProducerProperties =
			new ExtendedProducerProperties<>(new KinesisProducerProperties());
	String name = "test-stream";

	DescribeStreamResult describeStreamResult = describeStreamResultWithShards(
			Collections.singletonList(new Shard()));

	when(amazonKinesisMock.describeStream(any(DescribeStreamRequest.class)))
			.thenReturn(describeStreamResult);

	ProducerDestination destination = provisioner.provisionProducerDestination(name, extendedProducerProperties);

	verify(amazonKinesisMock)
			.describeStream(any(DescribeStreamRequest.class));

	assertThat(destination.getName()).isEqualTo(name);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-aws-kinesis,代码行数:23,代码来源:KinesisStreamProvisionerTests.java

示例3: provisionProducerDestination

import org.springframework.cloud.stream.binder.ExtendedProducerProperties; //导入依赖的package包/类
@Override
public ProducerDestination provisionProducerDestination(final String name, ExtendedProducerProperties<KafkaProducerProperties> properties) {
	if (this.logger.isInfoEnabled()) {
		this.logger.info("Using kafka topic for outbound: " + name);
	}
	KafkaTopicUtils.validateTopicName(name);
	createTopic(name, properties.getPartitionCount(), false);
	if (this.configurationProperties.isAutoCreateTopics() && adminClient != null) {
		DescribeTopicsResult describeTopicsResult = adminClient.describeTopics(Collections.singletonList(name));
		KafkaFuture<Map<String, TopicDescription>> all = describeTopicsResult.all();

		try {
			Map<String, TopicDescription> topicDescriptions = all.get(operationTimeout, TimeUnit.SECONDS);
			TopicDescription topicDescription = topicDescriptions.get(name);
			int partitions = topicDescription.partitions().size();
			return new KafkaProducerDestination(name, partitions);
		}
		catch (Exception e) {
			throw new ProvisioningException("Problems encountered with partitions finding", e);
		}
	}
	else {
		return new KafkaProducerDestination(name);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-kafka,代码行数:26,代码来源:KafkaTopicProvisioner.java

示例4: ProducerConfigurationMessageHandler

import org.springframework.cloud.stream.binder.ExtendedProducerProperties; //导入依赖的package包/类
ProducerConfigurationMessageHandler(KafkaTemplate<byte[], byte[]> kafkaTemplate, String topic,
		ExtendedProducerProperties<KafkaProducerProperties> producerProperties,
		ProducerFactory<byte[], byte[]> producerFactory) {
	super(kafkaTemplate);
	setTopicExpression(new LiteralExpression(topic));
	setMessageKeyExpression(producerProperties.getExtension().getMessageKeyExpression());
	setBeanFactory(KafkaMessageChannelBinder.this.getBeanFactory());
	if (producerProperties.isPartitioned()) {
		SpelExpressionParser parser = new SpelExpressionParser();
		setPartitionIdExpression(parser.parseExpression("headers." + BinderHeaders.PARTITION_HEADER));
	}
	if (producerProperties.getExtension().isSync()) {
		setSync(true);
	}
	this.producerFactory = producerFactory;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-kafka,代码行数:17,代码来源:KafkaMessageChannelBinder.java

示例5: createProducerDestinationIfNecessary

import org.springframework.cloud.stream.binder.ExtendedProducerProperties; //导入依赖的package包/类
@Override
protected List<TopicInfo> createProducerDestinationIfNecessary(String name,
		ExtendedProducerProperties<PubSubProducerProperties> properties) {
	Integer partitionIndex = null;
	List<TopicInfo> topics = new LinkedList<>();

	if (properties.isPartitioned()) {
		for (int i = 0; i < properties.getPartitionCount(); i++) {
			if (properties.isPartitioned())
				partitionIndex = i;
			TopicInfo topic = resourceManager.declareTopic(name,
					properties.getExtension().getPrefix(), partitionIndex);
			topics.add(topic);
		}
	}
	else {
		topics.add(resourceManager.declareTopic(name,
				properties.getExtension().getPrefix(), null));
	}

	return topics;
}
 
开发者ID:viniciusccarvalho,项目名称:spring-cloud-stream-binder-pubsub,代码行数:23,代码来源:PubSubMessageChannelBinder.java

示例6: createProducerMessageHandler

import org.springframework.cloud.stream.binder.ExtendedProducerProperties; //导入依赖的package包/类
@Override
protected MessageHandler createProducerMessageHandler(List<TopicInfo> destinations,
		ExtendedProducerProperties<PubSubProducerProperties> producerProperties)
		throws Exception {

	PubSubMessageHandler handler = null;
	if (producerProperties.getExtension().isBatchEnabled()) {
		handler = new BatchingPubSubMessageHandler(resourceManager,
				producerProperties, destinations);
		((BatchingPubSubMessageHandler) handler)
				.setConcurrency(producerProperties.getExtension().getConcurrency());
	}
	else {
		handler = new SimplePubSubMessageHandler(resourceManager, producerProperties,
				destinations);
	}

	resourceManager.createRequiredMessageGroups(destinations, producerProperties);

	return handler;
}
 
开发者ID:viniciusccarvalho,项目名称:spring-cloud-stream-binder-pubsub,代码行数:22,代码来源:PubSubMessageChannelBinder.java

示例7: createNonPartitionedSubscription

import org.springframework.cloud.stream.binder.ExtendedProducerProperties; //导入依赖的package包/类
@Test
public void createNonPartitionedSubscription() throws Exception {
	PubSubProducerProperties properties = new PubSubProducerProperties();

	ExtendedProducerProperties<PubSubProducerProperties> producerProperties = new ExtendedProducerProperties<>(properties);
	producerProperties.setRequiredGroups("hdfs", "average");
	producerProperties.getExtension().setPrefix("createNonPartitionedSubscription");
	List<TopicInfo> topics = new ArrayList<>();
	topics.add(resourceManager.declareTopic("test",properties.getPrefix(),null));
	resourceManager.createRequiredMessageGroups(topics,producerProperties);

	Topic topic = pubSub.getTopic(topics.get(0).name());
	Assert.assertNotNull(topic);
	topic.listSubscriptions().iterateAll().forEachRemaining(subscriptionId -> {
		Assert.assertTrue(subscriptionId.subscription().startsWith("createNonPartitionedSubscription.test."));
	});
	resourceManager.deleteTopics(topics);


}
 
开发者ID:viniciusccarvalho,项目名称:spring-cloud-stream-binder-pubsub,代码行数:21,代码来源:ResourceManagerTests.java

示例8: createPartitionedSubscription

import org.springframework.cloud.stream.binder.ExtendedProducerProperties; //导入依赖的package包/类
@Test
public void createPartitionedSubscription() throws Exception {
	PubSubProducerProperties properties = new PubSubProducerProperties();

	ExtendedProducerProperties<PubSubProducerProperties> producerProperties = new ExtendedProducerProperties<>(properties);
	producerProperties.setRequiredGroups("hdfs", "average");
	producerProperties.getExtension().setPrefix("createPartitionedSubscription");
	List<TopicInfo> topics = new ArrayList<>();
	for(int i=0;i<2;i++){
		topics.add(resourceManager.declareTopic("test",properties.getPrefix(),i));
	}
	resourceManager.createRequiredMessageGroups(topics,producerProperties);

	for(int i=0;i<2;i++){
		Topic topic = pubSub.getTopic(topics.get(i).name());
		Assert.assertNotNull(topic);
		topic.listSubscriptions().values().forEach(subscriptionId -> {
			Assert.assertTrue(subscriptionId.subscription().startsWith("createPartitionedSubscription.test-"));
		});
	}

	resourceManager.deleteTopics(topics);


}
 
开发者ID:viniciusccarvalho,项目名称:spring-cloud-stream-binder-pubsub,代码行数:26,代码来源:ResourceManagerTests.java

示例9: consumeMessages

import org.springframework.cloud.stream.binder.ExtendedProducerProperties; //导入依赖的package包/类
@Test
public void consumeMessages() throws Exception {

	int messageCount = 2000;
	final AtomicInteger counter = new AtomicInteger(0);
	CountDownLatch latch = new CountDownLatch(messageCount);
	String baseTopicName = "pubsub-test";
	ExtendedProducerProperties<PubSubProducerProperties> extendedProducerProperties = new ExtendedProducerProperties<>(new PubSubProducerProperties());
	List<TopicInfo> topics = new ArrayList<>();
	topics.add(resourceManager.declareTopic(baseTopicName,"",null));
	SubscriptionInfo subscriptionInfo = resourceManager.declareSubscription(topics.get(0).name(),"test-subscription","");
	PubSubMessageHandler messageHandler = new BatchingPubSubMessageHandler(resourceManager,extendedProducerProperties,topics);
	messageHandler.start();
	resourceManager.createConsumer(subscriptionInfo, message -> {
		counter.incrementAndGet();
		latch.countDown();
	});
	for(int j=0;j<messageCount;j++){
		String payload = "foo-"+j;
		messageHandler.handleMessage(MessageBuilder.withPayload(payload.getBytes()).build());
	}
	latch.await();
	Assert.assertEquals(messageCount,counter.get());
}
 
开发者ID:viniciusccarvalho,项目名称:spring-cloud-stream-binder-pubsub,代码行数:25,代码来源:PubSubMessageHandlerTests.java

示例10: shouldPublishMessageWithBytePayload

import org.springframework.cloud.stream.binder.ExtendedProducerProperties; //导入依赖的package包/类
@Test
public void shouldPublishMessageWithBytePayload() {

    // given
    DirectChannel output = new DirectChannel();

    ArgumentCaptor<URI> uriCaptor = ArgumentCaptor.forClass(URI.class);
    ArgumentCaptor<HermesMessage> messageCaptor = ArgumentCaptor.forClass(HermesMessage.class);

    // when
    Binding<MessageChannel> binding = binder.bindProducer(
            OUTPUT_NAME, output, new ExtendedProducerProperties<>(new HermesProducerProperties()));

    // then
    output.send(new GenericMessage<>(MESSAGE, json()));
    verify(hermesSender).send(uriCaptor.capture(), messageCaptor.capture());

    assertEquals("http://localhost:8080/topics/topic", uriCaptor.getValue().toString());
    assertArrayEquals(MESSAGE.getBytes(), messageCaptor.getValue().getBody());

    binding.unbind();
}
 
开发者ID:jmnarloch,项目名称:hermes-spring-cloud-starter-stream,代码行数:23,代码来源:HermesClientBinderTest.java

示例11: shouldPublishMessageWithError

import org.springframework.cloud.stream.binder.ExtendedProducerProperties; //导入依赖的package包/类
@Test
public void shouldPublishMessageWithError() {

    // given
    reset(hermesSender);
    final HermesResponse response = HermesResponseBuilder.hermesResponse()
            .withHttpStatus(500)
            .build();

    when(hermesSender.send(any(URI.class), any(HermesMessage.class)))
            .thenReturn(CompletableFuture.completedFuture(response));

    DirectChannel output = new DirectChannel();

    // when
    Binding<MessageChannel> binding = binder.bindProducer(
            OUTPUT_NAME, output, new ExtendedProducerProperties<>(new HermesProducerProperties()));

    // then
    output.send(new GenericMessage<>(MESSAGE, json()));
    verify(hermesSender, times(4)).send(any(URI.class), any(HermesMessage.class));
    binding.unbind();
}
 
开发者ID:jmnarloch,项目名称:hermes-spring-cloud-starter-stream,代码行数:24,代码来源:HermesClientBinderTest.java

示例12: bindProducer

import org.springframework.cloud.stream.binder.ExtendedProducerProperties; //导入依赖的package包/类
@Override
public Binding<MessageChannel> bindProducer(String name, MessageChannel moduleOutputChannel,
		ExtendedProducerProperties<RabbitProducerProperties> properties) {
	this.queues.add(properties.getExtension().getPrefix() + name + ".default");
	this.exchanges.add(properties.getExtension().getPrefix() + name);
	if (properties.getRequiredGroups() != null) {
		for (String group : properties.getRequiredGroups()) {
			if (properties.getExtension().isQueueNameGroupOnly()) {
				this.queues.add(properties.getExtension().getPrefix() + group);
			}
			else {
				this.queues.add(properties.getExtension().getPrefix() + name + "." + group);
			}
		}
	}
	this.prefixes.add(properties.getExtension().getPrefix());
	deadLetters(properties.getExtension());
	return super.bindProducer(name, moduleOutputChannel, properties);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-rabbit,代码行数:20,代码来源:RabbitTestBinder.java

示例13: bindProducer

import org.springframework.cloud.stream.binder.ExtendedProducerProperties; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public <T> Binding<T> bindProducer(T output, String outputName) {
	String bindingTarget = this.bindingServiceProperties
			.getBindingDestination(outputName);
	Binder<T, ?, ProducerProperties> binder = (Binder<T, ?, ProducerProperties>) getBinder(
			outputName, output.getClass());
	ProducerProperties producerProperties = this.bindingServiceProperties
			.getProducerProperties(outputName);
	if (binder instanceof ExtendedPropertiesBinder) {
		Object extension = ((ExtendedPropertiesBinder) binder)
				.getExtendedProducerProperties(outputName);
		ExtendedProducerProperties extendedProducerProperties = new ExtendedProducerProperties<>(
				extension);
		BeanUtils.copyProperties(producerProperties, extendedProducerProperties);
		producerProperties = extendedProducerProperties;
	}
	validate(producerProperties);
	Binding<T> binding = doBindProducer(output, bindingTarget, binder, producerProperties);
	this.producerBindings.put(outputName, binding);
	return binding;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:22,代码来源:BindingService.java

示例14: createProducerProperties

import org.springframework.cloud.stream.binder.ExtendedProducerProperties; //导入依赖的package包/类
@Override
protected ExtendedProducerProperties<KinesisProducerProperties> createProducerProperties() {
	ExtendedProducerProperties<KinesisProducerProperties> producerProperties = new ExtendedProducerProperties<>(
			new KinesisProducerProperties());
	producerProperties.setPartitionKeyExpression(new LiteralExpression("1"));
	producerProperties.getExtension().setSync(true);
	return producerProperties;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-aws-kinesis,代码行数:9,代码来源:KinesisBinderTests.java

示例15: provisionProducerDestination

import org.springframework.cloud.stream.binder.ExtendedProducerProperties; //导入依赖的package包/类
@Override
public ProducerDestination provisionProducerDestination(String name,
		ExtendedProducerProperties<KinesisProducerProperties> properties) throws ProvisioningException {

	if (logger.isInfoEnabled()) {
		logger.info("Using Kinesis stream for outbound: " + name);
	}

	if (properties.getHeaderMode() == null) {
		properties.setHeaderMode(HeaderMode.embeddedHeaders);
	}

	return new KinesisProducerDestination(name, createOrUpdate(name, properties.getPartitionCount()));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-aws-kinesis,代码行数:15,代码来源:KinesisStreamProvisioner.java


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