sdk-java/examples/spring-rsocket
Pierangelo Di Pilato a6580e5e1b
[2.2] Bump version to 2.2.2-SNAPSHOT (#440)
Run:
```
./mvnw versions:set -DnewVersion=2.2.2-SNAPSHOT -DgenerateBackupPoms=false -B
```

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>
2021-12-21 13:15:56 +01:00
..
src Add support for RSockets with Spring (#349) 2021-03-05 09:18:19 +01:00
README.md Add support for RSockets with Spring (#349) 2021-03-05 09:18:19 +01:00
pom.xml [2.2] Bump version to 2.2.2-SNAPSHOT (#440) 2021-12-21 13:15:56 +01:00

README.md

Spring RSockets + CloudEvents sample

Build

mvn package

Start Server

mvn spring-boot:run

You can try sending a request using rsc, and it echos back a cloud event the same body and with new ce-* headers:

rsc --request --dataMimeType=application/cloudevents+json --route=event \
    --data='{"data": {"value": "Foo"},
           "id": "1", 
           "source": "cloud-event-example", 
           "type": "my.application.Foo", 
           "specversion": "1.0"}' \
    --debug tcp://localhost:7000

The event endpoint is implemented like this (the request and response are modelled directly as a CloudEvent):

@MessageMapping("event")
public Mono<CloudEvent> event(@RequestBody Mono<CloudEvent> body) {
	return ...;
}

and to make that work we need to install the codecs:

@Bean
@Order(-1)
public RSocketStrategiesCustomizer cloudEventsCustomizer() {
	return new RSocketStrategiesCustomizer() {
		@Override
		public void customize(Builder strategies) {
			strategies.encoder(new CloudEventEncoder());
			strategies.decoder(new CloudEventDecoder());
		}
	};

}