Java – spring 4 websocket remote proxy configuration
•
Java
I managed to create a simple web socket application with spring 4 and stomp Please refer to my previous question here
registry.enableSimpleBroker("/topic");
to
registry.enableStompBrokerRelay("/topic");
It worked
The question is how to configure the agent? As far as I know, in this case, the application automatically discovers the agent on localhost: defaultport. What should I do if I need to point the application to another agent on another machine?
Solution
The enablestompbrokerelay method returns a convenient registration instance that exposes a smooth API
You can use this fluent API to configure your broker relay:
registry.enableStompBrokerRelay("/topic").setRelayHost("host").setRelayPort("1234");
You can also configure various properties, such as agent login / transfer credentials, etc
Same as XML configuration:
<websocket:message-broker> <websocket:stomp-endpoint path="/foo"> <websocket:handshake-handler ref="myHandler"/> <websocket:sockjs/> </websocket:stomp-endpoint> <websocket:stomp-broker-relay prefix="/topic,/queue" relay-host="relayhost" relay-port="1234" client-login="clientlogin" client-passcode="clientpass" system-login="syslogin" system-passcode="syspass" heartbeat-send-interval="5000" heartbeat-receive-interval="5000" virtual-host="example.org"/> </websocket:message-broker>
For more details on properties and default values, see stopbrokerrelayregistration Javadoc
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码