我使用Spring Boot Websocket和STOMP建立了一个聊天客户端,连接到功能齐全的ActiveMQ Broker。我有六个我的Spring启动应用程序运行在负载均衡器前面,但是,我想扩展我的ActiveMQ单个实例以使用ActiveMQ Brokers网络,我能够配置ActiveMQ Brokers网络,但我无法弄清楚如何让我的SpringBoot应用程序连接到这个经纪人网络,任何帮助将不胜感激。 以下是我用于连接外部单实例代理的代码片段。
@Override
public void configureMessageBroker(MessageBrokerRegistry messageBrokerRegistry)
{
messageBrokerRegistry.setApplicationDestinationPrefixes("/app");
if (UseSimpleMessagingBroker)
{
// Destination Prefix - Connect to default in-memory broker
log.warn(
"NOTE: ***CHAT SERVICE IS CONFIGURED TO USE A SIMPLE EMBEDDED MESSAGING BROKER. IT IS RECOMMENDED TO USE A MESSAGE BROKER CLUSTER LIKE ActiveMQ or RabbitMQ. THIS CAN BE CONFIGURED IN application.properties => UseSimpleMessagingBroker=false");
messageBrokerRegistry.enableSimpleBroker("/topic/", "/queue/");
} else
{
// connect to AMQ
StompBrokerRelayRegistration broker = messageBrokerRegistry.enableStompBrokerRelay("/queue/", "/topic/");
broker.setRelayHost(StompBrokerRelayHost);
broker.setRelayPort(StompBrokerRelayPort);
broker.setSystemLogin(brokerUser);
broker.setSystemPasscode(brokerPassword);
broker.setClientLogin(stompClientUser);
broker.setClientPasscode(stompClientPassword);
// broker.setVirtualHost(virtualHost)
}
}
-