I've downloaded the library available in: https://github.com/dejanb/stomp-php
and then implemented the following code:
<?php
use FuseSource\Stomp\Stomp;
(...)
$data=array($data1,$data2, $data3, $data4);
$json = json_encode($data, true);
$user = getenv("ACTIVEMQ_USER");
if( !$user ) $user = "admin";
$password = getenv("ACTIVEMQ_PASSWORD");
if( !$password ) $password = "password";
$destination = '/topic/event';
$messages = 10000;
$size = 256;
$DATA = "calls";
$body = $data;
for($i=0; $i< $size; $i++) {
$body .= $DATA[ $i % 26];
}
try {
$url = 'tcp://localhost:61613';
$con = new Stomp($url, $user, $password);
for($i=0; $i< $messages; $i++) {
$con->send($destination, $body);
if( $i%1000 == 0 ) {
echo "Sent ".$i." messages\n";
}
}
$stomp->send($destination, "SHUTDOWN");
} catch(StompException $e) {
echo $e->getMessage();
}
}
and I get this error:
Fatal error: Uncaught Error: Class 'Stomp' not found in /opt/lampp/htdocs/skeleton-application/test.php:80
UPDATE:
I reinstalled using composer
as suggested at https://github.com/stomp-php/stomp-php.
I required the autoloader using
<?php
require __DIR__ . '/../vendor/autoload.php';
and added the following imports
use Stomp\Client;
use Stomp\StatefulStomp;
use Stomp\Network\Connection;
use Stomp\Transport\Message;
Still same error... Do I need to do anything special with my activemq broker or something? I ran it through the console... but still nothing