- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.7k
feat(Ack.InProgress): publish advisory message #7284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This allows a job queue controller to detect whether a job has started / is being worked on. InProgress is also the only ACK message that does not have a corresponding advisory message, so this fills the gap. Signed-off-by: Benjamin Sparks <[email protected]>
| Generally not against this, but the progress ack is not about indicating a job has started, this is not what the feature is for. It's lets say you have a minute to handle a email delivery but the SMTP server is a bit slow and you need another minute, thats what its for. These acks - and so advisories - are for exceptional cases but from the description it sounds a bit like you want to use them every time a job starts? We should not use server generated advisories for that imo. Advisories are for exceptional cases generally not for something that happens on every message. | 
| @ripienaar hey 😄 thanks for the quick response. Depending on the task, a long time between job enqueuement and its completion / failure / error can pass, so it would be great to be able to monitor which jobs are outstanding, requiring the worker to only supply the corresponding  This could be aimed more at long-lived tasks, which would benefit more from precise lifecycle tracking, e.g. video encoding, where one might have to wait a long time to see the result, and not know if the task has been dispatched yet / is being worked upon. For example, Redis exposes this information with XPENDING for its Streams: 
 Adding this advisory message would implement similar functionality, as monitoring for this new advisory message allows detection of which messages are pending completion / currently being worked on. #[derive(Default)]
enum JobState {
    // Worker detected a transient failure and can retry,
    // and has therefore `AckNak`'ed the message,
    // which triggered the `CONSUMER.MSG_NAKED` advisory message.
    // This is also the default state upon insertion into storage.
    #[default]
    Enqueued,
    // Worker signalled that it is actively processing the requested job
    // and has therefore `AckInProgress`'ed the message,
    // which SHOULD trigger a `CONSUMER.IN_PROGRESS` advisory message
    Active, // <-- this is the state I'd like to trigger using this PR 
    // Worker has successfully completed the job
    // and indicates this by having `AckAck`'ed the message.
    // triggering the `CONSUMER.ACK` advisory message
    Success,
    // Worker detects that the job cannot be completed as was requested,
    // sending `AckTerm` to not reattempt the task,
    // triggering the `CONSUMER.MSG_TERMINATED` advisory message
    Error,
    // Worker detected a transient failure, but cannot retry due to
    // having exhausted `max_deliver`,
    // which triggers the `CONSUMER.MAX_DELIVERIES` advisory message
    Failure,
} | 
| But you can also just have a KV with a job status per job ID that you write into as things progress right? Those wishing to know job progress can watch the KV and be notified. With the added benefit of it being reliable (unlike advisories) and doing exactly what you want or choose to implement | 
| That is true, but it places additional responsibility on the worker to be aware of what to write where, which might not be feasible e.g. if the worker crashes (job gets stuck in  I'm not sure if I understand what you mean by advisories being unreliable, do you mean meeting delivery guarantees? | 
| Advisories are published using core nats, with no retries, no effort to make sure they reach the stream even if configured to listen on subjects. It's best efforts and subject to at-most-once guarantees. For the stream example, if a advisory gets published and the stream is leader-less or unreachable the advisory will just be lost. They really are only advisories that something exceptional has happened but for which delivery is not essential. You should not build application reliability logic ontop of these, strongly suggest you put your job management business status flow needs in your business domain | 
| I see, that's unfortunate, but thanks very much for the advice on advisories and watchable KVs, that is very helpful to know 😄 Thanks for your time, and for the continued development of NATS ❤️ | 
| Lets park it for after 1.12 release, there's a few ack related things I'd like to see: 
 So the first one there could certainly impact what we do here | 
This allows a job queue controller to detect whether a job has started / is being worked on.InProgress is also the only ACK message that does not have a corresponding advisory message, so this fills the gap.
Signed-off-by: Benjamin Sparks [email protected]