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

171
Vistas
How to dynamically add a delivery delay to an outbound message?

I have a JMS outbound gateway which i use to send messages to multiple queues in a queue manager. The destination is determined on the fly using the destinationExpression method:

@Bean
public IntegrationFlow sendTo101() {
    return flow -> flow
            .handle(Jms
                    .outboundAdapter(context.getBean("connection101", ConnectionFactory.class))
                    .destinationExpression("headers.destinationName")
                    .configureJmsTemplate(spec -> spec
                            .explicitQosEnabled(true)
                            .get().setDeliveryDelay(180000)
                    )
                    .get(),
                    endpointSpec -> endpointSpec.advice(context.getBean(RequestHandlerRetryAdvice.class))
            );

}

Now there's a need to set a delivery delay to a certain subset of messages that come in. Is there any way to use the contents of the message to determine if i should add a delay or not?

I could have a filter further up which checks for this property and redirects the flow to another outbound gateway, but that would be quite a bit of redundant code so i wanted to make sure that there wasn't a better way.

Also, different messages require different delays. Is it possible to set a different delay per message? I do realize that the delay property is on the Message Producer and not something you set on the message according to the JMS spec, but i'm fine with making a new JMS producer per message even though it hinders performance.

Thanks for the help!

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

0

Well, what I can suggest in this case is like to have top level JmsTemplate bean and set its deliveryDelay in advance of the Jms.outboundAdapter(). But in this case all your messages must be processed in this flow in the same Thread to avoid concurrent modification.

We have DynamicJmsTemplate which is based on the DynamicJmsTemplateProperties. And the last one uses ThreadLocal to change priority and receiveTimeout per request.

I'm pretty sure that your request for the deliveryDelay can be considered as a part of that feature.

Only the problem here that target JmsTemplate doesn't use getter but gets access to the property directly. So, first of all we have to ask Spring Framework team (https://jira.spring.io/browse/SPR) to refactor JmsTemplate internal for better inheritance.

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