GH-660 Update RSocket documentation with Messaging bits
This commit is contained in:
@@ -45,15 +45,22 @@ Once connected to RSocket we use `route` operation to specify which function we
|
|||||||
payload via `data` operation. Then we use one of the `retrieve` operations that best suits our desired interaction
|
payload via `data` operation. Then we use one of the `retrieve` operations that best suits our desired interaction
|
||||||
(RSocket supports multiple interaction models such as fire-and-forget, request-reply etc.)
|
(RSocket supports multiple interaction models such as fire-and-forget, request-reply etc.)
|
||||||
|
|
||||||
If you want to provide additional information that you would normally communicate via Message headers, you can use `metadata` operation for that.
|
### Messaging
|
||||||
|
|
||||||
|
If you want to provide and/or receive additional information that you would normally communicate via Message headers you can send and receive Spring `Message`.
|
||||||
|
For example, the following tests case demonstrates how you can accomplish that.
|
||||||
```
|
```
|
||||||
rsocketRequesterBuilder.tcp("localhost", port)
|
Person p = new Person();
|
||||||
.route(“uppercase”)
|
p.setName("Ricky");
|
||||||
.metadata("{\”header_key\":\”header-value\"}", MimeTypeUtils.APPLICATION_JSON)
|
Message<Person> message = MessageBuilder.withPayload(p).setHeader("someHeader", "foo").build();
|
||||||
.data("\"hello\"")
|
|
||||||
.retrieveMono(String.class)
|
Message<Person> result = rsocketRequesterBuilder.tcp("localhost", port)
|
||||||
.subscribe(System.out::println);
|
.route("pojoMessageToPojo")
|
||||||
|
.data(message)
|
||||||
|
.retrieveMono(new ParameterizedTypeReference<Message<Employee>>() {})
|
||||||
|
.block();
|
||||||
```
|
```
|
||||||
|
Aside from sending `Message`, note the usage of `ParameterizedTypeReference` to specify that we want not only `Message` in return but also `Message` with specific payload type.
|
||||||
|
|
||||||
### Order of priority for routing instructions
|
### Order of priority for routing instructions
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user