Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

429
Vistas
Consume messages from RabbitMQ queue using spring cloud stream 3.0+

I have a Producer producing messages in a RabbitMQ queue by using a direct exchange.

queue name: TEMP_QUEUE, exchange name: TEMP_DIRECT_EXCHANGE

Producing to this queue is easy since on my producer application I use Spring AMQP which I am familiar with.

On my Consumer application, I need to use Spring cloud stream version 3.0+.

I want to avoid using legacy annotations like @EnableBinding, @StreamListener because they are about to be depracated.

Legacy code for my application would look like that :

@EnableBinding(Bindings.class)
public class TempConsumer {

    @StreamListener(target = "TEMP_QUEUE")
    public void consumeFromTempQueue(MyObject object) {
        // do stuff with the object
    }
}

public interface Bindings {
    @Input("TEMP_QUEUE")
    SubscribableChannel myInputBinding();
}

From their docs I have found out I can do something like that

@Bean
public Consumer<MyObject> consumeFromTempQueue() {
    return obj -> {
        // do stuff with the object
    };
}

It is not clear to me how do I specify that this bean will consume from TEMP_QUEUE? Also what if I want to consume from multiple queues?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

You need to use the application.yml to bind your bean.

spring.cloud.stream:
  function.definition: consumeFromTempQueue

You can use this configuration to configure source, process and sink as well. In your case you are just using a source.

You can read this post for more information.

over 4 years ago · Santiago Trujillo Denunciar

0

See Consuming from Existing Queues/Exchanges.

You can consume from multiple queues with

spring.cloud.stream.bindings.consumeFromTempQueue-in-0.destination=q1,q2,q3
spring.cloud.stream.bindings.consumer.multiplex=true

Without multiplex you'll get 3 bindings; with multiplex, you'll get 1 listener container listening to multiple queues.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda