使用 Kafka 实现 STOMP 协议 [英] STOMP protocol implementation with Kafka

查看:28
本文介绍了使用 Kafka 实现 STOMP 协议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 websocket 协议和 STOMP 作为消息协议为网络平台开发聊天模块.

I'm developing a chat module for a web plateform using the websocket protocol, and STOMP as a message protocol.

这是我第一次使用任何消息代理,而 Kafka 是在公司(我正在为其工作的)网络平台上使用的,我猜是用于其他模块.之前我刚开始使用 RabbitMQ,现在我必须切换到 Kafka.我在RabbitMQ的网站上看到一整篇关于如何使用STOMP的文章,但是在Kafka的官网上却没有.

It's my first time using any message broker, and Kafka is the one used on the company's (the one i'm working for) web plateform, for other modules I guess. And having previously worked with RabbitMQ when I was just starting, now I have to switch to Kafka. I saw on RabbitMQ's website there's a whole article about how to use STOMP, but there is no such thing on Kafka's official website.

但我已经探索了其他几个来源,许多教程,但我找不到任何与将 STOMP 协议与 Kafka 结合使用的相关信息,这让我问这是否可能?

But I've explored several other sources, many tutorials and I couldn't find anything relevant about using STOMP protocol with Kafka, which leads me to ask if it's possible ?

这是我的 websocket 配置类:

Here's my websocket configuration class :

@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer{

    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) {
        registry.addEndpoint("/ws").withSockJS();
    }

    @Override
    public void configureMessageBroker(MessageBrokerRegistry registry) {
        registry.setApplicationDestinationPrefixes("/app");
        registry.enableSimpleBroker("/topic");

//Here's the line I wrote to use Kafka as a MB, but doesn't work        
registry.enableStompBrokerRelay("/topic").setRelayHost("localhost").setRelayPort(9092);

在启动 Kafka,然后运行我的 Java Spring 应用程序后,我从 java.io.IOException 获得连接重置由对等方",如果一切正常,则不应抛出该异常.

After lauching Kafka, and then running my Java Spring app, I get a "connection reset by peer" from a java.io.IOException, which is not supposed to be thrown if everything works fine.

我使用 Kakfa 的 2.2.0 版本,Zookeeper 的 3.4.14 版本,并使用 STS 3 作为我的 IDE.

I'm using Kakfa's 2.2.0 release, Zookeeper's 3.4.14 release, and using STS 3 as my IDE.

任何帮助将不胜感激.

推荐答案

RabbitMQ 本身不支持 STOMP,但它有一个 STOMP 插件;Kafka 没有对 STOMP 的内置支持.

RabbitMQ doesn't natively support STOMP, but it has a STOMP plugin; Kafka has no built-in support for STOMP.

这篇关于使用 Kafka 实现 STOMP 协议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