Skip to content

pcntl signals processed only after message is handled #89

@richardfullmer

Description

@richardfullmer

Hey @videlalvaro,

Great bundle. We use it in many of our projects.

Recently, we've had some issues with one of our consumers that doesn't receive messages that often. 1 per 30 minutes or so.

The issue we have is with handling the pcntl signals. Presently, handling signals happens after the next message is processed. When your script is processing messages at a rate of 1 per second, sending a SIGINT will only have you waiting 1 second before it's handled properly.

Now, in the case of 1 per 30 minutes, this is obviously a problem. We're specifically having the issue during deploys. We want to restart all consumers each deploy. Waiting 30 minutes really isn't an option.

Is there a way to have the following happen?

  • If a signal arrives while the consumer is waiting for the message, it just handles it immediately and close down.
  • If a signal arrives during the processing of one of these messages, it obviously should finish handling the message first, then handle the signal and close down.

I tried playing around with the bundle and the underlying lib, but the architecture seems to make this hard to accomplish.

Any ideas? I'm happy to write the code if there's a good solution without a ton of refactoring.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions