🎄 Happy Holidays! 🥳

Most of Solace is closed December 24–January 1 so our employees can spend time with their families. We will re-open Thursday, January 2, 2024. Please expect slower response times during this period and open a support ticket for anything needing immediate assistance.

Happy Holidays!

Please note: most of Solace is closed December 25–January 2, and will re-open Tuesday, January 3, 2023.

I want to add delay on consumption of messages. Delay will be dynamic in my application.

Diksha
Diksha Member Posts: 2

I want to add delay on consumption of messages. Delay will be dynamic in my application.

Example: For Message A delay will be of 1 min and for Message B delay will be 2 min.

I tried with below code of snippet but it's not working.

TextMessage msg = JCSMPFactory.onlyInstance().createMessage(TextMessage.class);
msg.setDeliveryMode(DeliveryMode.PERSISTENT);
msg.setText("Hi!");
msg.setCorrelationKey(msg);
msg.setTimeToLive(10000L);
producer.send(msg, queue);


Answers

  • TomF
    TomF Member, Employee Posts: 412 Solace Employee

    Hi Diksha,

    The TimeToLive message property instructs the broker to remove the message from a queue after that time, so it isn't going to help with what you're trying to do. Once the TTL expires, the message is moved to a dead message queue.

    As of broker 9.10, you can add a delay to delivery from a specific queue. See "Delayed Delivery." Any message published to this queue will be delivered after the delay you specify. Note that the delay is configured on the queue, not the message.

  • Diksha
    Diksha Member Posts: 2

    @TomF Thank you for your quick response.

    As per your comment, i can understand there is no way in solace to add delay on messages rather than queue. (Want to achieve dynamic delay). Please confirm.

    I will explain you about my requirement.

    In my project, i am sending request to consumer and getting back some response. On the basis of response i want to implement exponential retry of the same message until i will not get the success response or my retry count will not get exhaust. So the retry will be like: 1min -> 2 min -> 4min -> 8 min -> 16 min -> 32min so on.

    Currently we are using RabbitMQ in our application and we are achieving this exponential retry functionality using "x-delay" property. But RabbitMQ doesn't support active active. So we are thinking to migrate from RabbitMQ to Solace.

    Please let me know, is there any way in solace to achieve this dynamic delay on messages for retries.

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 541 admin

    Hey @Diksha, we have a community driven github organization that hosts opensource integrations and solutions. One of the repos is a solace redelivery delayer authored by @tkunnumpurath - take a look at it and see it meets your requirements.


    Hope this helps!