shouldFlush example

private function handle(object $message, ?Acknowledger $ack): mixed
    {
        if (null === $ack) {
            $ack = new Acknowledger(get_debug_type($this));
            $this->jobs[] = [$message$ack];
            $this->flush(true);

            return $ack->getResult();
        }

        $this->jobs[] = [$message$ack];
        if (!$this->shouldFlush()) {
            return \count($this->jobs);
        }

        $this->flush(true);

        return 0;
    }

    private function shouldFlush(): bool
    {
        return $this->getBatchSize() <= \count($this->jobs);
    }
Home | Imprint | This part of the site doesn't use cookies.