[英]Use proxy for Stomp over WebSocket protocol
我在 java 中通过 WebSocket 协议使用 Stomp 处理通知消费。 我的问题是通过代理(具有定义的名称和端口)到 go。 我在网上找了很多,但我找不到很多...
此代码运行良好,我设法使用队列并接收消息。 但是,我在服务器上部署时,并没有解决地址,必须通过专用代理强制传递。
public StompSession connect(StompSessionHandler stompSessionHandler) throws ExecutionException, InterruptedException {
WebSocketStompClient stompClient = initStompClient();
StompHeaders connectHeaders = configureHeaders();
return stompClient.connect(configuration.getUrlBroker(), (WebSocketHttpHeaders) null, connectHeaders, stompSessionHandler).get();
}
private WebSocketStompClient initStompClient() {
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
container.setDefaultMaxTextMessageBufferSize(configuration.getMaxTextMessageSize());
WebSocketClient webSocketClient = new StandardWebSocketClient(container);
WebSocketStompClient webSocketStompClient = new WebSocketStompClient(webSocketClient);
webSocketStompClient.setMessageConverter(new MappingJackson2MessageConverter());
webSocketStompClient.setTaskScheduler(new ConcurrentTaskScheduler());
webSocketStompClient.setInboundMessageSizeLimit(configuration.getMaxTextMessageSize());
return webSocketStompClient;
}
private StompHeaders configureHeaders() {
StompHeaders headers = new StompHeaders();
headers.setLogin(configuration.getLogin());
headers.setPasscode(configuration.getPassword());
headers.setHeartbeat(new long[]{configuration.getHeartbeatOut(), configuration.getHeartbeatIn()});
headers.setAcceptVersion(configuration.getAcceptVersion());
return headers;
}
你有线索吗?
先感谢您。
Le proxy peut se définir dans les propriétés système de la JVM:
System.setProperty("http.proxyHost", proxyConfiguration.getHost());
System.setProperty("http.proxyPort", valueOf(proxyConfiguration.getPort()));
System.setProperty("https.proxyHost", proxyConfiguration.getHost());
System.setProperty("https.proxyPort", valueOf(proxyConfiguration.getPort()));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.