Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

Commit 22bff0e

Browse files
committed
Support reactive return type for RSocket
Closes gh-408
1 parent 2598256 commit 22bff0e

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.springframework.boot.autoconfigure.rsocket;
2+
3+
import reactor.core.publisher.Flux;
4+
import reactor.core.publisher.Mono;
5+
6+
import org.springframework.nativex.extension.NativeImageConfiguration;
7+
import org.springframework.nativex.extension.NativeImageHint;
8+
import org.springframework.nativex.extension.TypeInfo;
9+
import org.springframework.nativex.type.AccessBits;
10+
11+
// TODO Should be possible to guess that automatically
12+
@NativeImageHint(trigger = RSocketMessagingAutoConfiguration.class, typeInfos= {
13+
@TypeInfo(types = {Mono.class, Flux.class}, access = AccessBits.CLASS)
14+
})
15+
public class RSocketMessagingHints implements NativeImageConfiguration {
16+
}

spring-graalvm-native-configuration/src/main/resources/META-INF/services/org.springframework.nativex.extension.NativeImageConfiguration

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ org.springframework.boot.autoconfigure.jackson.JacksonHints
4545
org.springframework.boot.autoconfigure.jdbc.JdbcHints
4646
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaHints
4747
org.springframework.boot.autoconfigure.r2dbc.R2dbcHints
48+
org.springframework.boot.autoconfigure.rsocket.RSocketMessagingHints
4849
org.springframework.boot.autoconfigure.security.servlet.SecurityHints
4950
org.springframework.boot.autoconfigure.session.SessionHints
5051
org.springframework.boot.autoconfigure.task.TaskHints

spring-graalvm-native-samples/rsocket/src/main/java/com/example/rsocket/RSocketController.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.example.rsocket;
22

3+
import reactor.core.publisher.Mono;
4+
35
import org.springframework.messaging.handler.annotation.MessageMapping;
46
import org.springframework.stereotype.Controller;
57

@@ -10,4 +12,9 @@ public class RSocketController {
1012
Message requestResponse(Message request) {
1113
return new Message("SERVER", "RESPONSE");
1214
}
15+
16+
@MessageMapping("mono-request-response")
17+
Mono<Message> monoRequestResponse(Message request) {
18+
return Mono.just(new Message("SERVER", "RESPONSE"));
19+
}
1320
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env bash
22
if [[ `java -jar /opt/rsc.jar --debug --request --data "{\"origin\":\"Client\",\"interaction\":\"Request\"}" --route request-response tcp://localhost:7000 | grep "Frame => Stream ID: 1 Type: NEXT_COMPLETE Flags: 0b1100000 Length: 81"` ]]; then
3-
exit 0
3+
if [[ `java -jar /opt/rsc.jar --debug --request --data "{\"origin\":\"Client\",\"interaction\":\"Request\"}" --route mono-request-response tcp://localhost:7000 | grep "Frame => Stream ID: 1 Type: NEXT_COMPLETE Flags: 0b1100000 Length: 81"` ]]; then
4+
exit 0
5+
fi
46
else
57
exit 1
68
fi

0 commit comments

Comments
 (0)