本文整理汇总了Java中org.springframework.cloud.stream.binder.ExtendedProducerProperties类的典型用法代码示例。如果您正苦于以下问题:Java ExtendedProducerProperties类的具体用法?Java ExtendedProducerProperties怎么用?Java ExtendedProducerProperties使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExtendedProducerProperties类属于org.springframework.cloud.stream.binder包,在下文中一共展示了ExtendedProducerProperties类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: testProvisionProducerSuccessfulWithNewStream
import org.springframework.cloud.stream.binder.ExtendedProducerProperties; //导入依赖的package包/类
@Test
public void testProvisionProducerSuccessfulWithNewStream() {
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";
Integer shards = 1;
DescribeStreamResult describeStreamResult =
describeStreamResultWithShards(Collections.singletonList(new Shard()));
when(amazonKinesisMock.describeStream(any(DescribeStreamRequest.class)))
.thenThrow(new ResourceNotFoundException("I got nothing"))
.thenReturn(describeStreamResult);
when(amazonKinesisMock.createStream(name, shards))
.thenReturn(new CreateStreamResult());
ProducerDestination destination = provisioner.provisionProducerDestination(name, extendedProducerProperties);
verify(amazonKinesisMock, times(2))
.describeStream(any(DescribeStreamRequest.class));
verify(amazonKinesisMock)
.createStream(name, shards);
assertThat(destination.getName()).isEqualTo(name);
}
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-aws-kinesis,代码行数:32,代码来源:KinesisStreamProvisionerTests.java
示例17: createProducerMessageHandler
import org.springframework.cloud.stream.binder.ExtendedProducerProperties; //导入依赖的package包/类
@Override
protected MessageHandler createProducerMessageHandler(ProducerDestination destination,
ExtendedProducerProperties<PubSubProducerProperties> producerProperties,
MessageChannel errorChannel) throws Exception {
this.provisioningProvider.provisionProducerDestination(
destination.getName(), producerProperties);
return new PubSubMessageHandler(this.pubSubTemplate, destination.getName());
}
开发者ID:spring-cloud,项目名称:spring-cloud-gcp,代码行数:11,代码来源:PubSubMessageChannelBinder.java
示例18: provisionProducerDestination
import org.springframework.cloud.stream.binder.ExtendedProducerProperties; //导入依赖的package包/类
@Override
public ProducerDestination provisionProducerDestination(String name,
ExtendedProducerProperties<PubSubProducerProperties> properties)
throws ProvisioningException {
if (this.pubSubAdmin.getTopic(name) == null) {
this.pubSubAdmin.createTopic(name);
}
return new PubSubProducerDestination(name);
}
开发者ID:spring-cloud,项目名称:spring-cloud-gcp,代码行数:11,代码来源:PubSubChannelProvisioner.java
示例19: provisionProducerDestination
import org.springframework.cloud.stream.binder.ExtendedProducerProperties; //导入依赖的package包/类
@Override
public ProducerDestination provisionProducerDestination(String name,
ExtendedProducerProperties<JmsProducerProperties> properties) throws ProvisioningException {
logger.info("Provisioning producer destination: '{}'", name);
Collection<DestinationNames> topicAndQueueNames = this.destinationNameResolver
.resolveTopicAndQueueNameForRequiredGroups(name, properties);
final Map<Integer, Topic> partitionTopics = new HashMap<>();
for (DestinationNames destinationNames : topicAndQueueNames) {
String sanitisedTopicName = sanitiseObjectName(destinationNames.getTopicName());
Topic topic = ibmMQRequests.createTopic(sanitisedTopicName);
for (String queue : destinationNames.getGroupNames()) {
// format for the subscribing queue name is: 'topic'.'queue'
String sanitisedQueueName = sanitiseObjectName(String.format("%s.%s", sanitisedTopicName, queue));
ibmMQRequests.createQueue(sanitisedQueueName);
ibmMQRequests.subcribeQueueToTopic(sanitisedTopicName, sanitisedQueueName);
}
if (destinationNames.getPartitionIndex() != null) {
partitionTopics.put(destinationNames.getPartitionIndex(), topic);
}
else {
partitionTopics.put(-1, topic);
}
}
return new JmsProducerDestination(partitionTopics);
}
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-ibm-mq,代码行数:31,代码来源:IBMMQProvisioningProvider.java
示例20: KafkaMessageChannelBinder
import org.springframework.cloud.stream.binder.ExtendedProducerProperties; //导入依赖的package包/类
public KafkaMessageChannelBinder(KafkaBinderConfigurationProperties configurationProperties,
KafkaTopicProvisioner provisioningProvider) {
super(headersToMap(configurationProperties), provisioningProvider);
this.configurationProperties = configurationProperties;
if (StringUtils.hasText(configurationProperties.getTransaction().getTransactionIdPrefix())) {
this.transactionManager = new KafkaTransactionManager<>(
getProducerFactory(configurationProperties.getTransaction().getTransactionIdPrefix(),
new ExtendedProducerProperties<>(configurationProperties.getTransaction().getProducer())));
this.transactionTemplate = new TransactionTemplate(this.transactionManager);
}
else {
this.transactionManager = null;
this.transactionTemplate = null;
}
}
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-kafka,代码行数:16,代码来源:KafkaMessageChannelBinder.java
注:本文中的org.springframework.cloud.stream.binder.ExtendedProducerProperties类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论