Skip to content

[FR]: Job ordering #380

Closed
Closed

Description

@ewhauser

In some systems, you need to guarantee order across a given partition key while still having multiple queue consumer threads. SQS has the concept of FIFO queues that we currently use for this.

The canonical use case a high volume SMS system where you are sending multiple messages to a specific customer and always want to send them in order.

Activity

  1. brandur commented on Jun 3, 2024

    @brandur
    Contributor

    This does seem like something that might be useful in the project — I've seen the same kind of thing elsewhere too.

    I'm not sure we're likely to get to this right away, so I'd suggest this workaround in the meantime: using the SMS example again, instead of putting the SMS messages directly in a River job, hold them instead as a separate database model that's ordered naturally on insert order. Then, your River job runs and just clears whatever SMS messages it finds in the database:

    func (w *SendSMSWorker) Work(ctx context.Context, job *river.Job[SendSMSArgs]) error {
        ...
    
        messagesToSend, err := queries.SMSMessageLoadByUser(job.UserID)
        ...
    
        for _, message := range messagesToSend {
            // send SMS message
        }
    
        return nil
    }
  2. locked and limited conversation to collaborators on Jul 7, 2024
  3. converted this issue into a discussion #431 on Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions