0

I'm using this process to send pushes , so all this depends on control Messaged Id.
What i thought about is how can i run this process with each id in the same time.
Example :
$RedyToSend=[12,23,34,45,...] //List of Control Message Id's
I want to make the process like this: (i don't know if it's possible)

For Every id:
Dispatcher(12);
Dispatcher(23);
.
.
.
etc..
This is the code that i am using, i am thinking about getting it out from the main, put it into another function() then call it with providing it a different Control Message ID in the same time.

    public function main(){

                $readyToSend = $this-> controlMessageDAO-> getPendingToSend();

    if(is_array($readyToSend)) {

        foreach($readyToSend as $controlMessage)
        {
            $controlMessageId = $controlMessage["control_message_id"];
            $this-> saveLog("Ready to send control message " . $controlMessageId);

            $maxInsertId = $this-> messageLogInsertDAO-> getMaxId($controlMessageId);

            $this-> handleControlMessage($controlMessageId);
            $this-> handlePlatformData($this-> controlMessageVO);

            $recipients = $this-> messageLogInsertDAO-> getRecipients($controlMessageId, $maxInsertId);

            $this-> messageLogInsertDAO-> updateMessageLogInsertStatus($maxInsertId, $controlMessageId);
            $this-> handleRecipients($this-> controlMessageVO, $recipients);
        }
    }
  • Is this what you are looking for ? https://stackoverflow.com/a/15501449/11265949 – filipe Apr 09 '19 at 17:20
  • Thank you for your answer ,i'll try that – Mohamed Ali Nakouri Apr 09 '19 at 17:22
  • 1
    Just a heads up that pthreads is a PHP extension not available in most server environments. PHP is a synchronous language, most end up just using queues for event or message dispatching if you don't want them to run synchronously. – Devon Bessemer Apr 09 '19 at 17:26
  • 1
    @Devon Not available in **any** server environments, in fact. The pthreads extension is only available in php-cli. –  Apr 09 '19 at 17:32
  • Possible duplicate of [Asynchronous Function Call in PHP](https://stackoverflow.com/questions/14236296/asynchronous-function-call-in-php) – miken32 Apr 09 '19 at 18:10

0 Answers0