![](/img/trans.png)
[英]Spring boot connection failure with RabbitMQ Web STOMP Plugin
[英]Spring Boot + Spring Web Socket + RabbitMQ Web STOMP
我正在努力在我的应用程序中添加实时通知
我已经完成了POC - Spring Boot - Spring WebSocket - SockJS - RabbitMQ STOMP插件
我读到了有关RabbitMQ Web STOMP的内容,并希望对其进行POC。 但它表示自从版本3.7支持SockJS websocket仿真被删除。
有没有SockJS的Spring WebSocket + RabbitMQ Web STOMP是否有任何示例。
请帮忙。
参考链接:
http://www.rabbitmq.com/stomp.html
@ n.sharvarish ...首先在rabbitmq上创建一个websocket配置类,就像这样......
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
private static final Logger log = LoggerFactory.getLogger(WebSocketConfig.class);
@Value("${spring.rabbitmq.username}")
private String userName;
@Value("${spring.rabbitmq.password}")
private String password;
@Value("${spring.rabbitmq.host}")
private String host;
@Value("${spring.rabbitmq.port}")
private int port;
@Value("${endpoint}")
private String endpoint;
@Value("${destination.prefix}")
private String destinationPrefix;
@Value("${stomp.broker.relay}")
private String stompBrokerRelay;
@Override
public void configureMessageBroker(final MessageBrokerRegistry config) {
config.enableStompBrokerRelay(stompBrokerRelay).setRelayHost(host).setRelayPort(port).setSystemLogin(userName).setSystemPasscode(password);
config.setApplicationDestinationPrefixes(destinationPrefix);
}
@Override
public void registerStompEndpoints(final StompEndpointRegistry registry) {
registry.addEndpoint(endpoint).setAllowedOrigins("*").withSockJS();
}
}
然后......使用上面你要使用的配置类..像这样..
@Autowired
SimpMessagingTemplate template
template.convertAndSend(destinationurl, object);
并从application.properties配置以上用户名和密码
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.