Try PubSub+

How to delay sending out messages in Solace PubSub+

honghong Administrator Posts: 166 admin
edited July 2019 in Tips and Tricks #1

Problem

You do not want Solace PubSub+ to send out your message to the subscribers right away. Instead, you want it to send out the message until a timestamp is reached.

Prerequisite

Download Solace PubSub+ and SDKPerf.

Solution

To let PubSub+ delay sending out messages, follow these steps:

  1. In PubSub+ Manager, select Queues and then click the green + Queue button.

  1. In the Create Queue dialog box, type the name of the queue you want to create (queue_b for this example) and click Create.

  1. In the Edit Queue Settings dialog box, enter queue_a as the DMQ Name and the Maximum TTL (sec) value (3600 for this example).

  1. Repeat Steps 1-3 to create a new queue called queue_b without the DMQ Name and Maximum TTL (sec).

  1. In SDKPerf, run the command below to set the consuming application to consume from Queue A.
    sdkperf_java_d34 -cip tcp://192.168.133.47:55555 -cu [email protected]_vpn -sql=queue_a

  2. In SDKPerf, run the command below to set the publishing application to publish to queue_b with the DMQ eligible flag set.
    sdkperf_java_d34 -cip tcp://192.168.133.47:55555 -cu [email protected]_vpn -pql=queue_b -mn=10 -mt=persistent -mdq

Result

When you send the message on to queue_b, it will stay there until the TTL expires. Then Solace PubSub+ will move the message to queue_a and deliver it to your publishing application.

Learn more

Documentation: Setting Dead Message Queues

Comments

  • TomFTomF Member, Employee Posts: 227 Solace Employee

    I love this trick! Simple, easy, but surprisingly cunning.

  • ShawnShawn Member, Employee Posts: 1 Solace Employee

    In many cases, its not practical to set the delay time as the TTL on the queue itself because (a) this same value is applied to all messages (b) the delay you want to apply will depend on when the app publishes the message vs when it should be made available for consumption. So in most cases, the publisher will set the TTL on each message when it is produced as the delta between time the message should be available to consume and the time at which it is published. With the JCSMP API, for example, you can do this with void setTimeToLive(long ttl) on XMLMessage (https://docs.solace.com/API-Developer-Online-Ref-Documentation/java/index.html).

  • MukundMukund Member Posts: 2

    This is a nice trick. Its behaving more of a scheduler now .
    Does solace recommend it for Business critical messages Handling ? . Are there any drawbacks /disadvantages of this ? .

  • TomFTomF Member, Employee Posts: 227 Solace Employee

    Hi @Mukund, great question. My personal feeling is that by doing this sort of thing you are bringing business logic into the event distribution layer, which breaks separation of concerns. This is one of the reasons ESBs started to fall out of favour. So I personally would only do this kind of thing as a fix to a problem or if it can't be avoided, say in a legacy integration - I would not want to incorporate it as an architectural practice.

    That's just my opinion, though - happy to hear other people's.

  • MukundMukund Member Posts: 2

    Thanks . Appreciate your quick feedback.

  • marcmarc Member, Administrator, Moderator, Employee Posts: 361 admin

    @Mukund and anyone else that comes across this thread, a "Delayed Delivery Queue" is a new feature on the roadmap for an upcoming broker release (maybe even by the end of summer ;) ) so stay tuned and we'll let you know when it's available to try out

Sign In or Register to comment.