consumer type
27 | * @param producer type
28 | * @author Marius Bogoevici
29 | */
30 | public interface ExtendedPropertiesBinder
31 | extends Binder, ExtendedProducerProperties>,
32 | ExtendedBindingProperties {
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/HeaderMode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2020 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.binder;
18 |
19 | /**
20 | * @author Marius Bogoevici
21 | * @author Gary Russell
22 | */
23 | public enum HeaderMode {
24 |
25 | /**
26 | * No headers.
27 | */
28 | none,
29 |
30 | /**
31 | * Native headers.
32 | */
33 | headers,
34 |
35 | /**
36 | * Headers embedded in payload - e.g. kafka < 0.11
37 | */
38 | embeddedHeaders
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/LastSubscriberAwareChannel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.binder;
18 |
19 | import org.springframework.messaging.SubscribableChannel;
20 |
21 | /**
22 | * A channel that can ensure a {@code LastSubscriberMessageHandler} is always the last
23 | * subscriber.
24 | *
25 | * @author Gary Russell
26 | * @since 1.3
27 | *
28 | */
29 | interface LastSubscriberAwareChannel extends SubscribableChannel {
30 |
31 | /**
32 | * Return the current subscribers.
33 | * @return the subscribers.
34 | */
35 | int subscribers();
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/LastSubscriberMessageHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.binder;
18 |
19 | import org.springframework.messaging.MessageHandler;
20 |
21 | /**
22 | * A marker interface designating a subscriber that must be the last.
23 | *
24 | * @author Gary Russell
25 | * @since 1.3
26 | *
27 | */
28 | public interface LastSubscriberMessageHandler extends MessageHandler {
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/PartitionKeyExtractorStrategy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.binder;
18 |
19 | import org.springframework.messaging.Message;
20 |
21 | /**
22 | * Strategy for extracting a partition key from a Message.
23 | *
24 | * @author Gary Russell
25 | */
26 | public interface PartitionKeyExtractorStrategy {
27 |
28 | Object extractKey(Message> message);
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/PartitionSelectorStrategy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.binder;
18 |
19 | /**
20 | * Strategy for determining the partition to which a message should be sent.
21 | *
22 | * @author Gary Russell
23 | */
24 | public interface PartitionSelectorStrategy {
25 |
26 | /**
27 | * Determine the partition based on a key. The partitionCount is 1 greater than the
28 | * maximum value of a valid partition. Typical implementations will return
29 | * {@code someValue % partitionCount}. The caller will apply that same modulo
30 | * operation (as well as enforcing absolute value) if the value exceeds partitionCount
31 | * - 1.
32 | * @param key the key
33 | * @param partitionCount the number of partitions
34 | * @return the partition
35 | */
36 | int selectPartition(Object key, int partitionCount);
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/PollableMessageSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.binder;
18 |
19 | import org.springframework.messaging.MessageHandler;
20 |
21 | /**
22 | * A {@link PollableSource} that calls a {@link MessageHandler} with a
23 | * {@link org.springframework.messaging.Message}.
24 | *
25 | * @author Gary Russell
26 | * @since 2.0
27 | *
28 | */
29 | public interface PollableMessageSource extends PollableSource {
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/BoundTargetHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2024 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.binding;
18 |
19 | /**
20 | * Holds information about the binding targets exposed by the interface proxy, as well
21 | * as their status.
22 | *
23 | * Refactored from {@link BindableProxyFactory}.
24 | *
25 | * @author Original authors in {@link BindableProxyFactory}
26 | * @author Soby Chacko
27 | * @author Omer Celik
28 | * @since 3.0.0
29 | */
30 | public record BoundTargetHolder(Object boundTarget, boolean bindable) {
31 | }
32 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/MessageChannelAndSourceConfigurer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.binding;
18 |
19 | import org.springframework.cloud.stream.binder.PollableMessageSource;
20 |
21 | /**
22 | * Configurer for {@link PollableMessageSource}.
23 | *
24 | * @author Gary Russell
25 | * @since 2.0
26 | *
27 | */
28 | public interface MessageChannelAndSourceConfigurer extends MessageChannelConfigurer {
29 |
30 | /**
31 | * Configure the provided message source binding.
32 | * @param binding the binding.
33 | * @param name the name.
34 | */
35 | void configurePolledMessageSource(PollableMessageSource binding, String name);
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/SupportedBindableFeatures.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.binding;
18 |
19 | /**
20 | * Internal abstraction for the supported bindable features.
21 | *
22 | * @author Soby Chacko
23 | * @since 4.0.0
24 | */
25 | public class SupportedBindableFeatures {
26 |
27 | private boolean pollable;
28 |
29 | private boolean reactive;
30 |
31 | public void setPollable(boolean pollable) {
32 | this.pollable = pollable;
33 | }
34 |
35 | public void setReactive(boolean reactive) {
36 | this.reactive = reactive;
37 | }
38 |
39 | public boolean isPollable() {
40 | return pollable;
41 | }
42 |
43 | public boolean isReactive() {
44 | return reactive;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/converter/ConversionException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.converter;
18 |
19 | /**
20 | * Exception thrown when an error is encountered during message conversion.
21 | *
22 | * @author David Turanski
23 | */
24 | @SuppressWarnings("serial")
25 | public class ConversionException extends RuntimeException {
26 |
27 | public ConversionException(String message) {
28 | super(message);
29 | }
30 |
31 | public ConversionException(String message, Throwable t) {
32 | super(message, t);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/converter/CustomMimeTypeConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2018 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.converter;
18 |
19 | import org.springframework.core.convert.converter.Converter;
20 | import org.springframework.util.MimeType;
21 |
22 | /**
23 | * A custom converter for {@link MimeType} that accepts a plain java class name as a
24 | * shorthand for {@code application/x-java-object;type=the.qualified.ClassName}.
25 | *
26 | * @author Eric Bottard
27 | * @author David Turanski
28 | */
29 | public class CustomMimeTypeConverter implements Converter {
30 |
31 | @Override
32 | public MimeType convert(String source) {
33 | if (!source.contains("/")) {
34 | return MimeType.valueOf("application/x-java-object;type=" + source);
35 | }
36 | return MimeType.valueOf(source);
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/function/StreamFunctionConfigurationProperties.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2023 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.function;
18 |
19 | import java.util.HashMap;
20 | import java.util.Map;
21 |
22 | import org.springframework.boot.context.properties.ConfigurationProperties;
23 |
24 | /**
25 | * @author Oleg Zhurakousky
26 | * @author Soby Chacko
27 | * @since 4.0.2
28 | */
29 | @ConfigurationProperties("spring.cloud.stream.function")
30 | public class StreamFunctionConfigurationProperties {
31 | private Map bindings = new HashMap<>();
32 |
33 | public Map getBindings() {
34 | return this.bindings;
35 | }
36 |
37 | public void setBindings(Map bindings) {
38 | this.bindings = bindings;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/provisioning/ConsumerDestination.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.provisioning;
18 |
19 | import org.springframework.cloud.stream.binder.ConsumerProperties;
20 |
21 | /**
22 | * Represents a ConsumerDestination that provides the information about the destination
23 | * that is physically provisioned through
24 | * {@link ProvisioningProvider#provisionConsumerDestination(String, String, ConsumerProperties)}.
25 | *
26 | * @author Soby Chacko
27 | * @since 1.2
28 | */
29 | public interface ConsumerDestination {
30 |
31 | /**
32 | * Provides the destination name.
33 | * @return destination name
34 | */
35 | String getName();
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/main/resources/META-INF/shared.beans:
--------------------------------------------------------------------------------
1 | org.springframework.boot.autoconfigure.amqp.ConnectionFactoryCustomizer
2 | org.springframework.boot.autoconfigure.kafka.KafkaConnectionDetails
3 | org.springframework.boot.autoconfigure.kafka.StreamsBuilderFactoryBeanCustomizer
4 | org.springframework.cloud.stream.config.SpelExpressionConverterConfiguration$SpelConverter
5 | org.springframework.cloud.stream.config.ListenerContainerCustomizer
6 | org.springframework.cloud.stream.binder.kafka.ListenerContainerWithDlqAndRetryCustomizer
7 | org.springframework.cloud.stream.binder.kafka.support.ConsumerConfigCustomizer
8 | org.springframework.cloud.stream.binder.kafka.support.ProducerConfigCustomizer
9 | org.springframework.cloud.stream.binder.kafka.provisioning.AdminClientConfigCustomizer
10 | org.springframework.kafka.config.KafkaStreamsCustomizer
11 | org.springframework.rabbit.stream.listener.ConsumerCustomizer
12 | org.springframework.amqp.core.DeclarableCustomizer
13 | org.springframework.cloud.stream.config.ProducerMessageHandlerCustomizer
14 | org.springframework.cloud.stream.binder.test.InputDestination
15 | org.springframework.cloud.stream.binder.test.OutputDestination
16 | org.springframework.cloud.stream.config.BindingHandlerAdvise
17 | io.micrometer.observation.ObservationRegistry
18 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/main/resources/META-INF/spring.factories:
--------------------------------------------------------------------------------
1 | org.springframework.boot.env.EnvironmentPostProcessor:\
2 | org.springframework.cloud.stream.function.RoutingFunctionEnvironmentPostProcessor,\
3 | org.springframework.cloud.stream.config.VersionExtractor,\
4 | org.springframework.cloud.stream.config.PollerConfigEnvironmentPostProcessor
5 | org.springframework.context.ApplicationContextInitializer:\
6 | org.springframework.cloud.stream.function.PollableSourceInitializer
7 |
8 |
9 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/main/resources/META-INF/spring/aot.factories:
--------------------------------------------------------------------------------
1 | org.springframework.aot.hint.RuntimeHintsRegistrar=org.springframework.cloud.stream.aot.StreamRuntimeHints
2 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports:
--------------------------------------------------------------------------------
1 | org.springframework.cloud.stream.config.BindersHealthIndicatorAutoConfiguration
2 | org.springframework.cloud.stream.config.ChannelsEndpointAutoConfiguration
3 | org.springframework.cloud.stream.config.BindingsEndpointAutoConfiguration
4 | org.springframework.cloud.stream.config.BindingServiceConfiguration
5 | org.springframework.cloud.stream.function.FunctionConfiguration
6 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/main/resources/banner.txt:
--------------------------------------------------------------------------------
1 | . ____ _ __ _ _
2 | /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
3 | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
4 | \\/ ___)| |_)| | | | | || (_| | ) ) ) )
5 | ' |____| .__|_| |_|_| |_\__, | / / / /
6 | =========|_|==============|___/=/_/_/_/
7 |
8 | :: Spring Boot :: v${spring-boot.version}
9 | :: Spring Cloud Stream :: v${spring-cloud-stream.version}
10 | :: Spring Cloud Function :: v${spring-cloud-function.version}
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/partitioning/CustomPartitionKeyExtractorClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.partitioning;
18 |
19 | import org.springframework.cloud.stream.binder.PartitionKeyExtractorStrategy;
20 | import org.springframework.messaging.Message;
21 |
22 | /**
23 | * @author Ilayaperumal Gopinathan
24 | */
25 | public class CustomPartitionKeyExtractorClass implements PartitionKeyExtractorStrategy {
26 |
27 | @Override
28 | public String extractKey(Message> message) {
29 | return (String) message.getHeaders().get("key");
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/partitioning/CustomPartitionSelectorClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.partitioning;
18 |
19 | import org.springframework.cloud.stream.binder.PartitionSelectorStrategy;
20 |
21 | /**
22 | * @author Ilayaperumal Gopinathan
23 | */
24 | public class CustomPartitionSelectorClass implements PartitionSelectorStrategy {
25 |
26 | @Override
27 | public int selectPartition(Object key, int partitionCount) {
28 | return Integer.valueOf((String) key);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/utils/FooBindingProperties.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.utils;
18 |
19 | import org.springframework.cloud.stream.binder.BinderSpecificPropertiesProvider;
20 |
21 | /**
22 | * @author Soby Chacko
23 | */
24 | public class FooBindingProperties implements BinderSpecificPropertiesProvider {
25 |
26 | private FooProducerProperties producer = new FooProducerProperties();
27 |
28 | private FooConsumerProperties consumer = new FooConsumerProperties();
29 |
30 | public FooProducerProperties getProducer() {
31 | return this.producer;
32 | }
33 |
34 | public void setProducer(FooProducerProperties producer) {
35 | this.producer = producer;
36 | }
37 |
38 | public FooConsumerProperties getConsumer() {
39 | return this.consumer;
40 | }
41 |
42 | public void setConsumer(FooConsumerProperties consumer) {
43 | this.consumer = consumer;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/utils/FooConsumerProperties.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.utils;
18 |
19 | /**
20 | * @author Soby Chacko
21 | */
22 | public class FooConsumerProperties {
23 |
24 | String extendedProperty;
25 |
26 | public String getExtendedProperty() {
27 | return this.extendedProperty;
28 | }
29 |
30 | public void setExtendedProperty(String extendedProperty) {
31 | this.extendedProperty = extendedProperty;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/utils/FooProducerProperties.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.utils;
18 |
19 | /**
20 | * @author Soby Chacko
21 | */
22 | public class FooProducerProperties {
23 |
24 | String extendedProperty;
25 |
26 | public String getExtendedProperty() {
27 | return this.extendedProperty;
28 | }
29 |
30 | public void setExtendedProperty(String extendedProperty) {
31 | this.extendedProperty = extendedProperty;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/utils/MockBinderConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.utils;
18 |
19 | import org.mockito.Mockito;
20 |
21 | import org.springframework.cloud.stream.binder.Binder;
22 | import org.springframework.context.annotation.Bean;
23 | import org.springframework.context.annotation.Configuration;
24 |
25 | /**
26 | * @author Marius Bogoevici
27 | */
28 | @Configuration
29 | public class MockBinderConfiguration {
30 |
31 | @Bean
32 | public Binder, ?, ?> binder() {
33 | return Mockito.mock(Binder.class,
34 | Mockito.withSettings().defaultAnswer(Mockito.RETURNS_MOCKS));
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/test/resources/META-INF/spring.binders:
--------------------------------------------------------------------------------
1 | mock:\
2 | org.springframework.cloud.stream.utils.MockBinderConfiguration
3 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/test/resources/application.yml:
--------------------------------------------------------------------------------
1 | expression: a.b
2 | numberExpression: 5
3 | booleanExpression: true
4 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/test/resources/binder-aot-test/application.yml:
--------------------------------------------------------------------------------
1 | spring.cloud:
2 | function:
3 | definition: fooSource;fooSink
4 | stream:
5 | default-binder: mockBinder1
6 | binders:
7 | mockBinder1:
8 | type: mock
9 | environment:
10 | foo: bar1
11 | mockBinder2:
12 | type: mock
13 | environment:
14 | foo: bar2
15 | bindings:
16 | fooSource-out-0:
17 | destination: fooSink-in-0
18 | binder: mockBinder2
19 | fooSink-in-0:
20 | destination: fooSource-out-0
21 | binder: mockBinder2
22 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/test/resources/binder1/META-INF/spring.binders:
--------------------------------------------------------------------------------
1 | binder1=org.springframework.cloud.stream.binder.stub1.StubBinder1Configuration
2 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/test/resources/binder2/META-INF/spring.binders:
--------------------------------------------------------------------------------
1 | binder2:\
2 | org.springframework.cloud.stream.binder.stub2.StubBinder2ConfigurationA,\
3 | org.springframework.cloud.stream.binder.stub2.StubBinder2ConfigurationB
4 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/test/resources/org/springframework/cloud/stream/binder/arbitrary-binding-test.properties:
--------------------------------------------------------------------------------
1 | spring.cloud.stream.bindings.process1-in-0.destination=someQueue.0
2 | spring.cloud.stream.bindings.process1-out-0.destination=someQueue.1
3 | spring.cloud.stream.bindings.process2-in-0.destination=someQueue.2
4 | spring.cloud.stream.bindings.process2-out-0.destination=someQueue.3
5 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/test/resources/org/springframework/cloud/stream/binder/cloud-function-test.properties:
--------------------------------------------------------------------------------
1 | spring.cloud.stream.function.producerProperties.useNativeEncoding:true
2 | spring.cloud.stream.function.consumerProperties.maxAttempts:5
3 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/test/resources/org/springframework/cloud/stream/binder/custom-partitioned-producer-test.properties:
--------------------------------------------------------------------------------
1 | spring.cloud.stream.bindings.output.destination=partOut
2 | spring.cloud.stream.bindings.output.producer.partitionCount=3
3 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/test/resources/org/springframework/cloud/stream/binder/partitioned-consumer-test.properties:
--------------------------------------------------------------------------------
1 | spring.cloud.stream.bindings.sink-in-0.destination=partIn
2 | spring.cloud.stream.bindings.sink-in-0.consumer.partitioned=true
3 | spring.cloud.stream.instanceCount=2
4 | spring.cloud.stream.instanceIndex=0
5 |
6 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/test/resources/org/springframework/cloud/stream/binder/partitioned-producer-test.properties:
--------------------------------------------------------------------------------
1 | spring.cloud.stream.bindings.output.destination=partOut
2 | spring.cloud.stream.bindings.output.producer.partitionKeyExpression=payload
3 | spring.cloud.stream.bindings.output.producer.partitionCount=3
4 |
5 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/test/resources/org/springframework/cloud/stream/binder/processor-binding-test.properties:
--------------------------------------------------------------------------------
1 | spring.cloud.stream.bindings.input.destination=testtock.0
2 | spring.cloud.stream.bindings.output.destination=testtock.1
3 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/test/resources/org/springframework/cloud/stream/binder/sink-binding-test.properties:
--------------------------------------------------------------------------------
1 | spring.cloud.stream.bindings.input.destination=testtock
2 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/src/test/resources/org/springframework/cloud/stream/binder/source-binding-test.properties:
--------------------------------------------------------------------------------
1 | spring.cloud.stream.bindings.output.destination=testtock
2 |
--------------------------------------------------------------------------------
/core/spring-cloud-stream/work.txt:
--------------------------------------------------------------------------------
1 | - MetersPublisherBinding uses Output. Need to rework
--------------------------------------------------------------------------------
/docs/.jdk8:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/.jdk8
--------------------------------------------------------------------------------
/docs/antora-playbook.yml:
--------------------------------------------------------------------------------
1 | antora:
2 | extensions:
3 | - require: '@springio/antora-extensions'
4 | root_component_name: 'cloud-stream'
5 | site:
6 | title: Spring Cloud Stream
7 | url: https://docs.spring.io/spring-cloud-stream/reference/
8 | content:
9 | sources:
10 | - url: ./..
11 | branches: HEAD
12 | start_path: docs
13 | worktrees: true
14 | asciidoc:
15 | attributes:
16 | page-stackoverflow-url: https://stackoverflow.com/tags/spring-cloud
17 | page-pagination: ''
18 | hide-uri-scheme: '@'
19 | tabs-sync-option: '@'
20 | chomp: 'all'
21 | extensions:
22 | - '@asciidoctor/tabs'
23 | - '@springio/asciidoctor-extensions'
24 | sourcemap: true
25 | urls:
26 | latest_version_segment: ''
27 | runtime:
28 | log:
29 | failure_level: warn
30 | format: pretty
31 | ui:
32 | bundle:
33 | url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.4.15/ui-bundle.zip
34 |
--------------------------------------------------------------------------------
/docs/antora.yml:
--------------------------------------------------------------------------------
1 | name: cloud-stream
2 | version: true
3 | title: spring-cloud-stream
4 | nav:
5 | - modules/ROOT/nav.adoc
6 | ext:
7 | collector:
8 | run:
9 | command: ./mvnw --no-transfer-progress -B process-resources -Pdocs -pl docs -Dantora-maven-plugin.phase=none -Dgenerate-docs.phase=none -Dgenerate-readme.phase=none -Dgenerate-cloud-resources.phase=none -Dmaven-dependency-plugin-for-docs.phase=none -Dmaven-dependency-plugin-for-docs-classes.phase=none -DskipTests
10 | local: true
11 | scan:
12 | dir: ./target/classes/antora-resources/
13 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/assets/images/SCSt-groups.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/modules/ROOT/assets/images/SCSt-groups.png
--------------------------------------------------------------------------------
/docs/modules/ROOT/assets/images/SCSt-overview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/modules/ROOT/assets/images/SCSt-overview.png
--------------------------------------------------------------------------------
/docs/modules/ROOT/assets/images/SCSt-partitioning.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/modules/ROOT/assets/images/SCSt-partitioning.png
--------------------------------------------------------------------------------
/docs/modules/ROOT/assets/images/SCSt-sensors.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/modules/ROOT/assets/images/SCSt-sensors.png
--------------------------------------------------------------------------------
/docs/modules/ROOT/assets/images/SCSt-with-binder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/modules/ROOT/assets/images/SCSt-with-binder.png
--------------------------------------------------------------------------------
/docs/modules/ROOT/assets/images/custom_vs_global_error_channels.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/modules/ROOT/assets/images/custom_vs_global_error_channels.png
--------------------------------------------------------------------------------
/docs/modules/ROOT/assets/images/part-bindings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/modules/ROOT/assets/images/part-bindings.png
--------------------------------------------------------------------------------
/docs/modules/ROOT/assets/images/part-exchange.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/modules/ROOT/assets/images/part-exchange.png
--------------------------------------------------------------------------------
/docs/modules/ROOT/assets/images/part-queues.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/modules/ROOT/assets/images/part-queues.png
--------------------------------------------------------------------------------
/docs/modules/ROOT/assets/images/producers-consumers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/modules/ROOT/assets/images/producers-consumers.png
--------------------------------------------------------------------------------
/docs/modules/ROOT/assets/images/redis-binder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/modules/ROOT/assets/images/redis-binder.png
--------------------------------------------------------------------------------
/docs/modules/ROOT/assets/images/registration.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/modules/ROOT/assets/images/registration.png
--------------------------------------------------------------------------------
/docs/modules/ROOT/assets/images/schema_reading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/modules/ROOT/assets/images/schema_reading.png
--------------------------------------------------------------------------------
/docs/modules/ROOT/assets/images/schema_resolution.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/modules/ROOT/assets/images/schema_resolution.png
--------------------------------------------------------------------------------
/docs/modules/ROOT/assets/images/spring-initializr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/modules/ROOT/assets/images/spring-initializr.png
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/README.adoc:
--------------------------------------------------------------------------------
1 | :jdkversion: 17
2 | :github-tag: master
3 | :github-repo: spring-cloud/spring-cloud-stream
4 |
5 | :github-raw: https://raw.githubusercontent.com/{github-repo}/{github-tag}
6 | :github-code: https://github.com/{github-repo}/tree/{github-tag}
7 |
8 | image::https://circleci.com/gh/spring-cloud/spring-cloud-stream.svg?style=svg["CircleCI", link="https://circleci.com/gh/spring-cloud/spring-cloud-stream"]
9 | image::https://codecov.io/gh/spring-cloud/spring-cloud-stream/branch/{github-tag}/graph/badge.svg["codecov", link="https://codecov.io/gh/spring-cloud/spring-cloud-stream"]
10 |
11 | // ======================================================================================
12 |
13 | [[introduction]]
14 | == Introduction
15 |
16 |
17 | [[resources]]
18 | == Resources
19 |
20 | For more information, please visit the https://spring.io/projects/spring-cloud-stream[project website].
21 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/binders.adoc:
--------------------------------------------------------------------------------
1 |
2 | [[binders]]
3 | == Binder Implementations
4 | :page-section-summary-toc: 1
5 |
6 | The following binder implementations are available:
7 |
8 | * https://cloud.spring.io/spring-cloud-stream-binder-rabbit/[RabbitMQ]
9 | * https://cloud.spring.io/spring-cloud-stream-binder-kafka/[Apache Kafka]
10 | * https://github.com/spring-cloud/spring-cloud-stream-binder-aws-kinesis[Amazon Kinesis]
11 | * https://github.com/spring-cloud/spring-cloud-gcp/tree/master/spring-cloud-gcp-pubsub-stream-binder[Google PubSub _(partner maintained)_]
12 | * https://github.com/SolaceProducts/solace-spring-cloud/tree/master/solace-spring-cloud-starters/solace-spring-cloud-stream-starter#spring-cloud-stream-binder-for-solace-pubsub[Solace PubSub+ _(partner maintained)_]
13 | * https://aka.ms/spring/docs#spring-cloud-stream-binder-for-azure-event-hubs[Azure Event Hubs _(partner maintained)_]
14 | * https://aka.ms/spring/docs#spring-cloud-stream-binder-for-azure-service-bus[Azure Service Bus Binder _(partner maintained)_]
15 | * https://github.com/alibaba/spring-cloud-alibaba/wiki/RocketMQ-en[Apache RocketMQ _(partner maintained)_]
16 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/configprops.adoc:
--------------------------------------------------------------------------------
1 | [[configuration-properties]]
2 | = Configuration Properties
3 |
4 | Below you can find a list of configuration properties.
5 |
6 |
7 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/kafka/kafka-binder/admin-client-config-cust.adoc:
--------------------------------------------------------------------------------
1 | [[admin-client-config-customization]]
2 | = Customizing AdminClient Configuration
3 |
4 | As with consumer and producer config customization above, applications can also customize the configuration for admin clients by providing an `AdminClientConfigCustomizer`.
5 | AdminClientConfigCustomizer's configure method provides access to the admin client properties, using which you can define further customization.
6 | Binder's Kafka topic provisioner gives the highest precedence for the properties given through this customizer.
7 | Here is an example of providing this customizer bean.
8 |
9 | ```
10 | @Bean
11 | public AdminClientConfigCustomizer adminClientConfigCustomizer() {
12 | return props -> {
13 | props.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "SASL_SSL");
14 | };
15 | }
16 | ```
17 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/kafka/kafka-binder/cons-prod-config-cust.adoc:
--------------------------------------------------------------------------------
1 | [[consumer-producer-config-customizer]]
2 | = Customizing Consumer and Producer configuration
3 |
4 | If you want advanced customization of consumer and producer configuration that is used for creating `ConsumerFactory` and `ProducerFactory` in Kafka,
5 | you can implement the following customizers.
6 |
7 | * ConsumerConfigCustomizer
8 | * ProducerConfigCustomizer
9 |
10 | Both of these interfaces provide a way to configure the config map used for consumer and producer properties.
11 | For example, if you want to gain access to a bean that is defined at the application level, you can inject that in the implementation of the `configure` method.
12 | When the binder discovers that these customizers are available as beans, it will invoke the `configure` method right before creating the consumer and producer factories.
13 |
14 | Both of these interfaces also provide access to both the binding and destination names so that they can be accessed while customizing producer and consumer properties.
15 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/kafka/kafka-binder/error-channels.adoc:
--------------------------------------------------------------------------------
1 | [[kafka-error-channels]]
2 | = Error Channels
3 |
4 | Starting with version 1.3, the binder unconditionally sends exceptions to an error channel for each consumer destination and can also be configured to send async producer send failures to an error channel.
5 | See xref:spring-cloud-stream/overview-error-handling.adoc[this section on error handling] for more information.
6 |
7 | The payload of the `ErrorMessage` for a send failure is a `KafkaSendFailureException` with properties:
8 |
9 | * `failedMessage`: The Spring Messaging `Message>` that failed to be sent.
10 | * `record`: The raw `ProducerRecord` that was created from the `failedMessage`
11 |
12 | There is no automatic handling of producer exceptions (such as sending to a xref:kafka/kafka-binder/dlq.adoc[dead letter topic]).
13 | You can consume these exceptions with your own Spring Integration flow.
14 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/kafka/kafka-binder/manual-ack.adoc:
--------------------------------------------------------------------------------
1 | = Manual Acknowledgement
2 |
3 | This example illustrates how one may manually acknowledge offsets in a consumer application.
4 |
5 | This example requires that `spring.cloud.stream.kafka.bindings.input.consumer.ackMode` be set to `MANUAL`.
6 | Use the corresponding input channel name for your example.
7 |
8 | [source]
9 | ----
10 | @SpringBootApplication
11 | public class ManuallyAcknowdledgingConsumer {
12 |
13 | public static void main(String[] args) {
14 | SpringApplication.run(ManuallyAcknowdledgingConsumer.class, args);
15 | }
16 |
17 | @Bean
18 | public Consumer> process() {
19 | return message -> {
20 | Acknowledgment acknowledgment = message.getHeaders().get(KafkaHeaders.ACKNOWLEDGMENT, Acknowledgment.class);
21 | if (acknowledgment != null) {
22 | System.out.println("Acknowledgment provided");
23 | acknowledgment.acknowledge();
24 | }
25 | };
26 | }
27 | ----
28 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/kafka/kafka-binder/metrics.adoc:
--------------------------------------------------------------------------------
1 | [[kafka-metrics]]
2 | = Kafka Metrics
3 |
4 | Kafka binder module exposes the following metrics:
5 |
6 | `spring.cloud.stream.binder.kafka.offset`: This metric indicates how many messages have not been yet consumed from a given binder's topic by a given consumer group.
7 | The metrics provided are based on the Micrometer library.
8 | The binder creates the `KafkaBinderMetrics` bean if Micrometer is on the classpath and no other such beans provided by the application.
9 | The metric contains the consumer group information, topic and the actual lag in committed offset from the latest offset on the topic.
10 | This metric is particularly useful for providing auto-scaling feedback to a PaaS platform.
11 |
12 | The metric collection behaviour can be configured by setting properties in the `spring.cloud.stream.kafka.binder.metrics` namespace,
13 | refer to the <> for more information.
14 |
15 | You can exclude `KafkaBinderMetrics` from creating the necessary infrastructure like consumers and then reporting the metrics by providing the following component in the application.
16 |
17 | ```
18 | @Component
19 | class NoOpBindingMeters {
20 | NoOpBindingMeters(MeterRegistry registry) {
21 | registry.config().meterFilter(
22 | MeterFilter.denyNameStartsWith(KafkaBinderMetrics.OFFSET_LAG_METRIC_NAME));
23 | }
24 | }
25 | ```
26 |
27 | More details on how to suppress meters selectively can be found https://micrometer.io/docs/concepts#_meter_filters[here].
28 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/kafka/kafka-binder/overview.adoc:
--------------------------------------------------------------------------------
1 | = Overview
2 |
3 | The following image shows a simplified diagram of how the Apache Kafka binder operates:
4 |
5 | // .Kafka Binder
6 | // image::{github-raw}/docs/src/main/asciidoc/images/kafka-binder.png[width=300,scaledwidth="50%"]
7 |
8 | The Apache Kafka Binder implementation maps each destination to an Apache Kafka topic.
9 | The consumer group maps directly to the same Apache Kafka concept.
10 | Partitioning also maps directly to Apache Kafka partitions as well.
11 |
12 | The binder currently uses the Apache Kafka `kafka-clients` version `3.1.0`.
13 | This client can communicate with older brokers (see the Kafka documentation), but certain features may not be available.
14 | For example, with versions earlier than 0.11.x.x, native headers are not supported.
15 | Also, 0.11.x.x does not support the `autoAddPartitions` property.
16 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/kafka/kafka-binder/pause_resume.adoc:
--------------------------------------------------------------------------------
1 | [[pause-resume]]
2 | = Pausing and Resuming the Consumer
3 |
4 | If you wish to suspend consumption but not cause a partition rebalance, you can pause and resume the consumer.
5 | This is facilitated by managing the binding lifecycle as shown in **Binding visualization and control** in the Spring Cloud Stream documentation, using `State.PAUSED` and `State.RESUMED`.
6 |
7 | To resume, you can use an `ApplicationListener` (or `@EventListener` method) to receive `ListenerContainerIdleEvent` instances.
8 | The frequency at which events are published is controlled by the `idleEventInterval` property.
9 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/kafka/kafka-binder/tombstone.adoc:
--------------------------------------------------------------------------------
1 | [[kafka-tombstones]]
2 | = Tombstone Records
3 |
4 | When using compacted topics, a record with a `null` value (also called a tombstone record) represents the deletion of a key.
5 | To receive such messages in a Spring Cloud Stream function, you can use the following strategy.
6 |
7 | ====
8 | [source, java]
9 | ----
10 | @Bean
11 | public Function, String> myFunction() {
12 | return value -> {
13 | Object v = value.getPayload();
14 | String className = v.getClass().getName();
15 | if (className.isEqualTo("org.springframework.kafka.support.KafkaNull")) {
16 | // this is a tombstone record
17 | }
18 | else {
19 | // continue with processing
20 | }
21 | };
22 | }
23 | ----
24 | ====
25 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/kafka/kafka-binder/usage.adoc:
--------------------------------------------------------------------------------
1 | = Usage
2 |
3 | To use Apache Kafka binder, you need to add `spring-cloud-stream-binder-kafka` as a dependency to your Spring Cloud Stream application, as shown in the following example for Maven:
4 |
5 | [source,xml]
6 | ----
7 |
8 | org.springframework.cloud
9 | spring-cloud-stream-binder-kafka
10 |
11 | ----
12 |
13 | Alternatively, you can also use the Spring Cloud Stream Kafka Starter, as shown in the following example for Maven:
14 |
15 | [source,xml]
16 | ----
17 |
18 | org.springframework.cloud
19 | spring-cloud-starter-stream-kafka
20 |
21 | ----
22 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/kafka/kafka-reactive-binder/concurrency.adoc:
--------------------------------------------------------------------------------
1 | [[concurrency]]
2 | = Concurrency
3 |
4 | When using reactive functions with the reactive Kafka binder, if you set concurrency on the consumer binding, then the binder creates as many dedicated `KafkaReceiver` objects as provided by the concurrency value.
5 | In other words, this creates multiple reactive streams with separate `Flux` implementations.
6 | This could be useful when you are consuming records from a partitioned topic.
7 |
8 | For example, assume that the incoming topic has at least three partitions.
9 | Then you can set the following property.
10 |
11 | ```
12 | spring.cloud.stream.bindings.lowercase-in-0.consumer.concurrency=3
13 | ```
14 |
15 | That will create three dedicated `KafkaReceiver` objects that generate three separate `Flux` implementations and then stream them to the handler method.
16 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/kafka/kafka-reactive-binder/health_indicator.adoc:
--------------------------------------------------------------------------------
1 | [[reactor-kafka-binder-health-indicator]]
2 | = Reactor Kafka Binder Health Indicator
3 |
4 | Reactor Kafka binder provides a `HealthIndicator` implementation that will be used when invoking the Spring Boot Actuator `health` endpoint.
5 | When Spring Boot actuator dependency is on the classpath, the Reactor Kafka binder can be enabled with a binder health indicator.
6 | This health indicator provides information about the status of the binder based application, i.e. if it is currently `UP` or `DOWN`, the topics in usage by the application, and the various details about the message producer components that the binder uses internally.
7 |
8 |
9 | The Reactor Kafka Binder Health Indicator is registered with the key `reactorKafka` internally by the framework.
10 | Therefore, it can be queried programmatically as shown below.
11 |
12 | [source, java]
13 | ----
14 | CompositeHealthContributor compositeHealthContributor = context
15 | .getBean("bindersHealthContributor", CompositeHealthContributor.class);
16 | ReactorKafkaBinderHealthIndicator healthIndicator = (ReactorKafkaBinderHealthIndicator) compositeHealthContributor.getContributor("reactorKafka");
17 | Health health = healthIndicator.health();
18 | ----
19 |
20 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/kafka/kafka-reactive-binder/multiplex.adoc:
--------------------------------------------------------------------------------
1 | [[multiplex]]
2 | = Multiplex
3 |
4 | Starting with version 4.0.3, the common consumer property `multiplex` is now supported by the reactive binder, where a single binding can consume from multiple topics.
5 | When `false` (default), a separate binding is created for each topic specified in a comma-delimited list in the common `destination` property.
6 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/kafka/kafka-reactive-binder/overview.adoc:
--------------------------------------------------------------------------------
1 | [[reactive-kafka-binder]]
2 | = Overview
3 |
4 | NOTE: As of Spring Cloud Stream version 4.3.0, the reactive Kafka binder is deprecated and will be completely removed in a future release. See the related updates in https://spring.io/blog/2025/05/20/reactor-kafka-discontinued[Reactor Kafka Discontinued Blog Post]. Please continue to use the regular message channel based Kafka binder with reactive types. Keep in mind that the applications will need to handle the various reactive use cases explicitly using the reactor programming model and support from the Project Reactor directly.
5 |
6 | Kafka binder ecosystem in Spring Cloud Stream provides a dedicated reactive binder based on the https://projectreactor.io/docs/kafka/release/reference/[Reactor Kafka] project.
7 | This reactive Kafka binder enables full end-to-end reactive capabilities such as backpressure, reactive streams, etc. in applications based on Apache Kafka.
8 | When your Spring Cloud Stream Kafka application is written using reactive types (`Flux`, `Mono` etc.), it is recommended to use this reactive Kafka binder instead of the regular message channel based Kafka binder.
9 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/kafka/kafka-reactive-binder/pattern.adoc:
--------------------------------------------------------------------------------
1 | [[destination-is-pattern]]
2 | = Destination is Pattern
3 |
4 | Starting with version 4.0.3, the `destination-is-pattern` Kafka binding consumer property is now supported.
5 | The receiver options are configured with a regex `Pattern`, allowing the binding to consume from any topic that matches the pattern.
6 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/kafka/kafka-reactive-binder/sender_result.adoc:
--------------------------------------------------------------------------------
1 | [[sender-result-channel]]
2 | = Sender Result Channel
3 |
4 | Starting with version 4.0.3, you can configure the `resultMetadataChannel` to receive `SenderResult>` s to determine success/failure of sends.
5 |
6 | The `SenderResult` contains `correlationMetadata` to allow you to correlate results with sends; it also contains `RecordMetadata`, which indicates the `TopicPartition` and offset of the sent record.
7 |
8 | The `resultMetadataChannel` **must** be a `FluxMessageChannel` instance.
9 |
10 | Here is an example of how to use this feature, with correlation metadata of type `Integer`:
11 |
12 | [source, java]
13 | ----
14 | @Bean
15 | FluxMessageChannel sendResults() {
16 | return new FluxMessageChannel();
17 | }
18 |
19 | @ServiceActivator(inputChannel = "sendResults")
20 | void handleResults(SenderResult result) {
21 | if (result.exception() != null) {
22 | failureFor(result);
23 | }
24 | else {
25 | successFor(result);
26 | }
27 | }
28 | ----
29 |
30 | To set the correlation metadata on an output record, set the `CORRELATION_ID` header:
31 |
32 | [source, java]
33 | ----
34 | streamBridge.send("words1", MessageBuilder.withPayload("foobar")
35 | .setCorrelationId(42)
36 | .build());
37 | ----
38 |
39 | When using the feature with a `Function`, the function output type must be a `Message>` with the correlation id header set to the desired value.
40 |
41 | Metadata should be unique, at least for the duration of the send.
42 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/kafka/kafka-reactive-binder/usage.adoc:
--------------------------------------------------------------------------------
1 | [[maven-coordinates]]
2 | = Maven Coordinates
3 |
4 | Following are the maven coordinates for the reactive Kafka binder.
5 |
6 | ```
7 |
8 | org.springframework.cloud
9 | spring-cloud-stream-binder-kafka-reactive
10 |
11 | ```
12 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/kafka/kafka-streams-binder/accessing-metrics.adoc:
--------------------------------------------------------------------------------
1 | [[accessing-kafka-streams-metrics]]
2 | = Accessing Kafka Streams Metrics
3 | :page-section-summary-toc: 1
4 |
5 | Spring Cloud Stream Kafka Streams binder provides Kafka Streams metrics which can be exported through a Micrometer `MeterRegistry`.
6 |
7 | For Spring Boot version 2.2.x, the metrics support is provided through a custom Micrometer metrics implementation by the binder.
8 | For Spring Boot version 2.3.x, the Kafka Streams metrics support is provided natively through Micrometer.
9 |
10 | When accessing metrics through the Boot actuator endpoint, make sure to add `metrics` to the property `management.endpoints.web.exposure.include`.
11 | Then you can access `/actuator/metrics` to get a list of all the available metrics, which then can be individually accessed through the same URI (`/actuator/metrics/`).
12 |
13 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/kafka/kafka-streams-binder/overview.adoc:
--------------------------------------------------------------------------------
1 | [[overview]]
2 | = Overview
3 | :page-section-summary-toc: 1
4 |
5 | Spring Cloud Stream includes a binder implementation designed explicitly for https://kafka.apache.org/documentation/streams/[Apache Kafka Streams] binding.
6 | With this native integration, a Spring Cloud Stream "processor" application can directly use the
7 | https://kafka.apache.org/documentation/streams/developer-guide[Apache Kafka Streams] APIs in the core business logic.
8 |
9 | Kafka Streams binder implementation builds on the foundations provided by the https://docs.spring.io/spring-kafka/reference/html/#kafka-streams[Spring for Apache Kafka] project.
10 |
11 | Kafka Streams binder provides binding capabilities for the three major types in Kafka Streams - `KStream`, `KTable` and `GlobalKTable`.
12 |
13 | Kafka Streams applications typically follow a model in which the records are read from an inbound topic, apply business logic, and then write the transformed records to an outbound topic.
14 | Alternatively, a Processor application with no outbound destination can be defined as well.
15 |
16 | In the following sections, we are going to look at the details of Spring Cloud Stream's integration with Kafka Streams.
17 |
18 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/kafka/kafka-streams-binder/state-cleanup.adoc:
--------------------------------------------------------------------------------
1 | [[state-cleanup]]
2 | = State Cleanup
3 | :page-section-summary-toc: 1
4 |
5 | By default, no local state is cleaned up when the binding is stopped.
6 | This is the same behavior effective from Spring Kafka version 2.7.
7 | See https://docs.spring.io/spring-kafka/reference/html/#streams-config[Spring Kafka documentation] for more details.
8 | To modify this behavior simply add a single `CleanupConfig` `@Bean` (configured to clean up on start, stop, or neither) to the application context; the bean will be detected and wired into the factory bean.
9 |
10 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/kafka/kafka-streams-binder/timestamp-extractor.adoc:
--------------------------------------------------------------------------------
1 | [[timestamp-extractor]]
2 | = Timestamp extractor
3 |
4 | Kafka Streams allows you to control the processing of the consumer records based on various notions of timestamp.
5 | By default, Kafka Streams extracts the timestamp metadata embedded in the consumer record.
6 | You can change this default behavior by providing a different `TimestampExtractor` implementation per input binding.
7 | Here are some details on how that can be done.
8 |
9 | ```
10 | @Bean
11 | public Function,
12 | Function,
13 | Function, KStream>>> process() {
14 | return orderStream ->
15 | customers ->
16 | products -> orderStream;
17 | }
18 |
19 | @Bean
20 | public TimestampExtractor timestampExtractor() {
21 | return new WallclockTimestampExtractor();
22 | }
23 | ```
24 |
25 | Then you set the above `TimestampExtractor` bean name per consumer binding.
26 |
27 | ```
28 | spring.cloud.stream.kafka.streams.bindings.process-in-0.consumer.timestampExtractorBeanName=timestampExtractor
29 | spring.cloud.stream.kafka.streams.bindings.process-in-1.consumer.timestampExtractorBeanName=timestampExtractor
30 | spring.cloud.stream.kafka.streams.bindings.process-in-2.consumer.timestampExtractorBeanName=timestampExtractor"
31 | ```
32 |
33 | If you skip an input consumer binding for setting a custom timestamp extractor, that consumer will use the default settings.
34 |
35 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/kafka/kafka-streams-binder/topology-visualization.adoc:
--------------------------------------------------------------------------------
1 | [[kafka-streams-topology-visualization]]
2 | = Kafka Streams topology visualization
3 | :page-section-summary-toc: 1
4 |
5 | Kafka Streams binder provides the following actuator endpoints for retrieving the topology description using which you can visualize the topology using external tools.
6 |
7 | `/actuator/kafkastreamstopology`
8 |
9 | `/actuator/kafkastreamstopology/`
10 |
11 | You need to include the actuator and web dependencies from Spring Boot to access these endpoints.
12 | Further, you also need to add `kafkastreamstopology` to `management.endpoints.web.exposure.include` property.
13 | By default, the `kafkastreamstopology` endpoint is disabled.
14 |
15 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/kafka/kafka-streams-binder/usage.adoc:
--------------------------------------------------------------------------------
1 | [[usage]]
2 | = Usage
3 | :page-section-summary-toc: 1
4 |
5 | For using the Kafka Streams binder, you just need to add it to your Spring Cloud Stream application, using the following maven coordinates:
6 |
7 | [source,xml]
8 | ----
9 |
10 | org.springframework.cloud
11 | spring-cloud-stream-binder-kafka-streams
12 |
13 | ----
14 |
15 | A quick way to bootstrap a new project for Kafka Streams binder is to use http://start.spring.io[Spring Initializr] and then select "Cloud Streams" and "Spring for Kafka Streams" as shown below
16 |
17 | // image::{github-raw}/docs/src/main/asciidoc/images/spring-initializr-kafka-streams.png[width=800,scaledwidth="75%",align="center"]
18 |
19 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/kafka/kafka-streams.adoc:
--------------------------------------------------------------------------------
1 | :nofooter:
2 | :sectlinks: true
3 |
4 | [[spring-cloud-stream-binder-kafka-streams-reference]]
5 | = Spring Cloud Stream Kafka Streams Binder Reference Guide
6 |
7 | xref:kafka/kafka-streams-binder/usage.adoc[Reference Guide]
8 |
9 |
10 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/pulsar/spring-cloud-stream-binder-pulsar.adoc:
--------------------------------------------------------------------------------
1 | :nofooter:
2 | :sectlinks: true
3 |
4 | [[spring-cloud-stream-binder-pulsar-reference]]
5 | = Spring Cloud Stream Pulsar Binder Reference Guide
6 | :page-section-summary-toc: 1
7 | Soby Chacko; Chris Bono; Alexander Preuß; Jay Bryant; Christophe Bornet
8 | :doctype: book
9 | :source-highlighter: prettify
10 | :numbered:
11 | :icons: font
12 | :hide-uri-scheme:
13 | :sc-ext: java
14 |
15 | // ======================================================================================
16 |
17 | // *{project-version}*
18 |
19 | xref:pulsar/pulsar_binder.adoc[Reference Guide]
20 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/rabbit/rabbit_overview/advanced-binding-configuration.adoc:
--------------------------------------------------------------------------------
1 | [[advanced-configuration]]
2 | = Advanced Configuration
3 | :page-section-summary-toc: 1
4 |
5 | From time to time, the RabbitMQ team add new features that are enabled by setting some argument when declaring, for example, a queue.
6 | Generally, such features are enabled in the binder by adding appropriate properties, but this may not be immediately available in a current version.
7 | Starting with version 3.0.1, you can now add `DeclarableCustomizer` bean(s) to the application context to modify a `Declarable` (`Queue`, `Exchange` or `Binding`) just before the declaration is performed.
8 | This allows you to add arguments that are not currently directly supported by the binder.
9 |
10 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/rabbit/rabbit_overview/advanced-listener-container-configuration.adoc:
--------------------------------------------------------------------------------
1 | [[advanced-listener-container-configuration]]
2 | = Advanced Listener Container Configuration
3 | :page-section-summary-toc: 1
4 |
5 | To set listener container properties that are not exposed as binder or binding properties, add a single bean of type `ListenerContainerCustomizer` to the application context.
6 | The binder and binding properties will be set and then the customizer will be called.
7 | The customizer (`configure()` method) is provided with the queue name as well as the consumer group as arguments.
8 |
9 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/rabbit/rabbit_overview/health-indicator.adoc:
--------------------------------------------------------------------------------
1 | [[rabbit-binder-health-indicator]]
2 | = Rabbit Binder Health Indicator
3 |
4 | The health indicator for Rabbit binder delegates to the one provided from Spring Boot.
5 | For more information on this, see https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#actuator.endpoints.health.auto-configured-health-indicators[this].
6 |
7 | You can disable this health indicator at the binder level by using the property - `management.health.binders.enabled` and set this to `false`.
8 | In the case of multi-binder environments, this has to be set on the binder's environment properties.
9 |
10 | When the health indicator is disabled, you should see something like the below in the health actuator endpoint:
11 |
12 | ```
13 | "rabbit": {
14 | "status": "UNKNOWN"
15 | }
16 | ```
17 |
18 | At the Spring Boot level, if you want to disable the Rabbit health indicator, you need to use the property `management.health.rabbit.enabled` and set to `false`.
19 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/spring-cloud-stream/application-communication.adoc:
--------------------------------------------------------------------------------
1 | [[inter-application-communication]]
2 | = Inter-Application Communication
3 | :page-section-summary-toc: 1
4 |
5 | Spring Cloud Stream enables communication between applications. Inter-application communication is a complex issue spanning several concerns, as described in the following topics:
6 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/spring-cloud-stream/binder-configuration-properties.adoc:
--------------------------------------------------------------------------------
1 | [[binder-configuration-properties]]
2 | = Binder Configuration Properties
3 |
4 | The following properties are available when customizing binder configurations. These properties exposed via `org.springframework.cloud.stream.config.BinderProperties`
5 |
6 | They must be prefixed with `spring.cloud.stream.binders.`.
7 |
8 | type::
9 | The binder type.
10 | It typically references one of the binders found on the classpath -- in particular, a key in a `META-INF/spring.binders` file.
11 | +
12 | By default, it has the same value as the configuration name.
13 | inheritEnvironment::
14 | Whether the configuration inherits the environment of the application itself.
15 | +
16 | Default: `true`.
17 | environment::
18 | Root for a set of properties that can be used to customize the environment of the binder.
19 | When this property is set, the context in which the binder is being created is not a child of the application context.
20 | This setting allows for complete separation between the binder components and the application components.
21 | +
22 | Default: `empty`.
23 | defaultCandidate::
24 | Whether the binder configuration is a candidate for being considered a default binder or can be used only when explicitly referenced.
25 | This setting allows adding binder configurations without interfering with the default processing.
26 | +
27 | Default: `true`.
28 |
29 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/spring-cloud-stream/binder-detection.adoc:
--------------------------------------------------------------------------------
1 | [[binder-detection]]
2 | = Binder Detection
3 | :page-section-summary-toc: 1
4 |
5 | Spring Cloud Stream relies on implementations of the Binder SPI to perform the task of connecting (binding) user code to message brokers.
6 | Each Binder implementation typically connects to one type of messaging system.
7 |
8 | [[classpath-detection]]
9 | == Classpath Detection
10 |
11 | By default, Spring Cloud Stream relies on Spring Boot's auto-configuration to configure the binding process.
12 | If a single Binder implementation is found on the classpath, Spring Cloud Stream automatically uses it.
13 | For example, a Spring Cloud Stream project that aims to bind only to RabbitMQ can add the following dependency:
14 |
15 | [source,xml]
16 | ----
17 |
18 | org.springframework.cloud
19 | spring-cloud-stream-binder-rabbit
20 |
21 | ----
22 |
23 | For the specific Maven coordinates of other binder dependencies, see the documentation of that binder implementation.
24 |
25 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/spring-cloud-stream/binding-names.adoc:
--------------------------------------------------------------------------------
1 | [[binding-names]]
2 | = Binding and Binding names
3 |
4 | Binding is an abstraction that represents a bridge between sources and targets exposed by the binder and user code,
5 | This abstraction has a name and while we try to do our best to limit configuration required to run spring-cloud-stream applications,
6 | being aware of such name(s) is necessary for cases where additional per-binding configuration is required.
7 |
8 | Throughout this manual you will see examples of configuration properties such as `spring.cloud.stream.bindings.input.destination=myQueue`.
9 | The `input` segment in this property name is what we refer to as _binding name_ and it could derive via several mechanisms.
10 | The following sub-sections will describe the naming conventions and configuration elements used by spring-cloud-stream to control binding names.
11 |
12 | NOTE: If your binding name has special characters, such as the `.` character, you need to surround the binding key with brackets (`[]`) and then wrap it in qoutes.
13 | For example `spring.cloud.stream.bindings."[my.output.binding.key]".destination`.
14 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/spring-cloud-stream/consumer-groups.adoc:
--------------------------------------------------------------------------------
1 | [[consumer-groups]]
2 | = Consumer Groups
3 | :page-section-summary-toc: 1
4 |
5 | While the publish-subscribe model makes it easy to connect applications through shared topics, the ability to scale up by creating multiple instances of a given application is equally important.
6 | When doing so, different instances of an application are placed in a competing consumer relationship, where only one of the instances is expected to handle a given message.
7 |
8 | Spring Cloud Stream models this behavior through the concept of a consumer group.
9 | (Spring Cloud Stream consumer groups are similar to and inspired by Kafka consumer groups.)
10 | Each consumer binding can use the `spring.cloud.stream.bindings..group` property to specify a group name.
11 | For the consumers shown in the following figure, this property would be set as `spring.cloud.stream.bindings..group=hdfsWrite` or `spring.cloud.stream.bindings..group=average`.
12 |
13 | .Spring Cloud Stream Consumer Groups
14 | image::SCSt-groups.png[width=800,scaledwidth="75%",align="center"]
15 |
16 | All groups that subscribe to a given destination receive a copy of published data, but only one member of each group receives a given message from that destination.
17 | By default, when a group is not specified, Spring Cloud Stream assigns the application to an anonymous and independent single-member consumer group that is in a publish-subscribe relationship with all other consumer groups.
18 |
19 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/spring-cloud-stream/content-type.adoc:
--------------------------------------------------------------------------------
1 | [[content_type_management]]
2 | = Content Type Negotiation
3 |
4 | Data transformation is one of the core features of any message-driven microservice architecture. Given that, in Spring Cloud Stream, such data
5 | is represented as a Spring `Message`, a message may have to be transformed to a desired shape or size before reaching its destination. This is required for two reasons:
6 |
7 | . To convert the contents of the incoming message to match the signature of the application-provided handler.
8 |
9 | . To convert the contents of the outgoing message to the wire format.
10 |
11 | The wire format is typically `byte[]` (that is true for the Kafka and Rabbit binders), but it is governed by the binder implementation.
12 |
13 | In Spring Cloud Stream, message transformation is accomplished with an `org.springframework.messaging.converter.MessageConverter`.
14 |
15 | NOTE: As a supplement to the details to follow, you may also want to read the following https://spring.io/blog/2018/02/26/spring-cloud-stream-2-0-content-type-negotiation-and-transformation[blog post].
16 |
17 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/spring-cloud-stream/destination-binders.adoc:
--------------------------------------------------------------------------------
1 | [[destination-binders]]
2 | = Destination Binders
3 | :page-section-summary-toc: 1
4 |
5 | Destination Binders are extension components of Spring Cloud Stream responsible for providing the necessary configuration and implementation to facilitate
6 | integration with external messaging systems.
7 | This integration is responsible for connectivity, delegation, and routing of messages to and from producers and consumers, data type conversion,
8 | invocation of the user code, and more.
9 |
10 | Binders handle a lot of the boiler plate responsibilities that would otherwise fall on your shoulders. However, to accomplish that, the binder still needs
11 | some help in the form of minimalistic yet required set of instructions from the user, which typically come in the form of some type of _binding_ configuration.
12 |
13 | While it is out of scope of this section to discuss all of the available binder and binding configuration options (the rest of the manual covers them extensively),
14 | _Binding_ as a concept, does require special attention. The next section discusses it in detail.
15 |
16 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/spring-cloud-stream/multiple-binders.adoc:
--------------------------------------------------------------------------------
1 | [[multiple-binders]]
2 | = Multiple Binders on the Classpath
3 | :page-section-summary-toc: 1
4 |
5 | When multiple binders are present on the classpath, the application must indicate which binder is to be used for each destination binding.
6 | Each binder configuration contains a `META-INF/spring.binders` file, which is a simple properties file, as shown in the following example:
7 |
8 | [source]
9 | ----
10 | rabbit:\
11 | org.springframework.cloud.stream.binder.rabbit.config.RabbitServiceAutoConfiguration
12 | ----
13 |
14 | Similar files exist for the other provided binder implementations (such as Kafka), and custom binder implementations are expected to provide them as well.
15 | The key represents an identifying name for the binder implementation, whereas the value is a comma-separated list of configuration classes that each contain one and only one bean definition of type `org.springframework.cloud.stream.binder.Binder`.
16 |
17 | Binder selection can either be performed globally, using the `spring.cloud.stream.defaultBinder` property (for example, `spring.cloud.stream.defaultBinder=rabbit`) or individually, by configuring the binder on each binding.
18 | For instance, a processor application (that has bindings named `input` and `output` for read and write respectively) that reads from Kafka and writes to RabbitMQ can specify the following configuration:
19 |
20 | [source]
21 | ----
22 | spring.cloud.stream.bindings.input.binder=kafka
23 | spring.cloud.stream.bindings.output.binder=rabbit
24 | ----
25 |
26 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/spring-cloud-stream/overview-application-model.adoc:
--------------------------------------------------------------------------------
1 | [[spring-cloud-stream-overview-application-model]]
2 | = Application Model
3 | :page-section-summary-toc: 1
4 |
5 | A Spring Cloud Stream application consists of a middleware-neutral core.
6 | The application communicates with the outside world by establishing _bindings_ between destinations
7 | exposed by the external brokers and input/output arguments in your code. Broker specific details
8 | necessary to establish bindings are handled by middleware-specific _Binder_ implementations.
9 |
10 | .Spring Cloud Stream Application
11 | image::SCSt-with-binder.png[width=800,scaledwidth="75%",align="center"]
12 |
13 | [[fat-jar]]
14 | == Fat JAR
15 |
16 | Spring Cloud Stream applications can be run in stand-alone mode from your IDE for testing.
17 | To run a Spring Cloud Stream application in production, you can create an executable (or "`fat`") JAR by using the standard Spring Boot tooling provided for Maven or Gradle. See the https://docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html#howto-create-an-executable-jar-with-maven[Spring Boot Reference Guide] for more details.
18 |
19 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/spring-cloud-stream/overview-connecting-multiple-application-instances.adoc:
--------------------------------------------------------------------------------
1 | [[spring-cloud-stream-overview-connecting-multiple-application-instances]]
2 | = Connecting Multiple Application Instances
3 | :page-section-summary-toc: 1
4 |
5 | While Spring Cloud Stream makes it easy for individual Spring Boot applications to connect to messaging systems, the typical scenario for Spring Cloud Stream is the creation of multi-application pipelines, where microservice applications send data to each other.
6 | You can achieve this scenario by correlating the input and output destinations of "`adjacent`" applications.
7 |
8 | Suppose a design calls for the Time Source application to send data to the Log Sink application. You could use a common destination named `ticktock` for bindings within both applications.
9 |
10 | Time Source (that has the binding named `output`) would set the following property:
11 |
12 | ----
13 | spring.cloud.stream.bindings.output.destination=ticktock
14 | ----
15 |
16 | Log Sink (that has the binding named `input`) would set the following property:
17 |
18 | ----
19 | spring.cloud.stream.bindings.input.destination=ticktock
20 | ----
21 |
22 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/spring-cloud-stream/overview-instance-index-instance-count.adoc:
--------------------------------------------------------------------------------
1 | [[spring-cloud-stream-overview-instance-index-instance-count]]
2 | = Instance Index and Instance Count
3 | :page-section-summary-toc: 1
4 |
5 | When scaling up Spring Cloud Stream applications, each instance can receive information about how many other instances of the same application exist and what its own instance index is.
6 | Spring Cloud Stream does this through the `spring.cloud.stream.instanceCount` and `spring.cloud.stream.instanceIndex` properties.
7 | For example, if there are three instances of a HDFS sink application, all three instances have `spring.cloud.stream.instanceCount` set to `3`, and the individual applications have `spring.cloud.stream.instanceIndex` set to `0`, `1`, and `2`, respectively.
8 |
9 | When Spring Cloud Stream applications are deployed through Spring Cloud Data Flow, these properties are configured automatically; when Spring Cloud Stream applications are launched independently, these properties must be set correctly.
10 | By default, `spring.cloud.stream.instanceCount` is `1`, and `spring.cloud.stream.instanceIndex` is `0`.
11 |
12 | In a scaled-up scenario, correct configuration of these two properties is important for addressing partitioning behavior (see below) in general, and the two properties are always required by certain binders (for example, the Kafka binder) in order to ensure that data are split correctly across multiple consumer instances.
13 |
14 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/spring-cloud-stream/programming-model.adoc:
--------------------------------------------------------------------------------
1 | [[programming-model]]
2 | = Programming Model
3 |
4 | To understand the programming model, you should be familiar with the following core concepts:
5 |
6 | * *Destination Binders:* Components responsible to provide integration with the external messaging systems.
7 | * *Bindings:* Bridge between the external messaging systems and application provided _Producers_ and _Consumers_ of messages (created by the Destination Binders).
8 | * *Message:* The canonical data structure used by producers and consumers to communicate with Destination Binders (and thus other applications via external messaging systems).
9 |
10 | image::SCSt-overview.png[width=800,scaledwidth="75%",align="center"]
11 |
12 |
--------------------------------------------------------------------------------
/docs/modules/ROOT/pages/spring-cloud-stream/samples.adoc:
--------------------------------------------------------------------------------
1 | [[samples]]
2 | = Samples
3 |
4 | For Spring Cloud Stream samples, see the https://github.com/spring-cloud/spring-cloud-stream-samples[spring-cloud-stream-samples] repository on GitHub.
5 |
--------------------------------------------------------------------------------
/docs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "antora": "3.2.0-alpha.4",
4 | "@antora/atlas-extension": "1.0.0-alpha.2",
5 | "@antora/collector-extension": "1.0.0-alpha.3",
6 | "@asciidoctor/tabs": "1.0.0-beta.6",
7 | "@springio/antora-extensions": "1.11.1",
8 | "@springio/asciidoctor-extensions": "1.0.0-alpha.10"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/docs/src/main/antora/resources/antora-resources/antora.yml:
--------------------------------------------------------------------------------
1 | version: @antora-component.version@
2 | prerelease: @antora-component.prerelease@
3 |
4 | #asciidoc:
5 | # attributes:
6 | # attribute-missing: 'warn'
7 | # chomp: 'all'
8 | # project-root: @maven.multiModuleProjectDirectory@
9 | # github-repo: @docs.main@
10 | # github-raw: https://raw.githubusercontent.com/spring-cloud/@docs.main@/@github-tag@
11 | # github-code: https://github.com/spring-cloud/@docs.main@/tree/@github-tag@
12 | # github-issues: https://github.com/spring-cloud/@docs.main@/issues/
13 | # github-wiki: https://github.com/spring-cloud/@docs.main@/wiki
14 | # spring-cloud-version: @project.version@
15 | # github-tag: @github-tag@
16 | # version-type: @version-type@
17 | # docs-url: https://docs.spring.io/@docs.main@/docs/@project.version@
18 | # raw-docs-url: https://raw.githubusercontent.com/spring-cloud/@docs.main@/@github-tag@
19 | # project-version: @project.version@
20 | # project-name: @docs.main@
21 |
--------------------------------------------------------------------------------
/docs/src/main/asciidoc/images/SCSt-groups.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/src/main/asciidoc/images/SCSt-groups.png
--------------------------------------------------------------------------------
/docs/src/main/asciidoc/images/SCSt-overview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/src/main/asciidoc/images/SCSt-overview.png
--------------------------------------------------------------------------------
/docs/src/main/asciidoc/images/SCSt-partitioning.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/src/main/asciidoc/images/SCSt-partitioning.png
--------------------------------------------------------------------------------
/docs/src/main/asciidoc/images/SCSt-sensors.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/src/main/asciidoc/images/SCSt-sensors.png
--------------------------------------------------------------------------------
/docs/src/main/asciidoc/images/SCSt-with-binder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/src/main/asciidoc/images/SCSt-with-binder.png
--------------------------------------------------------------------------------
/docs/src/main/asciidoc/images/custom_vs_global_error_channels.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/src/main/asciidoc/images/custom_vs_global_error_channels.png
--------------------------------------------------------------------------------
/docs/src/main/asciidoc/images/producers-consumers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/src/main/asciidoc/images/producers-consumers.png
--------------------------------------------------------------------------------
/docs/src/main/asciidoc/images/redis-binder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/src/main/asciidoc/images/redis-binder.png
--------------------------------------------------------------------------------
/docs/src/main/asciidoc/images/registration.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/src/main/asciidoc/images/registration.png
--------------------------------------------------------------------------------
/docs/src/main/asciidoc/images/schema_reading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/src/main/asciidoc/images/schema_reading.png
--------------------------------------------------------------------------------
/docs/src/main/asciidoc/images/schema_resolution.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/src/main/asciidoc/images/schema_resolution.png
--------------------------------------------------------------------------------
/docs/src/main/asciidoc/images/spring-initializr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/src/main/asciidoc/images/spring-initializr.png
--------------------------------------------------------------------------------
/docs/src/main/asciidoc/kafka/images/kafka-binder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/src/main/asciidoc/kafka/images/kafka-binder.png
--------------------------------------------------------------------------------
/docs/src/main/asciidoc/kafka/images/kafka-streams-initializr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/src/main/asciidoc/kafka/images/kafka-streams-initializr.png
--------------------------------------------------------------------------------
/docs/src/main/asciidoc/kafka/images/spring-initializr-kafka-streams.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/src/main/asciidoc/kafka/images/spring-initializr-kafka-streams.png
--------------------------------------------------------------------------------
/docs/src/main/asciidoc/rabbit/images/rabbit-binder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/docs/src/main/asciidoc/rabbit/images/rabbit-binder.png
--------------------------------------------------------------------------------
/docs/src/main/ruby/generate_readme.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | base_dir = File.join(File.dirname(__FILE__),'../../..')
4 | src_dir = File.join(base_dir, "/src/main/asciidoc")
5 | require 'asciidoctor'
6 | require 'optparse'
7 |
8 | options = {}
9 | file = "#{src_dir}/README.adoc"
10 |
11 | OptionParser.new do |o|
12 | o.on('-o OUTPUT_FILE', 'Output file (default is stdout)') { |file| options[:to_file] = file unless file=='-' }
13 | o.on('-h', '--help') { puts o; exit }
14 | o.parse!
15 | end
16 |
17 | file = ARGV[0] if ARGV.length>0
18 |
19 | # Copied from https://github.com/asciidoctor/asciidoctor-extensions-lab/blob/master/scripts/asciidoc-coalescer.rb
20 | doc = Asciidoctor.load_file file, safe: :unsafe, header_only: true, attributes: options[:attributes]
21 | header_attr_names = (doc.instance_variable_get :@attributes_modified).to_a
22 | header_attr_names.each {|k| doc.attributes[%(#{k}!)] = '' unless doc.attr? k }
23 | attrs = doc.attributes
24 | attrs['allow-uri-read'] = true
25 | puts attrs
26 |
27 | out = "// Do not edit this file (e.g. go instead to src/main/asciidoc)\n\n"
28 | doc = Asciidoctor.load_file file, safe: :unsafe, parse: false, attributes: attrs
29 | out << doc.reader.read
30 |
31 | unless options[:to_file]
32 | puts out
33 | else
34 | File.open(options[:to_file],'w+') do |file|
35 | file.write(out)
36 | end
37 | end
38 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-client/.jdk8:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/schema-registry/spring-cloud-stream-schema-registry-client/.jdk8
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-client/src/main/java/org/springframework/cloud/stream/schema/registry/SchemaNotFoundException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.schema.registry;
18 |
19 | /**
20 | * @author Vinicius Carvalho
21 | */
22 | public class SchemaNotFoundException extends RuntimeException {
23 |
24 | public SchemaNotFoundException(String message) {
25 | super(message);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-client/src/main/java/org/springframework/cloud/stream/schema/registry/SchemaRegistrationResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.schema.registry;
18 |
19 | /**
20 | * @author Marius Bogoevici
21 | */
22 | public class SchemaRegistrationResponse {
23 |
24 | private int id;
25 |
26 | private SchemaReference schemaReference;
27 |
28 | public int getId() {
29 | return this.id;
30 | }
31 |
32 | public void setId(int id) {
33 | this.id = id;
34 | }
35 |
36 | public SchemaReference getSchemaReference() {
37 | return this.schemaReference;
38 | }
39 |
40 | public void setSchemaReference(SchemaReference schemaReference) {
41 | this.schemaReference = schemaReference;
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-client/src/main/java/org/springframework/cloud/stream/schema/registry/avro/DefaultSubjectNamingStrategy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2017 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.schema.registry.avro;
18 |
19 | import org.apache.avro.Schema;
20 |
21 | import org.springframework.util.StringUtils;
22 |
23 | /**
24 | * @author David Kalosi
25 | */
26 | public class DefaultSubjectNamingStrategy implements SubjectNamingStrategy {
27 |
28 | @Override
29 | public String toSubject(String subjectNamePrefix, Schema schema) {
30 | return StringUtils.hasText(subjectNamePrefix) ?
31 | subjectNamePrefix + "-" + schema.getName().toLowerCase() :
32 | schema.getName().toLowerCase();
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-client/src/main/java/org/springframework/cloud/stream/schema/registry/avro/QualifiedSubjectNamingStrategy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.schema.registry.avro;
18 |
19 | import org.apache.avro.Schema;
20 |
21 | import org.springframework.util.StringUtils;
22 |
23 | /**
24 | * @author José A. Íñigo
25 | * @since 2.2.0
26 | */
27 | public class QualifiedSubjectNamingStrategy implements SubjectNamingStrategy {
28 |
29 | @Override
30 | public String toSubject(String subjectNamePrefix, Schema schema) {
31 | return StringUtils.hasText(subjectNamePrefix) ?
32 | subjectNamePrefix + "-" + schema.getFullName().toLowerCase() :
33 | schema.getFullName().toLowerCase();
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-client/src/main/java/org/springframework/cloud/stream/schema/registry/avro/SubjectNamingStrategy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2017 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.schema.registry.avro;
18 |
19 | import org.apache.avro.Schema;
20 |
21 | /**
22 | * Provides function towards naming schema registry subjects for Avro files.
23 | *
24 | * @author David Kalosi
25 | */
26 | public interface SubjectNamingStrategy {
27 |
28 | /**
29 | * Takes the Avro schema on input and returns the generated subject under which the
30 | * schema should be registered.
31 | * @param subjectNamePrefix optional subject name prefix
32 | * @param schema schema to register
33 | * @return subject name
34 | */
35 | String toSubject(String subjectNamePrefix, Schema schema);
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-client/src/main/java/org/springframework/cloud/stream/schema/registry/avro/SubjectPrefixOnlyNamingStrategy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020-2020 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.schema.registry.avro;
18 |
19 | import org.apache.avro.Schema;
20 |
21 | /**
22 | * @author Christian Tzolov
23 | */
24 | public class SubjectPrefixOnlyNamingStrategy implements SubjectNamingStrategy {
25 |
26 | @Override
27 | public String toSubject(String subjectNamePrefix, Schema schema) {
28 | return subjectNamePrefix;
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-client/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports:
--------------------------------------------------------------------------------
1 | org.springframework.cloud.stream.schema.registry.avro.AvroMessageConverterAutoConfiguration
2 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-client/src/test/resources/schemas/Command.avsc:
--------------------------------------------------------------------------------
1 | {
2 | "namespace":"example.avro",
3 | "name":"Command",
4 | "type":"record",
5 | "fields":[
6 | {
7 | "name":"type",
8 | "type":"string"
9 | },
10 | {
11 | "name":"correlationId",
12 | "type":"string"
13 | },
14 | {
15 | "name":"payload",
16 | "type":["Sms", "Email", "PushNotification"]
17 | }
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-client/src/test/resources/schemas/imports/Email.avsc:
--------------------------------------------------------------------------------
1 | {
2 | "namespace":"example.avro",
3 | "name": "Email",
4 | "type": "record",
5 | "fields":[
6 | {
7 | "name":"addressTo",
8 | "type":"string"
9 | },
10 | {
11 | "name":"title",
12 | "type":"string"
13 | },
14 | {
15 | "name":"text",
16 | "type":"string"
17 | }
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-client/src/test/resources/schemas/imports/PushNotification.avsc:
--------------------------------------------------------------------------------
1 | {
2 | "namespace":"example.avro",
3 | "name": "PushNotification",
4 | "type": "record",
5 | "fields":[
6 | {
7 | "name":"arn",
8 | "type":"string"
9 | },
10 | {
11 | "name":"text",
12 | "type":"string"
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-client/src/test/resources/schemas/imports/Sms.avsc:
--------------------------------------------------------------------------------
1 | {
2 | "namespace":"example.avro",
3 | "name": "Sms",
4 | "type": "record",
5 | "fields":[
6 | {
7 | "name":"phoneNumber",
8 | "type":"string"
9 | },{
10 | "name":"text",
11 | "type":"string"
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-client/src/test/resources/schemas/status.avsc:
--------------------------------------------------------------------------------
1 | {
2 | "namespace":"org.springframework.cloud.stream.samples",
3 | "name": "Status",
4 | "type" : "record",
5 | "fields": [
6 | {"name": "id", "type": "string"},
7 | {"name": "text", "type": "string"},
8 | {"name": "timestamp", "type": "long"}
9 | ]
10 | }
11 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-client/src/test/resources/schemas/user.avsc:
--------------------------------------------------------------------------------
1 | {"namespace": "example.avro",
2 | "type": "record",
3 | "name": "User",
4 | "fields": [
5 | {"name": "name", "type": "string"},
6 | {"name": "favoriteNumber", "type": ["int", "null"]},
7 | {"name": "favoriteColor", "type": ["string", "null"]}
8 |
9 | ]
10 | }
11 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-client/src/test/resources/schemas/user1_multiple_records.schema:
--------------------------------------------------------------------------------
1 | [
2 | {"namespace": "org.springframework.cloud.stream.schema.avro",
3 | "type": "record",
4 | "name": "User1",
5 | "fields": [
6 | {"name": "name", "type": "string"},
7 | {"name": "favoriteNumber", "type": ["int", "null"]},
8 | {"name": "favoriteColor", "type": ["string", "null"]}
9 |
10 | ]
11 | },
12 | {"namespace": "org.springframework.cloud.stream.schema.avro.v2",
13 | "type": "record",
14 | "name": "User1",
15 | "fields": [
16 | {"name": "name", "type": "string"},
17 | {"name": "favoriteNumber", "type": ["int", "null"]},
18 | {"name": "favoriteColor", "type": ["string", "null"]},
19 | {"name": "favoritePlace", "type": ["string","null"], "default" : "NYC"}
20 | ]
21 | }
22 | ]
23 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-client/src/test/resources/schemas/user1_v1.schema:
--------------------------------------------------------------------------------
1 | {"namespace": "org.springframework.cloud.schema.avro",
2 | "type": "record",
3 | "name": "User1",
4 | "fields": [
5 | {"name": "name", "type": "string"},
6 | {"name": "favoriteNumber", "type": ["int", "null"]},
7 | {"name": "favoriteColor", "type": ["string", "null"]}
8 |
9 | ]
10 | }
11 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-client/src/test/resources/schemas/user1_v2.schema:
--------------------------------------------------------------------------------
1 | {"namespace": "org.springframework.cloud.schema.avro.v2",
2 | "type": "record",
3 | "name": "User1",
4 | "fields": [
5 | {"name": "name", "type": "string"},
6 | {"name": "favoriteNumber", "type": ["int", "null"]},
7 | {"name": "favoriteColor", "type": ["string", "null"]},
8 | {"name": "favoritePlace", "type": ["string","null"], "default" : "NYC"}
9 | ]
10 | }
11 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-client/src/test/resources/schemas/user_v2.avsc:
--------------------------------------------------------------------------------
1 | {"namespace": "example.avro.v2",
2 | "type": "record",
3 | "name": "User",
4 | "fields": [
5 | {"name": "name", "type": "string"},
6 | {"name": "favoriteNumber", "type": ["int", "null"]},
7 | {"name": "favoriteColor", "type": ["string", "null"]},
8 | {"name": "favoritePlace", "type": ["string","null"], "default" : "NYC"}
9 | ]
10 | }
11 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-client/src/test/resources/schemas/users_v1.schema:
--------------------------------------------------------------------------------
1 | {"namespace": "example.avro",
2 | "type": "record",
3 | "name": "User",
4 | "fields": [
5 | {"name": "name", "type": "string"},
6 | {"name": "favoriteNumber", "type": ["int", "null"]},
7 | {"name": "favoriteColor", "type": ["string", "null"]}
8 |
9 | ]
10 | }
11 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-client/src/test/resources/schemas/users_v2.schema:
--------------------------------------------------------------------------------
1 | {"namespace": "example.avro",
2 | "type": "record",
3 | "name": "User",
4 | "fields": [
5 | {"name": "name", "type": "string"},
6 | {"name": "favoriteNumber", "type": ["int", "null"]},
7 | {"name": "favoriteColor", "type": ["string", "null"]},
8 | {"name": "favoritePlace", "type": ["string","null"], "default" : "NYC"}
9 | ]
10 | }
11 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-core/.jdk8:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/schema-registry/spring-cloud-stream-schema-registry-core/.jdk8
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-core/src/main/java/org/springframework/cloud/stream/schema/registry/EnableSchemaRegistryServer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.schema.registry;
18 |
19 | import java.lang.annotation.Documented;
20 | import java.lang.annotation.ElementType;
21 | import java.lang.annotation.Retention;
22 | import java.lang.annotation.RetentionPolicy;
23 | import java.lang.annotation.Target;
24 |
25 | import org.springframework.cloud.stream.schema.registry.config.SchemaServerConfiguration;
26 | import org.springframework.context.annotation.Import;
27 |
28 | /**
29 | * Enables the schema registry server enpoints.
30 | *
31 | * @author Vinicius Carvalho
32 | */
33 | @Target(ElementType.TYPE)
34 | @Retention(RetentionPolicy.RUNTIME)
35 | @Documented
36 | @Import(SchemaServerConfiguration.class)
37 | public @interface EnableSchemaRegistryServer {
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-core/src/main/java/org/springframework/cloud/stream/schema/registry/model/Compatibility.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.schema.registry.model;
18 |
19 | /**
20 | * @author Vinicius Carvalho
21 | */
22 | public enum Compatibility {
23 |
24 | /**
25 | * Backward compatibiltity.
26 | */
27 | BACKWARD,
28 |
29 | /**
30 | * Forward compatibility.
31 | */
32 | FORWARD,
33 |
34 | /**
35 | * Full compatibility.
36 | */
37 | FULL,
38 |
39 | /**
40 | * Lack of compatibility.
41 | */
42 | INCOMPATIBLE;
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-core/src/main/java/org/springframework/cloud/stream/schema/registry/repository/SchemaRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.schema.registry.repository;
18 |
19 | import java.util.List;
20 |
21 | import org.springframework.cloud.stream.schema.registry.model.Schema;
22 | import org.springframework.data.repository.CrudRepository;
23 | import org.springframework.transaction.annotation.Transactional;
24 |
25 | /**
26 | * @author Vinicius Carvalho
27 | */
28 | public interface SchemaRepository extends CrudRepository {
29 |
30 | @Transactional
31 | List findBySubjectAndFormatOrderByVersion(String subject, String format);
32 |
33 | @Transactional
34 | Schema findOneBySubjectAndFormatAndVersion(String subject, String format, Integer version);
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-core/src/main/java/org/springframework/cloud/stream/schema/registry/support/InvalidSchemaException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.schema.registry.support;
18 |
19 | /**
20 | * @author Vinicius Carvalho
21 | */
22 | public class InvalidSchemaException extends RuntimeException {
23 |
24 | public InvalidSchemaException(String message) {
25 | super(message);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-core/src/main/java/org/springframework/cloud/stream/schema/registry/support/SchemaDeletionNotAllowedException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.schema.registry.support;
18 |
19 | /**
20 | * @author Ilayaperumal Gopinathan
21 | */
22 | public class SchemaDeletionNotAllowedException extends RuntimeException {
23 |
24 | public SchemaDeletionNotAllowedException(String message) {
25 | super(message);
26 | }
27 |
28 | public SchemaDeletionNotAllowedException() {
29 | super("Schema Deletion Not Allowed");
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-core/src/main/java/org/springframework/cloud/stream/schema/registry/support/SchemaNotFoundException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.schema.registry.support;
18 |
19 | /**
20 | * @author Vinicius Carvalho
21 | */
22 | public class SchemaNotFoundException extends RuntimeException {
23 |
24 | public SchemaNotFoundException(String message) {
25 | super(message);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-core/src/main/java/org/springframework/cloud/stream/schema/registry/support/UnsupportedFormatException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.schema.registry.support;
18 |
19 | /**
20 | * @author Vinicius Carvalho
21 | */
22 | public class UnsupportedFormatException extends RuntimeException {
23 |
24 | public UnsupportedFormatException(String message) {
25 | super(message);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-core/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | application:
3 | name: SchemaRegistryServer
4 | server:
5 | port: 8990
6 |
7 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-core/src/test/java/org/springframework/cloud/stream/schema/registry/entityScanning/domain/TestEntity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.schema.registry.entityScanning.domain;
18 |
19 | import jakarta.persistence.Column;
20 | import jakarta.persistence.Entity;
21 | import jakarta.persistence.Id;
22 |
23 | /**
24 | * @author Marius Bogoevici
25 | */
26 | @Entity
27 | public class TestEntity {
28 |
29 | @Id
30 | private long id;
31 |
32 | @Column(name = "name")
33 | private String name;
34 |
35 | public long getId() {
36 | return this.id;
37 | }
38 |
39 | public void setId(long id) {
40 | this.id = id;
41 | }
42 |
43 | public String getName() {
44 | return this.name;
45 | }
46 |
47 | public void setName(String name) {
48 | this.name = name;
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-server/.jdk8:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream/a23dc7fe0a4782875060825f3e12c6030373c431/schema-registry/spring-cloud-stream-schema-registry-server/.jdk8
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-server/src/main/java/org/springframework/cloud/stream/schema/registry/server/SchemaRegistryServerApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.schema.registry.server;
18 |
19 | import org.springframework.boot.SpringApplication;
20 | import org.springframework.boot.autoconfigure.SpringBootApplication;
21 | import org.springframework.cloud.stream.schema.registry.EnableSchemaRegistryServer;
22 |
23 | /**
24 | * @author Vinicius Carvalho
25 | */
26 | // @checkstyle:off
27 | @SpringBootApplication
28 | @EnableSchemaRegistryServer
29 | public class SchemaRegistryServerApplication {
30 |
31 | public static void main(String[] args) {
32 | SpringApplication.run(SchemaRegistryServerApplication.class, args);
33 | }
34 |
35 | }
36 | // @checkstyle:on
37 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-server/src/main/resources/META-INF/spring.factories:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-server/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | application:
3 | name: SchemaRegistryServer
4 | server:
5 | port: 8990
6 |
7 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-server/src/test/resources/avro_user_definition_schema_v1.json:
--------------------------------------------------------------------------------
1 | {
2 | "namespace": "example.avro",
3 | "type": "record",
4 | "name": "User",
5 | "fields": [
6 | {
7 | "name": "name",
8 | "type": "string"
9 | },
10 | {
11 | "name": "favorite_number",
12 | "type": [
13 | "int",
14 | "null"
15 | ]
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-server/src/test/resources/avro_user_definition_schema_v2.json:
--------------------------------------------------------------------------------
1 | {
2 | "namespace": "example.avro",
3 | "type": "record",
4 | "name": "User",
5 | "fields": [
6 | {
7 | "name": "name",
8 | "type": "string"
9 | },
10 | {
11 | "name": "favorite_number",
12 | "type": [
13 | "int",
14 | "null"
15 | ]
16 | },
17 | {
18 | "name": "favorite_color",
19 | "type": [
20 | "string",
21 | "null"
22 | ]
23 | }
24 | ]
25 | }
26 |
--------------------------------------------------------------------------------
/schema-registry/spring-cloud-stream-schema-registry-server/src/test/resources/invalid_schema.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "record",
3 | "name": "SuperType",
4 | "namespace": "some.namespace",
5 | "fields": [
6 | {
7 | "name": "field",
8 | "type": "SomeType"
9 | }
10 | ]
11 | }
12 |
--------------------------------------------------------------------------------
/tools/kafka/docker-compose/control-center-ui.yml:
--------------------------------------------------------------------------------
1 | version: '2'
2 |
3 | # Runs a Confluent Control Center UI instance on 'http://localhost:9021'.
4 | #
5 | # Pre-requisites: The brokers are already running.
6 |
7 | services:
8 |
9 | control-center:
10 | image: confluentinc/cp-enterprise-control-center:7.5.0
11 | hostname: control-center
12 | container_name: control-center
13 | depends_on:
14 | - broker1
15 | - broker2
16 | - broker3
17 | ports:
18 | - "9021:9021"
19 | environment:
20 | CONTROL_CENTER_BOOTSTRAP_SERVERS: 'broker1:29091,broker2:29092,broker3:29093'
21 | #CONTROL_CENTER_CONNECT_CONNECT-DEFAULT_CLUSTER: 'connect:8083'
22 | #CONTROL_CENTER_KSQL_KSQLDB1_URL: "http://ksqldb-server:8088"
23 | #CONTROL_CENTER_KSQL_KSQLDB1_ADVERTISED_URL: "http://localhost:8088"
24 | CONTROL_CENTER_SCHEMA_REGISTRY_URL: "http://schema-registry:8081"
25 | CONTROL_CENTER_REPLICATION_FACTOR: 1
26 | CONTROL_CENTER_INTERNAL_TOPICS_PARTITIONS: 1
27 | CONTROL_CENTER_MONITORING_INTERCEPTOR_TOPIC_PARTITIONS: 1
28 | CONFLUENT_METRICS_TOPIC_REPLICATION: 1
29 | PORT: 9021
30 |
--------------------------------------------------------------------------------
/tools/kafka/docker-compose/kraft.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | services:
4 |
5 | kafka:
6 | image: apache/kafka:latest
7 | container_name: kafka
8 | hostname: kafka
9 | ports:
10 | - "9092:9092"
11 | - "9101:9101"
12 | environment:
13 | KAFKA_NODE_ID: 1
14 | KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: 'CONTROLLER:PLAINTEXT,PLAINTEXT_DOCKER:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT'
15 | KAFKA_LISTENERS: 'PLAINTEXT_DOCKER://kafka:29092,CONTROLLER://kafka:29093,PLAINTEXT_HOST://0.0.0.0:9092'
16 | KAFKA_ADVERTISED_LISTENERS: 'PLAINTEXT_DOCKER://kafka:29092,PLAINTEXT_HOST://localhost:9092'
17 | KAFKA_NUM_PARTITIONS: 10
18 | KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
19 | KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
20 | KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
21 | KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
22 | KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
23 | KAFKA_JMX_PORT: 9101
24 | KAFKA_JMX_HOSTNAME: localhost
25 | KAFKA_PROCESS_ROLES: 'broker,controller'
26 | KAFKA_CONTROLLER_QUORUM_VOTERS: '1@kafka:29093'
27 | KAFKA_INTER_BROKER_LISTENER_NAME: 'PLAINTEXT_DOCKER'
28 | KAFKA_CONTROLLER_LISTENER_NAMES: 'CONTROLLER'
29 | KAFKA_LOG_DIRS: '/tmp/kraft-combined-logs'
30 |
--------------------------------------------------------------------------------
/tools/kafka/docker-compose/schema-registry.yml:
--------------------------------------------------------------------------------
1 | version: '2'
2 |
3 | # Runs a Confluent Schema Registry instance on 'http://localhost:8081'.
4 | #
5 | # Pre-requisites: The brokers are already running.
6 |
7 | services:
8 | schema-registry:
9 | image: confluentinc/cp-schema-registry:7.5.0
10 | hostname: schema-registry
11 | container_name: schema-registry
12 | depends_on:
13 | - broker1
14 | - broker2
15 | - broker3
16 | ports:
17 | - "8081:8081"
18 | environment:
19 | SCHEMA_REGISTRY_HOST_NAME: schema-registry
20 | SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: 'broker1:29091,broker2:29092,broker3:29093'
21 | SCHEMA_REGISTRY_LISTENERS: http://0.0.0.0:8081
22 | SCHEMA_REGISTRY_LOG4J_ROOT_LOGLEVEL: WARN
23 |
--------------------------------------------------------------------------------
/tools/rabbitmq/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 | services:
3 | rabbitmq:
4 | image: rabbitmq:management
5 | ports:
6 | - 5672:5672
7 | - 15672:15672
8 |
9 |
--------------------------------------------------------------------------------