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

Options
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: 406 Solace Employee
    Options

    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
    Options

    @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: 499 admin
    Options

    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!