Skip to content

Commit

Permalink
Restructure Cloud messaging
Browse files Browse the repository at this point in the history
This commit restructures the cloud messaging group by removing binder
specific checkbox for Spring Cloud Bus and Spring Cloud Stream. A new
"Messaging" group is added with RabbitMQ, Kafka and JMS.

To create a new cloud messaging project, the user should now select the
technology and a binder. To support Spring Cloud Stream with Kafka
streams, a dedicated "Kafka Streams" has been introduced.

Closes gh-557
  • Loading branch information
snicoll committed Feb 14, 2018
1 parent aad08e0 commit e827a99
Show file tree
Hide file tree
Showing 4 changed files with 327 additions and 83 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright 2012-2018 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 io.spring.initializr.service.extension;

import io.spring.initializr.generator.ProjectRequest;
import io.spring.initializr.metadata.Dependency;
import io.spring.initializr.metadata.InitializrMetadata;

import org.springframework.stereotype.Component;

/**
* Determine the appropriate Spring Cloud stream dependency to use based on the
* selected messaging technology.
* <p>
* Does not replace the messaging technology jar by the relevant binder. If more than
* one tech is selected, it is far more easier to remove the unnecessary binder jar than
* to figure out the name of the tech jar to add to keep support for that technology.
*
* @author Stephane Nicoll
*/
@Component
public class SpringCloudMessagingRequestPostProcessor
extends AbstractProjectRequestPostProcessor {

static final Dependency KAFKA_BINDER = Dependency.withId("cloud-stream-binder-kafka",
"org.springframework.cloud", "spring-cloud-stream-binder-kafka");

static final Dependency RABBIT_BINDER = Dependency.withId(
"cloud-stream-binder-rabbit", "org.springframework.cloud",
"spring-cloud-stream-binder-rabbit");

@Override
public void postProcessAfterResolution(ProjectRequest request,
InitializrMetadata metadata) {
boolean hasSpringCloudStream = hasDependency(request, "cloud-stream");
boolean hasReactiveSpringCloudStream = hasDependency(request,
"reactive-cloud-stream");
boolean hasSpringCloudBus = hasDependency(request, "cloud-bus");
boolean hasSpringCloudTurbineStream = hasDependency(request,
"cloud-turbine-stream");
if (hasSpringCloudStream || hasReactiveSpringCloudStream || hasSpringCloudBus
|| hasSpringCloudTurbineStream) {
if (hasDependencies(request, "amqp")) {
request.getResolvedDependencies().add(RABBIT_BINDER);
}
if (hasDependencies(request, "kafka")) {
request.getResolvedDependencies().add(KAFKA_BINDER);
}
}
}

}

