cxf
unread,Jan 3, 2012, 10:56:20 PM1/3/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to php-amqplib-devel
hi,
I want use php-amqplib and libevent, in receiver, i get the socket
in AMQPConnection (just return $this->sock ) and set it in libevent,
when sending messaget to queue,the receiver has no action (the
callback is not even invoked at all ); is there anyting wrong, thanks
very much.
receiver code as followers:
$exchange = 'router';
$queue = 'msgs';
$consumer_tag = 'consumer';
function getMsg($fd, $events, $arg) {
$ch = $arg[0];
$queue = $arg[1];
$msg = $ch->basic_get($queue, true);
print_r($msg);
print("get a messge:\n");
}
$conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
$ch = $conn->channel();
$ch->queue_declare($queue, false, true, false, false);
$ch->exchange_declare($exchange, 'direct', false, true, false);
$ch->queue_bind($queue, $exchange);
$fd = $conn->get_socket();
//$ch->basic_consume($queue, $consumer_tag, false, true, false, false,
"getMsg1");
$base_fd = event_base_new();
$event_fd = event_new();
event_set($event_fd, $fd, EV_READ|EV_PERSIST, "getMsg", array($ch,
$queue));
event_base_set($event_fd, $base_fd);
event_add($event_fd);
event_base_loop($base_fd);