STOMP Wildcard based queue subscription

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

STOMP Wildcard based queue subscription

tapan.thapa
Hello,

I am using below php code for producer and consumer for wildcard subscription on queues but i am getting errors.

Producer code:

<?php

// include a library
require_once("Stomp.php");
// make a connection
$con = new Stomp("tcp://localhost:61613");
$con->sync = false;
// connect
$con->connect();
for ($i = 0; $i <= 100; $i++) {
// send a message to the queue
    $con->send("htmsl.$i", "queue.$i");
    echo "Sent message with body 'queue.$i'\n";
}
// disconnect
$con->disconnect();
?>

Consumer code:

<?php

// include a library
require_once("Stomp.php");
// make a connection
$con = new Stomp("tcp://localhost:61613");
$con->sync = false;
// connect
$con->connect();
// subscribe to the queue
$con->subscribe("htmsl.>");
// receive a message from the queue
while (TRUE) {
    $msg = $con->readFrame();

// do what you want with the message
    if ($msg != null) {
        //$headers = explode(':', $msg->headers['message-id']);
        //$transactionId = $headers[1];
        //echo "Received message with body $msg->body\n";
        var_dump($msg);
        //echo $transactionId . "\n";
        // mark the message as received in the queue
        //$con->ack($transactionId);        
        $con->ack($msg);
        sleep(1);
    } else {
        echo "Failed to receive a message\n";
    }
}
// disconnect
$con->disconnect();
?>

Errors:
message: ACK received without a message-id to acknowledge!
ERROR:
at java.lang.Thread.run(Thread.java: 619)

 : org.apache.activemq.transport.stomp.ProtocolException: ACK received without a message-id to ackno
wledge!
 WARN | Exception occurred processing:
ACK
content-type: text/plain
:
at org.apache.activemq.transport.stomp.ProtocolConverter.onStompAck(ProtocolConverter.java: 303)
at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java: 83)
at org.apache.activemq.transport.stomp.StompTransportFilter.onCommand(StompTransportFilter.java: 76)

message: ACK received without a message-id to acknowledge!
at org.apache.activemq.transport.stomp.ProtocolConverter.onStompCommand(ProtocolConverter.java: 166)

ERROR:
at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java: 222)
at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java: 204)
at java.lang.Thread.run(Thread.java: 619)

 : org.apache.activemq.transport.stomp.ProtocolException: ACK received without a message-id to ackno
wledge!
 WARN | Exception occurred processing:
ACK
content-type: text/plain
:
at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java: 83)
message: Unexpected ACK received for message-id [ ID:tapan-htmsl-20386-1338126998218-2:57:-1:1:70]
ERROR:
at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java: 222)
at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java: 204)
at java.lang.Thread.run(Thread.java: 619)

 : org.apache.activemq.transport.stomp.ProtocolException: ACK received without a message-id to ackno
wledge!
 WARN | Exception occurred processing:
ACK
content-type: text/plain
:

Please suggest.

Regards
Tapan Thapa