Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!