Search code examples
phpactivemq-classicmessage-queuestompmessagebroker

php messagelistener for activemq


I am currently using stomp to send and receive/consume messages in activemq queues, but the stomp consumer is working synchronously , meaning the stomp consumer keeps checking if there is any new messages in the queue .But what I need to do is to make activemq notify my stomp consumer when a new message enters the queue . like the Onmessage() method in Java for example . I searched for days but still no luck . my current php code ( how I read messages from queue using stomp) :

while (true) {

       $frame = $stomp->readFrame();
       if ($frame != NULL) {
           print "Received: " . $frame->body . " - time now is " . date("Y-m-d H:i:s"). "\n";
           $stomp->ack($frame);
       }
       else {
       print "No frames to read\n";
   }

Solution

  • solved the problem .

    used github.com/reactphp/stomp library and it worked perfectly . it consumes messages from my message broker asynchronously now .