Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

169
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda