RSocket requests: Add per message metadata support

* Use convenient `Consumer` API to avoid external iteration for
`setupMetadata` in the `ClientRSocketConnector`
* Add `routeVars` and `metadata` support into the `RSocketOutboundGateway`
* Cover new options in the XML and Java DSL configurations
This commit is contained in:
Artem Bilan
2019-09-03 15:56:39 -04:00
parent 444c1f9913
commit a95c76e4d7
8 changed files with 106 additions and 18 deletions

View File

@@ -21,6 +21,7 @@
route-expression="'testRoute'"
request-channel="requestChannel"
publisher-element-type="byte[]"
expected-response-type="java.util.Date"/>
expected-response-type="java.util.Date"
metadata-expression="{'metadata': new org.springframework.util.MimeType('*')}"/>
</beans>

View File

@@ -18,14 +18,18 @@ package org.springframework.integration.rsocket.config;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Collections;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.expression.Expression;
import org.springframework.integration.rsocket.ClientRSocketConnector;
import org.springframework.integration.rsocket.outbound.RSocketOutboundGateway;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.util.MimeType;
/**
* @author Artem Bilan
@@ -34,7 +38,7 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
*/
@SpringJUnitConfig
@DirtiesContext
public class RSocketOutboundGatewayParserTests {
class RSocketOutboundGatewayParserTests {
@Autowired
private ClientRSocketConnector clientRSocketConnector;
@@ -54,6 +58,10 @@ public class RSocketOutboundGatewayParserTests {
.isEqualTo("byte[]");
assertThat(TestUtils.getPropertyValue(this.outboundGateway, "expectedResponseTypeExpression.literalValue"))
.isEqualTo("java.util.Date");
Expression metadataExpression =
TestUtils.getPropertyValue(this.outboundGateway, "metadataExpression", Expression.class);
assertThat(metadataExpression.getValue())
.isEqualTo(Collections.singletonMap("metadata", new MimeType("*")));
}
}