0

I have a basic setup where a consumer is listening to a "/queue/work" for items. The consumer is meant to only consume one item at a time.

to do so i NACK any other item received concurrently and also UNSUBSCRIBE from the queue while the item is getting processed.

if i now SUBSCRIBE to the same queue again, the NACKed messages are not redelivered to the client - unless i drop the whole connection and reconnect the session - which is not exactly what i want to do since it impacts other subscriptions too :(

is there another way to implement this "take one item - ignore while busy" pattern ?

light_303
  • 2,101
  • 2
  • 18
  • 35

2 Answers2

0

According to the STOMP Protocol Spec, the server does not re-deliver the NACKed message to the client that sent the NACK.

When you re-subscribe, try using a different id header value that is not used by any other subscriber.

Luke Bakken
  • 8,993
  • 2
  • 20
  • 33
0

To answer my own question - the way to implement it without ever having to NACK a message which produces the redelivery problem is to use a combination of transactions and prefetch settings:

if setting the "prefetch-count": 1 in the STOMP header - the server will only allow one message "in flight" on the channel before sending the next. This means that the client has to ACK/NACK the message before a new one is sent.

So instead of sending an ACK only if the "job" is completed - we instead start a transaction when we receive the message - ACK the message immediately - and COMMIT the transaction when the job is done. This way "failed" jobs are redelivered correctly.

light_303
  • 2,101
  • 2
  • 18
  • 35