From 55591889e10a122c3ab6047c7df7ccae408a2fdc Mon Sep 17 00:00:00 2001 From: Ilayaperumal Gopinathan Date: Tue, 11 Aug 2015 11:22:04 -0700 Subject: [PATCH] Add auto-config for Local binder - Make `local` binder compile dependency as optional - Add `local` binder auto configuration - This imports local binder properties and binder - Add `spring.factories` to enable auto configuration when this archive is on the classpath --- .../config/LocalBinderAutoConfiguration.java | 33 +++++++++++++++++++ .../local-binder.properties | 5 +++ .../main/resources/META-INF/spring.factories | 2 ++ spring-cloud-stream/pom.xml | 1 + 4 files changed, 41 insertions(+) create mode 100644 spring-cloud-stream-binders/spring-cloud-stream-binder-local/src/main/java/org/springframework/cloud/stream/binder/local/config/LocalBinderAutoConfiguration.java create mode 100644 spring-cloud-stream-binders/spring-cloud-stream-binder-local/src/main/resources/META-INF/spring-cloud-stream/local-binder.properties create mode 100644 spring-cloud-stream-binders/spring-cloud-stream-binder-local/src/main/resources/META-INF/spring.factories diff --git a/spring-cloud-stream-binders/spring-cloud-stream-binder-local/src/main/java/org/springframework/cloud/stream/binder/local/config/LocalBinderAutoConfiguration.java b/spring-cloud-stream-binders/spring-cloud-stream-binder-local/src/main/java/org/springframework/cloud/stream/binder/local/config/LocalBinderAutoConfiguration.java new file mode 100644 index 000000000..54fcee432 --- /dev/null +++ b/spring-cloud-stream-binders/spring-cloud-stream-binder-local/src/main/java/org/springframework/cloud/stream/binder/local/config/LocalBinderAutoConfiguration.java @@ -0,0 +1,33 @@ +/* + * Copyright 2015 the original author or authors. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.cloud.stream.binder.local.config; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.cloud.stream.binder.Binder; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; +import org.springframework.context.annotation.PropertySource; + +/** + * Auto configuration for Local (in-memory) {@link Binder}. + * + * @author Ilayaperumal Gopinathan + */ +@Configuration +@ConditionalOnMissingBean(Binder.class) +@Import(LocalMessageChannelBinderConfiguration.class) +@PropertySource("classpath:/META-INF/spring-cloud-stream/local-binder.properties") +public class LocalBinderAutoConfiguration { +} diff --git a/spring-cloud-stream-binders/spring-cloud-stream-binder-local/src/main/resources/META-INF/spring-cloud-stream/local-binder.properties b/spring-cloud-stream-binders/spring-cloud-stream-binder-local/src/main/resources/META-INF/spring-cloud-stream/local-binder.properties new file mode 100644 index 000000000..646166481 --- /dev/null +++ b/spring-cloud-stream-binders/spring-cloud-stream-binder-local/src/main/resources/META-INF/spring-cloud-stream/local-binder.properties @@ -0,0 +1,5 @@ +spring.cloud.stream.binder.local.polling: 1000 +spring.cloud.stream.binder.local.executor.corePoolSize: 0 +spring.cloud.stream.binder.local.executor.maxPoolSize: 400 +#spring.cloud.stream.binder.local.executor.queueSize: # defaults to Integer.MAX_VALUE +spring.cloud.stream.binder.local.executor.keepAliveSeconds: 60 diff --git a/spring-cloud-stream-binders/spring-cloud-stream-binder-local/src/main/resources/META-INF/spring.factories b/spring-cloud-stream-binders/spring-cloud-stream-binder-local/src/main/resources/META-INF/spring.factories new file mode 100644 index 000000000..83df102ba --- /dev/null +++ b/spring-cloud-stream-binders/spring-cloud-stream-binder-local/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration:\ +org.springframework.cloud.stream.binder.local.config.LocalBinderAutoConfiguration diff --git a/spring-cloud-stream/pom.xml b/spring-cloud-stream/pom.xml index cc49b8513..8ad1b238c 100644 --- a/spring-cloud-stream/pom.xml +++ b/spring-cloud-stream/pom.xml @@ -46,6 +46,7 @@ org.springframework.cloud spring-cloud-stream-binder-local + true org.springframework.cloud