0Pricing
WebSockets & Real-Time Systems with Spring · Aula

Configuração do retransmissor do intermediário STOMP

Substitua o intermediário simples em memória por um retransmissor de intermediário STOMP, para que o Spring encaminhe mensagens a um intermediário real como o RabbitMQ e permita o dimensionamento horizontal.

Configuração do retransmissor do intermediário STOMP é uma aula grátis de WebSockets & Real-Time Systems with Spring no CoddyKit. Esta é a aula 4 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de WebSockets & Real-Time Systems with Spring, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de WebSockets & Real-Time Systems with Spring inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

Limits of the Simple Broker

The default enableSimpleBroker keeps subscriptions and message routing in memory on one JVM. It is great for demos but cannot share state across instances, so it does not scale horizontally.

Enter the Broker Relay

A STOMP broker relay tells Spring to forward messages to a dedicated broker (RabbitMQ, ActiveMQ) that speaks STOMP. The broker, not the JVM, now handles routing and fan-out.

Why This Scales

With a central broker, every Spring instance connects to the same broker. A message published on node A reaches a subscriber on node B because both share the broker's topics and queues.

Enabling the Relay

Swap enableSimpleBroker for enableStompBrokerRelay in your config, pointing at the broker host and port.

registry.enableStompBrokerRelay("/topic", "/queue")
  .setRelayHost("rabbitmq")
  .setRelayPort(61613)
  .setClientLogin("guest")
  .setClientPasscode("guest");

Enabling STOMP on RabbitMQ

RabbitMQ speaks STOMP through a plugin you must enable. Port 61613 is the STOMP default.

rabbitmq-plugins enable rabbitmq_stomp

Application vs Broker Destinations

Keep the prefixes distinct:

  • /app → routed to your @MessageMapping controllers
  • /topic, /queue → routed straight to the broker relay
registry.setApplicationDestinationPrefixes("/app");

System Connection

Spring keeps a separate system connection to the broker for server-initiated messages (e.g. convertAndSend from a service). Configure its credentials too.

relay.setSystemLogin("guest")
     .setSystemPasscode("guest")
     .setSystemHeartbeatSendInterval(10000);

Heartbeats with the Relay

The relay maintains heartbeats with the broker to detect a dead broker connection. If the broker goes down, Spring attempts to reconnect automatically.

What the Broker Brings

A real broker adds capabilities the simple broker lacks:

  • Durable subscriptions that survive restarts
  • Message persistence to disk
  • Cross-node fan-out for clustering
  • Monitoring and management UIs

Reactive/Virtual Thread Note

The relay uses a Reactor Netty TCP client under the hood. Ensure the reactor-netty dependency is present, or the relay fails to start with a missing-class error.

<dependency>
  <groupId>io.projectreactor.netty</groupId>
  <artifactId>reactor-netty</artifactId>
</dependency>

Graceful Degradation

If the broker is unreachable at startup, the relay keeps retrying. Design clients to handle temporary delivery gaps and reconnect, rather than assuming the broker is always up.

Quick Check

Test your relay knowledge.

Recap

You moved routing to a real broker:

  • The simple broker is in-memory and single-node only
  • enableStompBrokerRelay forwards to RabbitMQ/ActiveMQ over STOMP
  • Enable the broker's STOMP plugin (port 61613)
  • Keep /app for controllers, /topic and /queue for the broker
  • The relay gives clustering, persistence, and durable subscriptions

Perguntas Frequentes

A aula “Configuração do retransmissor do intermediário STOMP” é grátis?

Sim — o texto completo de “Configuração do retransmissor do intermediário STOMP” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de WebSockets & Real-Time Systems with Spring, atualize para CoddyKit PRO. O curso de WebSockets & Real-Time Systems with Spring inclui 4 aulas no total.

O que vou aprender em “Configuração do retransmissor do intermediário STOMP”?

Substitua o intermediário simples em memória por um retransmissor de intermediário STOMP, para que o Spring encaminhe mensagens a um intermediário real como o RabbitMQ e permita o dimensionamento hor… Você pratica WebSockets & Real-Time Systems with Spring com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar WebSockets & Real-Time Systems with Spring?

Nenhuma experiência prévia é necessária. WebSockets & Real-Time Systems with Spring no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 4 de 4.

Quanto tempo leva a aula “Configuração do retransmissor do intermediário STOMP”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de WebSockets & Real-Time Systems with Spring?

Sim. Cada aula de WebSockets & Real-Time Systems with Spring inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Necessidade de intermediários de mensagens externos
  2. Integração com RabbitMQ/Kafka
  3. Arquiteturas WebSocket distribuídas
  4. Configuração do retransmissor do intermediário STOMP
← Voltar para WebSockets & Real-Time Systems with Spring