File: procedural.php

package info (click to toggle)
php-stomp 1.0.5-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 260 kB
  • ctags: 205
  • sloc: ansic: 1,557; xml: 299; php: 108; makefile: 13; sh: 10
file content (24 lines) | stat: -rw-r--r-- 524 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php

$broker = 'tcp://localhost:61613';
$queue  = '/queue/foo';
$msg    = 'bar';

if($stomp = stomp_connect($broker)) {

    stomp_begin($stomp, 't1');
    stomp_send($stomp, $queue, $msg, array('transaction' => 't1'));
    stomp_commit($stomp, 't1');

    stomp_subscribe($stomp, $queue);
    $frame = stomp_read_frame($stomp);
    if ($frame['body'] === $msg) {
        echo "Worked\n";
        stomp_ack($stomp, $frame['headers']['message-id']);
    } else {
        echo "Failed\n";
    }

    stomp_close($stomp);
}