activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Schulze <schulze-ho...@gmx.net>
Subject ActiveMQ + PHP + Stomp = ActiveStack ??
Date Wed, 06 Jun 2007 09:58:29 GMT

I tried to use ActiveMQ 4.1.1 with stomp connector from PHP (after porting
Stomp.php for use with PHP5). Surprisingly it behaves like a stack:

===
producer.php:
----
<?php
require_once 'Stomp5.php';

header('Content-type: text/plain');

function send($msg) {
    global $c;
    $c->subscribe('/queue/FOO');
    $c->send('/queue/FOO', $msg, array('expires' => 1));
    print 'sent: '.$msg.PHP_EOL;
}

$c = new StompConnection('localhost');
$result = $c->connect('producer', 'test');
$c->subscribe('/queue/FOO');

send('Hello World!');
send('Hello Mars!');

$c->disconnect();
?>
----
sent: Hello World!
sent: Hello Mars!
===

===
consumer.php
---
<?php
require_once 'Stomp5.php';

header('Content-type: text/plain');

function consume() {
    $c = new StompConnection('localhost', 5);
    $result = $c->connect('bobo', 'test');
    $c->subscribe('/queue/FOO');
    $result = $c->receive();
    print 'read: '.$result->body . PHP_EOL;
    $c->acknowledge($result->headers['message-id']);
    $c->disconnect();
    return true;
}

consume();
consume();

?>
---
read: Hello Mars!
read: Hello World!
===

Am I wrong?
-- 
View this message in context: http://www.nabble.com/ActiveMQ-%2B-PHP-%2B-Stomp-%3D-ActiveStack----tf3876949s2354.html#a10985635
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message