本文整理汇总了Java中org.springframework.cloud.stream.binder.ExtendedProducerProperties.setRequiredGroups方法的典型用法代码示例。如果您正苦于以下问题:Java ExtendedProducerProperties.setRequiredGroups方法的具体用法?Java ExtendedProducerProperties.setRequiredGroups怎么用?Java ExtendedProducerProperties.setRequiredGroups使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.cloud.stream.binder.ExtendedProducerProperties
的用法示例。
在下文中一共展示了ExtendedProducerProperties.setRequiredGroups方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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
示例2: 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
示例3: testTwoRequiredGroups
import org.springframework.cloud.stream.binder.ExtendedProducerProperties; //导入方法依赖的package包/类
@Test
@Override
@SuppressWarnings("unchecked")
public void testTwoRequiredGroups() throws Exception {
Binder binder = getBinder();
ExtendedProducerProperties<KafkaProducerProperties> producerProperties = createProducerProperties();
DirectChannel output = createBindableChannel("output", createProducerBindingProperties(producerProperties));
String testDestination = "testDestination" + UUID.randomUUID().toString().replace("-", "");
producerProperties.setRequiredGroups("test1", "test2");
Binding<MessageChannel> producerBinding = binder.bindProducer(testDestination, output, producerProperties);
String testPayload = "foo-" + UUID.randomUUID().toString();
output.send(new GenericMessage<>(testPayload.getBytes()));
QueueChannel inbound1 = new QueueChannel();
ExtendedConsumerProperties<KafkaConsumerProperties> consumerProperties = createConsumerProperties();
consumerProperties.getExtension().setAutoRebalanceEnabled(false);
Binding<MessageChannel> consumerBinding1 = binder.bindConsumer(testDestination, "test1", inbound1,
consumerProperties);
QueueChannel inbound2 = new QueueChannel();
Binding<MessageChannel> consumerBinding2 = binder.bindConsumer(testDestination, "test2", inbound2,
consumerProperties);
Message<?> receivedMessage1 = receive(inbound1);
assertThat(receivedMessage1).isNotNull();
assertThat(new String((byte[]) receivedMessage1.getPayload(), StandardCharsets.UTF_8)).isEqualTo(testPayload);
Message<?> receivedMessage2 = receive(inbound2);
assertThat(receivedMessage2).isNotNull();
assertThat(new String((byte[]) receivedMessage2.getPayload(), StandardCharsets.UTF_8)).isEqualTo(testPayload);
consumerBinding1.unbind();
consumerBinding2.unbind();
producerBinding.unbind();
}
示例4: testBatchingAndCompression
import org.springframework.cloud.stream.binder.ExtendedProducerProperties; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testBatchingAndCompression() throws Exception {
RabbitTestBinder binder = getBinder();
ExtendedProducerProperties<RabbitProducerProperties> producerProperties = createProducerProperties();
producerProperties.getExtension().setDeliveryMode(MessageDeliveryMode.NON_PERSISTENT);
producerProperties.getExtension().setBatchingEnabled(true);
producerProperties.getExtension().setBatchSize(2);
producerProperties.getExtension().setBatchBufferLimit(100000);
producerProperties.getExtension().setBatchTimeout(30000);
producerProperties.getExtension().setCompress(true);
producerProperties.setRequiredGroups("default");
DirectChannel output = createBindableChannel("output", createProducerBindingProperties(producerProperties));
output.setBeanName("batchingProducer");
Binding<MessageChannel> producerBinding = binder.bindProducer("batching.0", output, producerProperties);
Log logger = spy(TestUtils.getPropertyValue(binder, "binder.compressingPostProcessor.logger", Log.class));
new DirectFieldAccessor(TestUtils.getPropertyValue(binder, "binder.compressingPostProcessor"))
.setPropertyValue("logger", logger);
when(logger.isTraceEnabled()).thenReturn(true);
assertThat(TestUtils.getPropertyValue(binder, "binder.compressingPostProcessor.level"))
.isEqualTo(Deflater.BEST_SPEED);
output.send(new GenericMessage<>("foo".getBytes()));
output.send(new GenericMessage<>("bar".getBytes()));
Object out = spyOn("batching.0.default").receive(false);
assertThat(out).isInstanceOf(byte[].class);
assertThat(new String((byte[]) out)).isEqualTo("\u0000\u0000\u0000\u0003foo\u0000\u0000\u0000\u0003bar");
ArgumentCaptor<Object> captor = ArgumentCaptor.forClass(Object.class);
verify(logger).trace(captor.capture());
assertThat(captor.getValue().toString()).contains(("Compressed 14 to "));
QueueChannel input = new QueueChannel();
input.setBeanName("batchingConsumer");
Binding<MessageChannel> consumerBinding = binder.bindConsumer("batching.0", "test", input,
createConsumerProperties());
output.send(new GenericMessage<>("foo".getBytes()));
output.send(new GenericMessage<>("bar".getBytes()));
Message<byte[]> in = (Message<byte[]>) input.receive(10000);
assertThat(in).isNotNull();
assertThat(new String(in.getPayload())).isEqualTo("foo");
in = (Message<byte[]>) input.receive(10000);
assertThat(in).isNotNull();
assertThat(new String(in.getPayload())).isEqualTo("bar");
assertThat(in.getHeaders().get(AmqpHeaders.DELIVERY_MODE)).isNull();
producerBinding.unbind();
consumerBinding.unbind();
}