use of io.rsocket.frame.FrameType in project spring-framework by spring-projects.
the class MessagingRSocket method handleAndReply.
@SuppressWarnings("deprecation")
private Flux<Payload> handleAndReply(Payload firstPayload, FrameType frameType, Flux<Payload> payloads) {
AtomicReference<Flux<Payload>> responseRef = new AtomicReference<>();
MessageHeaders headers = createHeaders(firstPayload, frameType, responseRef);
AtomicBoolean read = new AtomicBoolean();
Flux<DataBuffer> buffers = payloads.map(this::retainDataAndReleasePayload).doOnSubscribe(s -> read.set(true));
Message<Flux<DataBuffer>> message = MessageBuilder.createMessage(buffers, headers);
return Mono.defer(() -> this.messageHandler.handleMessage(message)).doFinally(s -> {
// Subscription should have happened by now due to ChannelSendOperator
if (!read.get()) {
firstPayload.release();
}
}).thenMany(Flux.defer(() -> responseRef.get() != null ? responseRef.get() : Mono.error(new IllegalStateException("Expected response"))));
}
use of io.rsocket.frame.FrameType in project spring-framework by spring-projects.
the class RSocketMessageHandler method handleNoMatch.
@Override
protected void handleNoMatch(@Nullable RouteMatcher.Route destination, Message<?> message) {
FrameType frameType = RSocketFrameTypeMessageCondition.getFrameType(message);
if (frameType == FrameType.SETUP || frameType == FrameType.METADATA_PUSH) {
// optional handling
return;
}
if (frameType == FrameType.REQUEST_FNF) {
// Can't propagate error to client, so just log
logger.warn("No handler for fireAndForget to '" + destination + "'");
return;
}
Set<FrameType> frameTypes = getHandlerMethods().keySet().stream().map(CompositeMessageCondition::getMessageConditions).filter(conditions -> conditions.get(1).getMatchingCondition(message) != null).map(conditions -> (RSocketFrameTypeMessageCondition) conditions.get(0)).flatMap(condition -> condition.getFrameTypes().stream()).collect(Collectors.toSet());
throw new MessageDeliveryException(frameTypes.isEmpty() ? "No handler for destination '" + destination + "'" : "Destination '" + destination + "' does not support " + frameType + ". " + "Supported interaction(s): " + frameTypes);
}
Aggregations