org.springframework.messaging.tcp.FixedIntervalReconnectStrategy Java Examples

The following examples show how to use org.springframework.messaging.tcp.FixedIntervalReconnectStrategy. 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: StompBrokerRelayMessageHandler.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
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));
}
 
Example #2
Source File: StompBrokerRelayMessageHandler.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
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));
}
 
Example #3
Source File: StompBrokerRelayMessageHandler.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected void startInternal() {
	if (this.tcpClient == null) {
		StompDecoder decoder = new StompDecoder();
		decoder.setHeaderInitializer(getHeaderInitializer());
		Reactor2StompCodec codec = new Reactor2StompCodec(new StompEncoder(), decoder);
		this.tcpClient = new StompTcpClientFactory().create(this.relayHost, this.relayPort, codec);
	}

	if (logger.isInfoEnabled()) {
		logger.info("Connecting \"system\" session to " + this.relayHost + ":" + this.relayPort);
	}

	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);
	accessor.setHost(getVirtualHost());
	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));
}