Skip to content

Commit de0168e

Browse files
authored
Adds support for RSocket (spring-cloud#239)
* Creates Destination.Factory to create Destinations This allows the default PathDestinationFactory to send to all via ant patterns and RSocket to use tags. * Adds spring-cloud-bus-rsocket to dependencies pom * Moves stream to separate autoconfig * Adds AntPathMatcher to handle isFromSelf * Adds support for application/cbor * Adds support for default tags to send on queries. * Adds BusRSocketEnvironmentPostProcessor This adds a bus=true tag to the RSocket routing client for registration with the RSocket routing broker All tags in the remote event must be present from local configuration. * Updates repo.spring.io urls * Adds spring-cloud-starter-bus-stream which includes spring-cloud-bus and spring-cloud-stream. This is because spring-cloud-stream is now optional in spring-cloud-bus. This is useful for bus users that want to use a different stream binder than amqp and kafka.
1 parent 5bb2149 commit de0168e

File tree

43 files changed

+881
-173
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+881
-173
lines changed

.mvn/maven.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-DaltSnapshotDeploymentRepository=repo.spring.io::default::https://repo.spring.io/libs-snapshot-local -P spring
1+
-DaltSnapshotDeploymentRepository=repo.spring.io::default::https://repo.spring.io/snapshot -P spring

.settings.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
<repository>
2424
<id>spring-snapshots</id>
2525
<name>Spring Snapshots</name>
26-
<url>https://repo.spring.io/libs-snapshot-local</url>
26+
<url>https://repo.spring.io/snapshot</url>
2727
<snapshots>
2828
<enabled>true</enabled>
2929
</snapshots>
3030
</repository>
3131
<repository>
3232
<id>spring-milestones</id>
3333
<name>Spring Milestones</name>
34-
<url>https://repo.spring.io/libs-milestone-local</url>
34+
<url>https://repo.spring.io/milestone</url>
3535
<snapshots>
3636
<enabled>false</enabled>
3737
</snapshots>
@@ -49,15 +49,15 @@
4949
<pluginRepository>
5050
<id>spring-snapshots</id>
5151
<name>Spring Snapshots</name>
52-
<url>https://repo.spring.io/libs-snapshot-local</url>
52+
<url>https://repo.spring.io/snapshot</url>
5353
<snapshots>
5454
<enabled>true</enabled>
5555
</snapshots>
5656
</pluginRepository>
5757
<pluginRepository>
5858
<id>spring-milestones</id>
5959
<name>Spring Milestones</name>
60-
<url>https://repo.spring.io/libs-milestone-local</url>
60+
<url>https://repo.spring.io/milestone</url>
6161
<snapshots>
6262
<enabled>false</enabled>
6363
</snapshots>

pom.xml

+20-5
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@
2121
<modules>
2222
<module>spring-cloud-bus-dependencies</module>
2323
<module>spring-cloud-bus</module>
24+
<module>spring-cloud-bus-rsocket</module>
2425
<module>spring-cloud-bus-tests</module>
2526
<module>spring-cloud-starter-bus-amqp</module>
2627
<module>spring-cloud-starter-bus-kafka</module>
28+
<module>spring-cloud-starter-bus-stream</module>
2729
<module>docs</module>
2830
</modules>
2931

3032
<properties>
3133
<spring-cloud-commons.version>3.0.0-SNAPSHOT</spring-cloud-commons.version>
3234
<spring-cloud-stream.version>3.1.0-SNAPSHOT</spring-cloud-stream.version>
35+
<spring-cloud-function.version>3.1.0-SNAPSHOT</spring-cloud-function.version>
3336
<bintray.package>bus</bintray.package>
3437
</properties>
3538

@@ -75,7 +78,7 @@
7578
<repository>
7679
<id>spring-snapshots</id>
7780
<name>Spring Snapshots</name>
78-
<url>https://repo.spring.io/libs-snapshot-local</url>
81+
<url>https://repo.spring.io/snapshot</url>
7982
<snapshots>
8083
<enabled>true</enabled>
8184
</snapshots>
@@ -86,7 +89,7 @@
8689
<repository>
8790
<id>spring-milestones</id>
8891
<name>Spring Milestones</name>
89-
<url>https://repo.spring.io/libs-milestone-local</url>
92+
<url>https://repo.spring.io/milestone</url>
9093
<snapshots>
9194
<enabled>false</enabled>
9295
</snapshots>
@@ -104,7 +107,7 @@
104107
<pluginRepository>
105108
<id>spring-snapshots</id>
106109
<name>Spring Snapshots</name>
107-
<url>https://repo.spring.io/libs-snapshot-local</url>
110+
<url>https://repo.spring.io/snapshot</url>
108111
<snapshots>
109112
<enabled>true</enabled>
110113
</snapshots>
@@ -115,15 +118,15 @@
115118
<pluginRepository>
116119
<id>spring-milestones</id>
117120
<name>Spring Milestones</name>
118-
<url>https://repo.spring.io/libs-milestone-local</url>
121+
<url>https://repo.spring.io/milestone</url>
119122
<snapshots>
120123
<enabled>false</enabled>
121124
</snapshots>
122125
</pluginRepository>
123126
<pluginRepository>
124127
<id>spring-releases</id>
125128
<name>Spring Releases</name>
126-
<url>https://repo.spring.io/libs-release-local</url>
129+
<url>https://repo.spring.io/release</url>
127130
<snapshots>
128131
<enabled>false</enabled>
129132
</snapshots>
@@ -159,6 +162,18 @@
159162
<type>pom</type>
160163
<scope>import</scope>
161164
</dependency>
165+
<dependency>
166+
<groupId>org.springframework.cloud</groupId>
167+
<artifactId>spring-cloud-function-dependencies</artifactId>
168+
<version>${spring-cloud-function.version}</version>
169+
<type>pom</type>
170+
<scope>import</scope>
171+
</dependency>
172+
<dependency>
173+
<groupId>org.springframework.cloud</groupId>
174+
<artifactId>spring-cloud-function-rsocket</artifactId>
175+
<version>${spring-cloud-function.version}</version>
176+
</dependency>
162177
</dependencies>
163178
</dependencyManagement>
164179

spring-cloud-bus-dependencies/pom.xml

+14-4
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,21 @@
2626
<artifactId>spring-cloud-starter-bus-kafka</artifactId>
2727
<version>${project.version}</version>
2828
</dependency>
29+
<dependency>
30+
<groupId>org.springframework.cloud</groupId>
31+
<artifactId>spring-cloud-starter-bus-stream</artifactId>
32+
<version>${project.version}</version>
33+
</dependency>
2934
<dependency>
3035
<groupId>org.springframework.cloud</groupId>
3136
<artifactId>spring-cloud-bus</artifactId>
3237
<version>${project.version}</version>
3338
</dependency>
39+
<dependency>
40+
<groupId>org.springframework.cloud</groupId>
41+
<artifactId>spring-cloud-bus-rsocket</artifactId>
42+
<version>${project.version}</version>
43+
</dependency>
3444
</dependencies>
3545
</dependencyManagement>
3646
<profiles>
@@ -40,7 +50,7 @@
4050
<repository>
4151
<id>spring-snapshots</id>
4252
<name>Spring Snapshots</name>
43-
<url>https://repo.spring.io/libs-snapshot-local</url>
53+
<url>https://repo.spring.io/snapshot</url>
4454
<snapshots>
4555
<enabled>true</enabled>
4656
</snapshots>
@@ -51,7 +61,7 @@
5161
<repository>
5262
<id>spring-milestones</id>
5363
<name>Spring Milestones</name>
54-
<url>https://repo.spring.io/libs-milestone-local</url>
64+
<url>https://repo.spring.io/milestone</url>
5565
<snapshots>
5666
<enabled>false</enabled>
5767
</snapshots>
@@ -69,7 +79,7 @@
6979
<pluginRepository>
7080
<id>spring-snapshots</id>
7181
<name>Spring Snapshots</name>
72-
<url>https://repo.spring.io/libs-snapshot-local</url>
82+
<url>https://repo.spring.io/snapshot</url>
7383
<snapshots>
7484
<enabled>true</enabled>
7585
</snapshots>
@@ -80,7 +90,7 @@
8090
<pluginRepository>
8191
<id>spring-milestones</id>
8292
<name>Spring Milestones</name>
83-
<url>https://repo.spring.io/libs-milestone-local</url>
93+
<url>https://repo.spring.io/milestone</url>
8494
<snapshots>
8595
<enabled>false</enabled>
8696
</snapshots>

spring-cloud-bus-rsocket/pom.xml

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<artifactId>spring-cloud-bus-rsocket</artifactId>
8+
<packaging>jar</packaging>
9+
10+
<name>spring-cloud-bus-rsocket</name>
11+
<description>Spring Cloud Bus</description>
12+
13+
<parent>
14+
<groupId>org.springframework.cloud</groupId>
15+
<artifactId>spring-cloud-bus-parent</artifactId>
16+
<version>3.0.0-SNAPSHOT</version>
17+
<relativePath>..</relativePath> <!-- lookup parent from repository -->
18+
</parent>
19+
20+
<properties>
21+
<rsocket-routing.version>0.2.0-SNAPSHOT</rsocket-routing.version>
22+
</properties>
23+
24+
<dependencies>
25+
<dependency>
26+
<groupId>org.springframework.boot</groupId>
27+
<artifactId>spring-boot-configuration-processor</artifactId>
28+
<optional>true</optional>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.springframework.boot</groupId>
32+
<artifactId>spring-boot-starter-actuator</artifactId>
33+
<optional>true</optional>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.springframework.cloud</groupId>
37+
<artifactId>spring-cloud-bus</artifactId>
38+
</dependency>
39+
<dependency>
40+
<groupId>org.springframework.cloud</groupId>
41+
<artifactId>spring-cloud-function-rsocket</artifactId>
42+
</dependency>
43+
<dependency>
44+
<groupId>com.fasterxml.jackson.dataformat</groupId>
45+
<artifactId>jackson-dataformat-cbor</artifactId>
46+
</dependency>
47+
<dependency>
48+
<groupId>io.rsocket.routing</groupId>
49+
<artifactId>rsocket-routing-client-spring</artifactId>
50+
<version>${rsocket-routing.version}</version>
51+
<optional>true</optional>
52+
</dependency>
53+
<dependency>
54+
<groupId>org.springframework.boot</groupId>
55+
<artifactId>spring-boot-autoconfigure-processor</artifactId>
56+
<optional>true</optional>
57+
</dependency>
58+
<dependency>
59+
<groupId>org.springframework.boot</groupId>
60+
<artifactId>spring-boot-starter-test</artifactId>
61+
<scope>test</scope>
62+
</dependency>
63+
<dependency>
64+
<groupId>org.junit.vintage</groupId>
65+
<artifactId>junit-vintage-engine</artifactId>
66+
<scope>test</scope>
67+
</dependency>
68+
<dependency>
69+
<groupId>org.springframework.cloud</groupId>
70+
<artifactId>spring-cloud-test-support</artifactId>
71+
<scope>test</scope>
72+
</dependency>
73+
</dependencies>
74+
75+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright 2015-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.bus.rsocket;
18+
19+
import io.rsocket.RSocket;
20+
import io.rsocket.routing.client.spring.RoutingClientProperties;
21+
import io.rsocket.routing.client.spring.RoutingRSocketRequester;
22+
23+
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
24+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
25+
import org.springframework.boot.context.properties.EnableConfigurationProperties;
26+
import org.springframework.cloud.bus.BusAutoConfiguration;
27+
import org.springframework.cloud.bus.BusProperties;
28+
import org.springframework.cloud.bus.BusRefreshAutoConfiguration;
29+
import org.springframework.cloud.bus.ConditionalOnBusEnabled;
30+
import org.springframework.cloud.bus.PathServiceMatcherAutoConfiguration;
31+
import org.springframework.context.annotation.Bean;
32+
import org.springframework.context.annotation.Configuration;
33+
34+
/**
35+
* @author Spencer Gibb
36+
*/
37+
@Configuration(proxyBeanMethods = false)
38+
@ConditionalOnBusEnabled
39+
@EnableConfigurationProperties(BusRSocketProperties.class)
40+
@ConditionalOnClass({ RSocket.class, RoutingRSocketRequester.class })
41+
@AutoConfigureBefore({ BusAutoConfiguration.class, BusRefreshAutoConfiguration.class,
42+
PathServiceMatcherAutoConfiguration.class })
43+
public class BusRSocketAutoConfiguration {
44+
45+
@Bean
46+
public RoutingClientDestinationFactory routingClientDestinationFactory(BusRSocketProperties properties) {
47+
return new RoutingClientDestinationFactory(properties);
48+
}
49+
50+
@Bean
51+
public RSocketRequesterBusBridge rSocketRequesterBusBridge(RoutingRSocketRequester requester) {
52+
return new RSocketRequesterBusBridge(requester);
53+
}
54+
55+
@Bean
56+
public RSocketServiceMatcher rSocketServiceMatcher(BusProperties properties,
57+
RoutingClientProperties routingClientProperties) {
58+
return new RSocketServiceMatcher(properties.getId(), routingClientProperties);
59+
}
60+
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright 2012-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.bus.rsocket;
18+
19+
import java.util.HashMap;
20+
import java.util.Map;
21+
22+
import io.rsocket.routing.client.spring.RoutingClientProperties;
23+
24+
import org.springframework.boot.SpringApplication;
25+
import org.springframework.boot.env.EnvironmentPostProcessor;
26+
import org.springframework.core.env.ConfigurableEnvironment;
27+
28+
import static org.springframework.cloud.bus.BusEnvironmentPostProcessor.addOrReplace;
29+
30+
/**
31+
* {@link EnvironmentPostProcessor} that sets the default properties for the RSocket
32+
* Routing Client.
33+
*/
34+
public class BusRSocketEnvironmentPostProcessor implements EnvironmentPostProcessor {
35+
36+
static final String DEFAULTS_PROPERTY_SOURCE_NAME = "springCloudBusRSocketDefaultProperties";
37+
38+
@Override
39+
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
40+
Map<String, Object> defaults = new HashMap<>();
41+
defaults.put(RoutingClientProperties.CONFIG_PREFIX + ".tags.bus", true);
42+
addOrReplace(environment.getPropertySources(), defaults, DEFAULTS_PROPERTY_SOURCE_NAME, false);
43+
}
44+
45+
}

0 commit comments

Comments
 (0)