org.springframework.messaging.rsocket.RSocketStrategies Java Examples
The following examples show how to use
org.springframework.messaging.rsocket.RSocketStrategies.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RSocketClientToSecuredServerITest.java From spring-rsocket-demo with GNU General Public License v3.0 | 6 votes |
@BeforeAll public static void setupOnce(@Autowired RSocketRequester.Builder builder, @LocalRSocketServerPort Integer port, @Autowired RSocketStrategies strategies) { SocketAcceptor responder = RSocketMessageHandler.responder(strategies, new ClientHandler()); mimeType = MimeTypeUtils.parseMimeType(WellKnownMimeType.MESSAGE_RSOCKET_AUTHENTICATION.getString()); // ******* The user 'test' is NOT in the required 'USER' role! ********** credentials = new UsernamePasswordMetadata("test", "pass"); requester = builder .setupRoute("shell-client") .setupData(UUID.randomUUID().toString()) .setupMetadata(credentials, mimeType) .rsocketStrategies(b -> b.encoder(new SimpleAuthenticationEncoder())) .rsocketConnector(connector -> connector.acceptor(responder)) .connectTcp("localhost", port) .block(); }
Example #2
Source File: RSocketClientToServerITest.java From spring-rsocket-demo with GNU General Public License v3.0 | 6 votes |
@BeforeAll public static void setupOnce(@Autowired RSocketRequester.Builder builder, @LocalRSocketServerPort Integer port, @Autowired RSocketStrategies strategies) { SocketAcceptor responder = RSocketMessageHandler.responder(strategies, new ClientHandler()); credentials = new UsernamePasswordMetadata("user", "pass"); mimeType = MimeTypeUtils.parseMimeType(WellKnownMimeType.MESSAGE_RSOCKET_AUTHENTICATION.getString()); requester = builder .setupRoute("shell-client") .setupData(UUID.randomUUID().toString()) .setupMetadata(credentials, mimeType) .rsocketStrategies(b -> b.encoder(new SimpleAuthenticationEncoder())) .rsocketConnector(connector -> connector.acceptor(responder)) .connectTcp("localhost", port) .block(); }
Example #3
Source File: MetadataEncoder.java From spring-cloud-rsocket with Apache License 2.0 | 5 votes |
public MetadataEncoder(MimeType metadataMimeType, RSocketStrategies strategies) { Assert.notNull(metadataMimeType, "'metadataMimeType' is required"); Assert.notNull(strategies, "RSocketStrategies is required"); this.metadataMimeType = metadataMimeType; this.strategies = strategies; this.isComposite = this.metadataMimeType.toString() .equals(WellKnownMimeType.MESSAGE_RSOCKET_COMPOSITE_METADATA.getString()); this.allocator = bufferFactory() instanceof NettyDataBufferFactory ? ((NettyDataBufferFactory) bufferFactory()).getByteBufAllocator() : ByteBufAllocator.DEFAULT; }
Example #4
Source File: GatewayRSocketClientAutoConfiguration.java From spring-cloud-rsocket with Apache License 2.0 | 5 votes |
@Bean @Scope("prototype") // TODO: I don't think prototype works here @ConditionalOnMissingBean public RSocketRequester.Builder gatewayRSocketRequesterBuilder( RSocketStrategies strategies, ClientProperties properties, MeterRegistry meterRegistry) { RouteSetup.Builder routeSetup = RouteSetup.of(properties.getRouteId(), properties.getServiceName()); properties.getTags().forEach((key, value) -> { if (key.getWellKnownKey() != null) { routeSetup.with(key.getWellKnownKey(), value); } else if (key.getCustomKey() != null) { routeSetup.with(key.getCustomKey(), value); } }); MicrometerRSocketInterceptor interceptor = new MicrometerRSocketInterceptor( meterRegistry, Tag.of("servicename", properties.getServiceName())); RSocketRequester.Builder builder = RSocketRequester.builder() .setupMetadata(routeSetup.build(), RouteSetup.ROUTE_SETUP_MIME_TYPE) .rsocketStrategies(strategies).rsocketFactory(configurer(interceptor)); return new ClientRSocketRequesterBuilder(builder, properties, strategies.routeMatcher()); }
Example #5
Source File: PingPongApp.java From spring-cloud-rsocket with Apache License 2.0 | 5 votes |
static ByteBuf getForwardingMetadata(RSocketStrategies strategies, String name, long id) { Forwarding metadata = Forwarding.of(id).serviceName(name).build(); DataBuffer dataBuffer = new MetadataEncoder(COMPOSITE_MIME_TYPE, strategies) .metadata(metadata, Forwarding.FORWARDING_MIME_TYPE).encode(); return TagsMetadata.asByteBuf(dataBuffer); }
Example #6
Source File: PingPongApp.java From spring-cloud-rsocket with Apache License 2.0 | 5 votes |
static ByteBuf getRouteSetupMetadata(RSocketStrategies strategies, String name, long id) { RouteSetup routeSetup = RouteSetup.of(id, name) .with("current-time", String.valueOf(System.currentTimeMillis())).build(); LinkedHashMap<TagsMetadata.Key, String> tags = new LinkedHashMap<>(); tags.put(new TagsMetadata.Key(WellKnownKey.TIME_ZONE), System.currentTimeMillis() + ""); DataBuffer dataBuffer = new MetadataEncoder(COMPOSITE_MIME_TYPE, strategies) .metadata(routeSetup, ROUTE_SETUP_MIME_TYPE).encode(); return TagsMetadata.asByteBuf(dataBuffer); }
Example #7
Source File: ClusterJoinListener.java From spring-cloud-rsocket with Apache License 2.0 | 5 votes |
public ClusterJoinListener(ClusterService clusterService, BrokerProperties properties, RSocketStrategies strategies, GatewayRSocketFactory gatewayRSocketFactory) { this.clusterService = clusterService; this.properties = properties; this.strategies = strategies; this.gatewayRSocketFactory = gatewayRSocketFactory; }
Example #8
Source File: GatewayRSocketAutoConfiguration.java From spring-cloud-rsocket with Apache License 2.0 | 5 votes |
@Bean public ClusterJoinListener clusterJoinListener(ClusterService clusterService, BrokerProperties properties, RSocketStrategies strategies, GatewayRSocketFactory gatewayRSocketFactory) { return new ClusterJoinListener(clusterService, properties, strategies, gatewayRSocketFactory); }
Example #9
Source File: GatewayRSocketAutoConfiguration.java From spring-cloud-rsocket with Apache License 2.0 | 5 votes |
@Bean public GatewaySocketAcceptor socketAcceptor(GatewayRSocketFactory rsocketFactory, List<SocketAcceptorFilter> filters, MeterRegistry meterRegistry, BrokerProperties properties, RSocketStrategies rSocketStrategies) { return new GatewaySocketAcceptor(rsocketFactory, filters, meterRegistry, properties, rSocketStrategies.metadataExtractor()); }
Example #10
Source File: GatewayRSocketAutoConfiguration.java From spring-cloud-rsocket with Apache License 2.0 | 5 votes |
@Bean public GatewayRSocketFactory gatewayRSocketFactory(RoutingTable routingTable, Routes routes, PendingRequestRSocketFactory pendingFactory, LoadBalancerFactory loadBalancerFactory, MeterRegistry meterRegistry, BrokerProperties properties, RSocketStrategies rSocketStrategies) { return new GatewayRSocketFactory(routingTable, routes, pendingFactory, loadBalancerFactory, meterRegistry, properties, rSocketStrategies.metadataExtractor()); }
Example #11
Source File: GatewayRSocketAutoConfiguration.java From spring-cloud-rsocket with Apache License 2.0 | 5 votes |
@Bean public PendingRequestRSocketFactory pendingRequestRSocketFactory( RoutingTable routingTable, Routes routes, RSocketStrategies rSocketStrategies) { return new PendingRequestRSocketFactory(routingTable, routes, rSocketStrategies.metadataExtractor()); }
Example #12
Source File: GatewayRSocketCommonMetadataAutoConfiguration.java From spring-cloud-rsocket with Apache License 2.0 | 5 votes |
@Override public void afterPropertiesSet() { RSocketStrategies rSocketStrategies = this.context .getBean(RSocketStrategies.class); MetadataExtractor metadataExtractor = rSocketStrategies.metadataExtractor(); // TODO: see if possible to make easier in framework. if (metadataExtractor instanceof DefaultMetadataExtractor) { DefaultMetadataExtractor extractor = (DefaultMetadataExtractor) metadataExtractor; extractor.metadataToExtract(FORWARDING_MIME_TYPE, Forwarding.class, Forwarding.METADATA_KEY); extractor.metadataToExtract(ROUTE_SETUP_MIME_TYPE, RouteSetup.class, RouteSetup.METADATA_KEY); } }
Example #13
Source File: RSocketClientDeniedConnectionToSecuredServerITest.java From spring-rsocket-demo with GNU General Public License v3.0 | 5 votes |
@BeforeAll public static void setupOnce(@Autowired RSocketRequester.Builder builder, @LocalRSocketServerPort Integer port, @Autowired RSocketStrategies strategies) { mimeType = MimeTypeUtils.parseMimeType(WellKnownMimeType.MESSAGE_RSOCKET_AUTHENTICATION.getString()); reqbuilder = builder; theport = port; // ******* The user 'fake' is NOT in the user list! ********** credentials = new UsernamePasswordMetadata("fake", "pass"); }
Example #14
Source File: RSocketSecurityConfig.java From spring-rsocket-demo with GNU General Public License v3.0 | 5 votes |
@Bean RSocketMessageHandler messageHandler(RSocketStrategies strategies) { RSocketMessageHandler handler = new RSocketMessageHandler(); handler.getArgumentResolverConfigurer().addCustomResolver(new AuthenticationPrincipalArgumentResolver()); handler.setRSocketStrategies(strategies); return handler; }
Example #15
Source File: RSocketServerToClientITest.java From spring-rsocket-demo with GNU General Public License v3.0 | 5 votes |
/** * This private method is used to establish a connection to our fake RSocket server. * It also controls the state of our test controller. This method is reusable by many tests. * * @param connectionRoute */ private void connectAndRunTest(String connectionRoute) { ServerController controller = context.getBean(ServerController.class); RSocketStrategies strategies = context.getBean(RSocketStrategies.class); RSocketRequester requester = null; try { controller.reset(); // Add our ClientHandler as a responder SocketAcceptor responder = RSocketMessageHandler.responder(strategies, new ClientHandler()); // Create an RSocket requester that includes our responder requester = RSocketRequester.builder() .setupRoute(connectionRoute) .setupData(clientId) .rsocketStrategies(strategies) .rsocketConnector(connector -> connector.acceptor(responder)) .connectTcp("localhost", server.address().getPort()) .block(); // Give the test time to run, wait for the server's call. controller.await(Duration.ofSeconds(10)); } finally { if (requester != null) { requester.rsocket().dispose(); } } }
Example #16
Source File: ServiceConsumeConfiguration.java From alibaba-rsocket-broker with Apache License 2.0 | 5 votes |
@Bean public RSocketRequester rsocketRequester(UpstreamManager upstreamManager) { LoadBalancedRSocket loadBalancedRSocket = upstreamManager.findBroker().getLoadBalancedRSocket(); RSocketStrategies rSocketStrategies = RSocketStrategies.builder() .encoder(new HessianEncoder()) .decoder(new HessianDecoder()) .build(); return RSocketRequester.wrap(loadBalancedRSocket, MimeType.valueOf("application/x-hessian"), MimeType.valueOf("message/x.rsocket.composite-metadata.v0"), rSocketStrategies); }
Example #17
Source File: ClientRSocketRequesterBuilder.java From spring-cloud-rsocket with Apache License 2.0 | 4 votes |
@Override public RSocketRequester.Builder rsocketStrategies( Consumer<RSocketStrategies.Builder> configurer) { return delegate.rsocketStrategies(configurer); }
Example #18
Source File: MarketDataRSocketControllerLiveTest.java From tutorials with MIT License | 4 votes |
@Bean @Lazy RSocketRequester rSocketRequester(RSocketStrategies rSocketStrategies) { return RSocketRequester.wrap(rSocket(), MimeTypeUtils.APPLICATION_JSON, MimeTypeUtils.APPLICATION_JSON, rSocketStrategies); }
Example #19
Source File: RsocketClientApplication.java From bootiful-reactive-microservices with Apache License 2.0 | 4 votes |
@Bean RSocketRequester requester(RSocketStrategies rSocketStrategies) { return RSocketRequester .create(this.rSocket(), MimeTypeUtils.APPLICATION_JSON, rSocketStrategies); }
Example #20
Source File: ClientConfiguration.java From tutorials with MIT License | 4 votes |
@Bean RSocketRequester rSocketRequester(RSocketStrategies rSocketStrategies) { return RSocketRequester.wrap(rSocket(), MimeTypeUtils.APPLICATION_JSON, MimeTypeUtils.APPLICATION_JSON, rSocketStrategies); }
Example #21
Source File: ClientRSocketRequesterBuilder.java From spring-cloud-rsocket with Apache License 2.0 | 4 votes |
@Override public RSocketRequester.Builder rsocketStrategies(RSocketStrategies strategies) { return delegate.rsocketStrategies(strategies); }
Example #22
Source File: MetadataEncoder.java From spring-cloud-rsocket with Apache License 2.0 | 4 votes |
public static DataBuffer emptyDataBuffer(RSocketStrategies rSocketStrategies) { return rSocketStrategies.dataBufferFactory().wrap(new byte[0]); }
Example #23
Source File: RSocketServerToClientITest.java From spring-rsocket-demo with GNU General Public License v3.0 | 4 votes |
@Bean("testStrategies") public RSocketStrategies rsocketStrategies() { return RSocketStrategies.create(); }
Example #24
Source File: RSocketServerToClientITest.java From spring-rsocket-demo with GNU General Public License v3.0 | 4 votes |
@Bean public RSocketMessageHandler serverMessageHandler(@Qualifier("testStrategies") RSocketStrategies strategies) { RSocketMessageHandler handler = new RSocketMessageHandler(); handler.setRSocketStrategies(strategies); return handler; }
Example #25
Source File: RSocketShellClient.java From spring-rsocket-demo with GNU General Public License v3.0 | 4 votes |
@Autowired public RSocketShellClient(RSocketRequester.Builder builder, @Qualifier("rSocketStrategies") RSocketStrategies strategies) { this.rsocketRequesterBuilder = builder; this.rsocketStrategies = strategies; }