157 changes: 74 additions & 83 deletions initializr-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,63 @@ initializr:
description: Accessing Data with GemFire
- rel: reference
href: http://docs.spring.io/spring-boot/docs/{bootVersion}/reference/htmlsingle/#boot-features-gemfire
- name: Messaging
content:
- name: RabbitMQ
id: amqp
description: Advanced Message Queuing Protocol via spring-rabbit
weight: 100
keywords:
- messaging
links:
- rel: guide
href: https://spring.io/guides/gs/messaging-rabbitmq/
description: Messaging with RabbitMQ
- rel: reference
href: http://docs.spring.io/spring-boot/docs/{bootVersion}/reference/htmlsingle/#boot-features-amqp
- name: Kafka
id: kafka
weight: 100
description: Kafka messaging support using Spring Kafka
versionRange: 1.5.0.RC1
groupId: org.springframework.kafka
artifactId: spring-kafka
starter: false
keywords:
- messaging
links:
- rel: reference
href: http://docs.spring.io/spring-boot/docs/{bootVersion}/reference/htmlsingle/#boot-features-kafka
- name: JMS (ActiveMQ)
id: activemq
description: Java Message Service API via Apache ActiveMQ
versionRange: 1.4.0.RC1
links:
- rel: guide
href: https://spring.io/guides/gs/messaging-jms/
description: Messaging with JMS
- rel: reference
href: http://docs.spring.io/spring-boot/docs/{bootVersion}/reference/htmlsingle/#boot-features-activemq
- name: JMS (Artemis)
id: artemis
description: Java Message Service API via Apache Artemis
versionRange: 1.3.0.RELEASE
links:
- rel: guide
href: https://spring.io/guides/gs/messaging-jms/
description: Messaging with JMS
- rel: reference
href: http://docs.spring.io/spring-boot/docs/{bootVersion}/reference/htmlsingle/#boot-features-artemis
- name: JMS (HornetQ)
id: hornetq
description: Java Message Service API via HornetQ
versionRange: "[1.1.0.RELEASE,1.4.0.RC1)"
links:
- rel: guide
href: https://spring.io/guides/gs/messaging-jms/
description: Messaging with JMS
- rel: reference
href: http://docs.spring.io/spring-boot/docs/{bootVersion}/reference/htmlsingle/#boot-features-hornetq
- name: Cloud Core
bom: spring-cloud
versionRange: 1.2.3.RELEASE
Expand All @@ -748,7 +805,7 @@ initializr:
artifactId: spring-cloud-starter-oauth2
- name: Cloud Task
id: cloud-task
description: Task result tracking along with integration with batch and streams
description: Task result tracking and integration with Spring Batch
groupId: org.springframework.cloud
artifactId: spring-cloud-starter-task
versionRange: "1.3.0.RELEASE"
Expand Down Expand Up @@ -927,7 +984,7 @@ initializr:
- versionRange: "1.5.0.BUILD-SNAPSHOT"
- name: Turbine Stream
id: cloud-turbine-stream
description: Circuit breaker metric aggregation using spring-cloud-netflix with Turbine and Spring Cloud Stream (choose a specific Stream binder implementation to complement this)
description: Circuit breaker metric aggregation using spring-cloud-netflix with Turbine and Spring Cloud Stream (requires a binder, e.g. Kafka or RabbitMQ)
versionRange: 1.3.0.RELEASE
groupId: org.springframework.cloud
artifactId: spring-cloud-starter-netflix-turbine-stream
Expand Down Expand Up @@ -974,41 +1031,25 @@ initializr:
bom: spring-cloud
versionRange: 1.2.3.RELEASE
content:
- name: Cloud Bus AMQP
id: cloud-bus-amqp
description: A simple control bus with AMQP and spring-cloud-bus-amqp
- name: Cloud Bus
id: cloud-bus
description: A simple control bus using Spring Cloud Stream (requires a binder, e.g. Kafka or RabbitMQ)
groupId: org.springframework.cloud
artifactId: spring-cloud-starter-bus-amqp
- name: Cloud Bus Kafka
id: cloud-bus-kafka
description: A simple control bus with Kafka and spring-cloud-bus
versionRange: "1.3.0.RELEASE"
groupId: org.springframework.cloud
artifactId: spring-cloud-starter-bus-kafka
- name: Stream Binder Rabbit
id: cloud-stream-binder-rabbit
description: Messaging microservices with RabbitMQ
versionRange: 1.3.0.RELEASE
groupId: org.springframework.cloud
artifactId: spring-cloud-starter-stream-rabbit
- name: Stream Binder Kafka
id: cloud-stream-binder-kafka
description: Messaging microservices with Kafka
artifactId: spring-cloud-bus
- name: Cloud Stream
id: cloud-stream
description: Messaging microservices with Spring Cloud Stream (requires a binder, e.g. Kafka or RabbitMQ)
versionRange: 1.3.0.RELEASE
weight: 90
groupId: org.springframework.cloud
artifactId: spring-cloud-stream-binder-kafka
- name: Stream Binder "Kafka Streams"
id: cloud-stream-binder-kafka-streams
description: Stream processing microservices with Kafka Streams API
versionRange: 1.5.7.RELEASE
artifactId: spring-cloud-stream
- name: Reactive Cloud Stream
id: reactive-cloud-stream
description: Reactive messaging microservices with Spring Cloud Stream (requires a binder, e.g. Kafka or RabbitMQ)
versionRange: 2.0.0.BUILD-SNAPSHOT
weight: 90
groupId: org.springframework.cloud
artifactId: spring-cloud-stream-binder-kstream
links:
- rel: guide
href: https://github.com/spring-cloud/spring-cloud-stream-samples/tree/master/kstream
description: Samples for using Kafka Streams with Spring Cloud stream
- rel: reference
href: https://docs.spring.io/spring-cloud-stream/docs/current/reference/htmlsingle/#_kafka_streams_binding_capabilities_of_spring_cloud_stream
artifactId: spring-cloud-stream-reactive
- name: Cloud AWS
bom: spring-cloud
versionRange: 1.2.3.RELEASE
Expand Down Expand Up @@ -1177,56 +1218,6 @@ initializr:
links:
- rel: reference
href: http://docs.spring.io/spring-boot/docs/{bootVersion}/reference/htmlsingle/#boot-features-email
- name: AMQP
id: amqp
description: Advanced Message Queuing Protocol via spring-rabbit
links:
- rel: guide
href: https://spring.io/guides/gs/messaging-rabbitmq/
description: Messaging with RabbitMQ
- rel: reference
href: http://docs.spring.io/spring-boot/docs/{bootVersion}/reference/htmlsingle/#boot-features-amqp
- name: Kafka
id: kafka
weight: 100
description: Kafka messaging support using Spring Kafka
versionRange: 1.5.0.RC1
groupId: org.springframework.kafka
artifactId: spring-kafka
starter: false
links:
- rel: reference
href: http://docs.spring.io/spring-boot/docs/{bootVersion}/reference/htmlsingle/#boot-features-kafka
- name: JMS (ActiveMQ)
id: activemq
description: Java Message Service API via Apache ActiveMQ
versionRange: 1.4.0.RC1
links:
- rel: guide
href: https://spring.io/guides/gs/messaging-jms/
description: Messaging with JMS
- rel: reference
href: http://docs.spring.io/spring-boot/docs/{bootVersion}/reference/htmlsingle/#boot-features-activemq
- name: JMS (Artemis)
id: artemis
description: Java Message Service API via Apache Artemis
versionRange: 1.3.0.RELEASE
links:
- rel: guide
href: https://spring.io/guides/gs/messaging-jms/
description: Messaging with JMS
- rel: reference
href: http://docs.spring.io/spring-boot/docs/{bootVersion}/reference/htmlsingle/#boot-features-artemis
- name: JMS (HornetQ)
id: hornetq
description: Java Message Service API via HornetQ
versionRange: "[1.1.0.RELEASE,1.4.0.RC1)"
links:
- rel: guide
href: https://spring.io/guides/gs/messaging-jms/
description: Messaging with JMS
- rel: reference
href: http://docs.spring.io/spring-boot/docs/{bootVersion}/reference/htmlsingle/#boot-features-hornetq
- name: Apache Camel
id: camel
versionRange: "[1.4.0.RELEASE,2.0.0.M1)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.spring.initializr.generator.ProjectGenerator;
import io.spring.initializr.generator.ProjectRequest;
import io.spring.initializr.generator.ProjectRequestPostProcessor;
import io.spring.initializr.metadata.Dependency;
import io.spring.initializr.metadata.InitializrMetadataProvider;
import io.spring.initializr.test.generator.GradleBuildAssert;
import io.spring.initializr.test.generator.PomAssert;
Expand All @@ -45,6 +46,10 @@ public abstract class AbstractRequestPostProcessorTests {
@Autowired
private InitializrMetadataProvider metadataProvider;

protected Dependency getDependency(String id) {
return this.metadataProvider.get().getDependencies().get(id);
}

protected PomAssert generateMavenPom(ProjectRequest request) {
request.setType("maven-build");
String content = new String(projectGenerator.generateMavenPom(request));
Expand Down
Loading

0 comments on commit e827a99

Please sign in to comment.