diff --git a/spring-integration-rsocket/src/main/java/org/springframework/integration/rsocket/AbstractRSocketConnector.java b/spring-integration-rsocket/src/main/java/org/springframework/integration/rsocket/AbstractRSocketConnector.java
index 7f4afa1388..35aa5dd705 100644
--- a/spring-integration-rsocket/src/main/java/org/springframework/integration/rsocket/AbstractRSocketConnector.java
+++ b/spring-integration-rsocket/src/main/java/org/springframework/integration/rsocket/AbstractRSocketConnector.java
@@ -53,7 +53,7 @@ public abstract class AbstractRSocketConnector
private MimeType dataMimeType = MimeTypeUtils.TEXT_PLAIN;
- private MimeType metadataMimeType = IntegrationRSocket.COMPOSITE_METADATA;
+ private MimeType metadataMimeType = new MimeType("message", "x.rsocket.composite-metadata.v0");
private RSocketStrategies rsocketStrategies =
RSocketStrategies.builder()
diff --git a/spring-integration-rsocket/src/main/java/org/springframework/integration/rsocket/IntegrationRSocket.java b/spring-integration-rsocket/src/main/java/org/springframework/integration/rsocket/IntegrationRSocket.java
deleted file mode 100644
index 39d773099b..0000000000
--- a/spring-integration-rsocket/src/main/java/org/springframework/integration/rsocket/IntegrationRSocket.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * Copyright 2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.integration.rsocket;
-
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.function.Function;
-
-import org.reactivestreams.Publisher;
-
-import org.springframework.core.io.buffer.DataBuffer;
-import org.springframework.core.io.buffer.DataBufferFactory;
-import org.springframework.core.io.buffer.DataBufferUtils;
-import org.springframework.core.io.buffer.NettyDataBuffer;
-import org.springframework.lang.Nullable;
-import org.springframework.messaging.Message;
-import org.springframework.messaging.MessageHeaders;
-import org.springframework.messaging.ReactiveMessageHandler;
-import org.springframework.messaging.handler.DestinationPatternsMessageCondition;
-import org.springframework.messaging.handler.invocation.reactive.HandlerMethodReturnValueHandler;
-import org.springframework.messaging.rsocket.PayloadUtils;
-import org.springframework.messaging.rsocket.RSocketRequester;
-import org.springframework.messaging.rsocket.annotation.support.MetadataExtractor;
-import org.springframework.messaging.rsocket.annotation.support.RSocketPayloadReturnValueHandler;
-import org.springframework.messaging.rsocket.annotation.support.RSocketRequesterMethodArgumentResolver;
-import org.springframework.messaging.support.MessageBuilder;
-import org.springframework.messaging.support.MessageHeaderAccessor;
-import org.springframework.util.Assert;
-import org.springframework.util.MimeType;
-import org.springframework.util.RouteMatcher;
-
-import io.rsocket.AbstractRSocket;
-import io.rsocket.ConnectionSetupPayload;
-import io.rsocket.Payload;
-import reactor.core.publisher.Flux;
-import reactor.core.publisher.Mono;
-import reactor.core.publisher.MonoProcessor;
-
-/**
- * Implementation of {@link io.rsocket.RSocket} that wraps incoming requests with a
- * {@link Message}, delegates to a {@link Function} for handling, and then
- * obtains the response from a "reply" header.
- *
By default this is not set. However a server acceptor will use the
- * content type from the {@link io.rsocket.ConnectionSetupPayload}, so this is typically
- * required for clients but can also be used on servers as a fallback.
- * @param defaultDataMimeType the MimeType to use
- */
- @Override
- public void setDefaultDataMimeType(@Nullable MimeType defaultDataMimeType) {
- super.setDefaultDataMimeType(defaultDataMimeType);
- this.defaultDataMimeType = defaultDataMimeType;
- }
-
-
- /**
- * Configure the default {@code MimeType} for payload data if the
- * {@code SETUP} frame did not specify one.
- *
By default this is set to {@code "message/x.rsocket.composite-metadata.v0"}
- * @param mimeType the MimeType to use
- */
- @Override
- public void setDefaultMetadataMimeType(MimeType mimeType) {
- super.setDefaultMetadataMimeType(mimeType);
- this.defaultMetadataMimeType = mimeType;
- }
-
- /**
- * Configure a {@link MetadataExtractor} to extract the route and possibly
- * other metadata from the first payload of incoming requests.
- *
By default this is a {@link DefaultMetadataExtractor} with the
- * configured {@link RSocketStrategies} (and decoders), extracting a route
- * from {@code "message/x.rsocket.routing.v0"} or {@code "text/plain"}
- * metadata entries.
- * @param extractor the extractor to use
- */
- @Override
- public void setMetadataExtractor(MetadataExtractor extractor) {
- super.setMetadataExtractor(extractor);
- this.metadataExtractor = extractor;
- }
-
- @Override
- public BiFunction clientAcceptor() {
- return this::createRSocket;
- }
-
public boolean detectEndpoints() {
ApplicationContext applicationContext = getApplicationContext();
if (applicationContext != null && getHandlerMethods().isEmpty()) {
@@ -135,6 +70,7 @@ class IntegrationRSocketMessageHandler extends RSocketMessageHandler {
public void addEndpoint(IntegrationRSocketEndpoint endpoint) {
registerHandlerMethod(endpoint, HANDLE_MESSAGE_METHOD,
new CompositeMessageCondition(
+ RSocketFrameTypeMessageCondition.REQUEST_CONDITION,
new DestinationPatternsMessageCondition(endpoint.getPath(), getRouteMatcher())));
}
@@ -143,36 +79,6 @@ class IntegrationRSocketMessageHandler extends RSocketMessageHandler {
return Collections.singletonList(new MessageHandlerMethodArgumentResolver());
}
- @Override
- public void afterPropertiesSet() {
- super.afterPropertiesSet();
- if (this.metadataExtractor == null) {
- DefaultMetadataExtractor extractor = new DefaultMetadataExtractor(getRSocketStrategies()); // NOSONAR
- extractor.metadataToExtract(MimeTypeUtils.TEXT_PLAIN, String.class, MetadataExtractor.ROUTE_KEY);
- this.metadataExtractor = extractor;
- }
- }
-
- protected IntegrationRSocket createRSocket(ConnectionSetupPayload setupPayload, RSocket rsocket) {
- String mimeType = setupPayload.dataMimeType();
- MimeType dataMimeType =
- StringUtils.hasText(mimeType)
- ? MimeTypeUtils.parseMimeType(mimeType)
- : this.defaultDataMimeType;
- Assert.notNull(dataMimeType, "No `dataMimeType` in ConnectionSetupPayload and no default value");
- mimeType = setupPayload.metadataMimeType();
- MimeType metaMimeType =
- StringUtils.hasText(mimeType)
- ? MimeTypeUtils.parseMimeType(mimeType)
- : this.defaultMetadataMimeType;
- Assert.notNull(dataMimeType, "No `metadataMimeType` in ConnectionSetupPayload and no default value");
- RSocketStrategies rSocketStrategies = getRSocketStrategies();
- Assert.notNull(rSocketStrategies, "No `rSocketStrategies` provided");
- RSocketRequester requester = RSocketRequester.wrap(rsocket, dataMimeType, metaMimeType, rSocketStrategies);
- return new IntegrationRSocket(this, getRouteMatcher(), requester, dataMimeType, metaMimeType,
- this.metadataExtractor, rSocketStrategies.dataBufferFactory());
- }
-
private static final class MessageHandlerMethodArgumentResolver implements SyncHandlerMethodArgumentResolver {
@Override
diff --git a/spring-integration-rsocket/src/main/java/org/springframework/integration/rsocket/ServerRSocketConnector.java b/spring-integration-rsocket/src/main/java/org/springframework/integration/rsocket/ServerRSocketConnector.java
index 31e6963a48..e89685f4ac 100644
--- a/spring-integration-rsocket/src/main/java/org/springframework/integration/rsocket/ServerRSocketConnector.java
+++ b/spring-integration-rsocket/src/main/java/org/springframework/integration/rsocket/ServerRSocketConnector.java
@@ -22,15 +22,20 @@ import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Consumer;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.lang.Nullable;
+import org.springframework.messaging.Message;
+import org.springframework.messaging.MessageHeaders;
+import org.springframework.messaging.handler.CompositeMessageCondition;
+import org.springframework.messaging.handler.DestinationPatternsMessageCondition;
import org.springframework.messaging.rsocket.RSocketRequester;
+import org.springframework.messaging.rsocket.annotation.support.RSocketFrameTypeMessageCondition;
+import org.springframework.messaging.rsocket.annotation.support.RSocketRequesterMethodArgumentResolver;
import org.springframework.util.Assert;
+import org.springframework.util.ReflectionUtils;
+import org.springframework.util.RouteMatcher;
import io.rsocket.RSocketFactory;
import io.rsocket.SocketAcceptor;
@@ -162,9 +167,13 @@ public class ServerRSocketConnector extends AbstractRSocketConnector
.subscribe();
}
- private static class ServerRSocketMessageHandler extends IntegrationRSocketMessageHandler {
+ @Override
+ public void afterSingletonsInstantiated() {
+ super.afterSingletonsInstantiated();
+ serverRSocketMessageHandler().registerHandleConnectionSetupMethod();
+ }
- private static final Log LOGGER = LogFactory.getLog(ServerRSocketMessageHandler.class);
+ private static class ServerRSocketMessageHandler extends IntegrationRSocketMessageHandler {
private final Map