https://github.com/scalecube/scalecube-spring-boot-starter
https://github.com/scalecube/scalecube-spring-boot-starter
Last synced: 22 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/scalecube/scalecube-spring-boot-starter
- Owner: scalecube
- Created: 2020-01-22T10:37:31.000Z (over 5 years ago)
- Default Branch: develop
- Last Pushed: 2023-05-22T21:47:50.000Z (almost 2 years ago)
- Last Synced: 2025-04-10T05:09:27.993Z (22 days ago)
- Language: Java
- Size: 250 KB
- Stars: 5
- Watchers: 18
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Spring Boot Scale Cube Starter
[Scale Cube](http://scalecube.io) Spring Boot Project it easy to create
[Spring Boot](https://github.com/spring-projects/spring-boot/) application using Scale Cube.> Scale Cube is A Novel Open-source application-platform that addresses inherent challenges
involved in the development of distributed computing.## Released version
You can introduce the latest dubbo-spring-boot-starter to your project by adding the
following dependency to your pom.xml```xml
2.1.6.RELEASE
org.springframework.boot
spring-boot-dependencies
${spring-boot.version}
pom
import
io.scalecube
scalecube-bom
${spring-boot.version}
pom
import
io.scalecube
spring-boot-starter-scalecube
${spring-boot.version}
io.scalecube
scalecube-services-transport-rsocket
io.scalecube
scalecube-services-discovery
io.scalecube
scalecube-services-transport-jackson
```
### Build from Source
If you'd like to attempt to experience latest features, you also can build from source as follow:
1. Maven install current project in your local repository.
> Maven install = `mvn install`## Getting Started
If you don't know about Scale Cube, please take a few minutes to learn
[www.scalecube.io](http://scalecube.io).Usually, There are two usage scenarios for Scale Cube applications, one is Scale Cube service(s)
provider,
another is Scale Cube service(s) consumer, thus let's get a quick start on them.First of all, we suppose an interface as Scale Cube Service that a service provider exports
and a service client consumes:```java
@Service
public interface ExampleService {@ServiceMethod
Mono sayHello(String name);@ServiceMethod
Flux helloStream();@ServiceMethod
Flux helloBidirectional(Flux nameSteam);
}
```### Scale Cube service(s) provider
1. Service Provider implements `ExampleService`
```java
@Component
public class DefaultExampleService implements ExampleService {
@Override
public Mono sayHello(String name) {
return Mono.just("Hello, " + request);
}
@Override
public Flux helloStream() {
return Flux.just("Hello, Eugene", "Hello, Kate");
}
@Override
public Flux helloBidirectional(Flux nameSteam) {
return nameSteam.map("Hello, "::concat);
}
}
```2. Provides a bootstrap class
```java
@SpringBootApplication
public class ScalecubeProviderDemo {
public static void main(String[] args) {
SpringApplication.run(DubboProviderDemo.class,args);
}
}
```3. Configures the `application.yml`
```yaml
spring:
scalecube:
discovery:
transport:
port: 21000
```### Scale Cube Service Consumer
1. Service Consumer must depend on `ExampleService`
```java
@Component
public class ExampleServiceConsumer {
@SelectorStrategy(routerType = RoundRobinRouter)
private final ExampleService exampleService;
public ExampleServiceConsumer(ExampleService exampleService) {
this.exampleService = exampleService;
}
public void printGreeting() {
exampleService.helloStream().subscribe(System.out::println);
}
}
```
2. Service Consumer also provides a bootstrap class```java
@SpringBootApplication
public class ScalecubeConsumerDemo {
public static void main(String[] args) {
SpringApplication.run(DubboProviderDemo.class,args);
}
@Bean
public ApplicationRunner runner(ExampleServiceConsumer exampleServiceConsumer) {
return args -> exampleServiceConsumer.printGreeting();
}
}
```3. Configures `application.yml`
```yaml
spring:
scalecube:
discovery:
membership:
seed-members:
- localhost:21000
```
## Getting HelpHaving trouble with Scale Cube Spring Boot? We'd like to help!
* Ask a question - You can write to [Gitter](https://gitter.im/scalecube/Lobby).
* Report bugs at
[github.com/scalecube/spring-boot-scalecube-starter/issues](https://github.com/scalecube/spring-boot-scalecube-starter/issues).