Java Code Examples for org.springframework.messaging.tcp.reactor.ReactorNettyCodec

Following code examples demonstrate how to use org.springframework.messaging.tcp.reactor.ReactorNettyCodecfrom spring-framework. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.springframework.messaging.tcp.reactor.ReactorNettyCodecand various code implementation of this class.

	protected void startInternal() {
		if (this.tcpClient == null) {
			this.tcpClient = initTcpClient();
		}

		if (logger.isInfoEnabled()) {
			logger.info("Starting \"system\" session, " + toString());
		}

		StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.CONNECT);
		accessor.setAcceptVersion("1.1,1.2");
		accessor.setLogin(this.systemLogin);
		accessor.setPasscode(this.systemPasscode);
		accessor.setHeartbeat(this.systemHeartbeatSendInterval, this.systemHeartbeatReceiveInterval);
		String virtualHost = getVirtualHost();
		if (virtualHost != null) {
			accessor.setHost(virtualHost);
		}
		accessor.setSessionId(SYSTEM_SESSION_ID);
		if (logger.isDebugEnabled()) {
			logger.debug("Forwarding " + accessor.getShortLogMessage(EMPTY_PAYLOAD));
		}

		SystemStompConnectionHandler handler = new SystemStompConnectionHandler(accessor);
		this.connectionHandlers.put(handler.getSessionId(), handler);

		this.stats.incrementConnectCount();
		this.tcpClient.connect(handler, new FixedIntervalReconnectStrategy(5000));
	} 


    public void configureMessageBroker(MessageBrokerRegistry registry) {
        StompBrokerRelayRegistration relayRegistration = registry
            .setApplicationDestinationPrefixes("/app", "/user")
            .setUserDestinationPrefix("/user")
            .enableStompBrokerRelay("/queue", "/topic")
            .setUserDestinationBroadcast("/topic/user-destination")
            .setUserRegistryBroadcast("/topic/user-registry")
            .setRelayHost(brokerProperties.getHost())
            .setRelayPort(brokerProperties.getPort())
            .setSystemLogin(brokerProperties.getSystemUsername())
            .setSystemPasscode(brokerProperties.getSystemPassword())
            .setClientLogin(brokerProperties.getClientUsername())
            .setClientPasscode(brokerProperties.getClientPassword());

        if (brokerProperties.getSsl()) {
            relayRegistration.setTcpClient(createSslTcpClient());
        }
    } 

    private Consumer<ClientOptions.Builder<?>> clientOptionsBuilder(final StompBrokerRelayMessageHandler handler) {
        return builder -> {
            builder.host(handler.getRelayHost()).port(handler.getRelayPort());
            if (properties.isRelaySsl()) {
                builder.sslSupport();
            }
        };
    } 

Advertisement
Javadoc
Simple holder for a decoding Function and an encoding BiConsumer to use with Reactor Netty. @author

Rossen Stoyanchev @since 5.0 @param the message payload type

Read More
Advertisement