} } if (pn_credit($lnk) < 10) { pn_flow($lnk, 10); } } else { if (pn_writable($delivery)) { // we have capacity to write, so let's send a message list($cd, $msg) = pn_message_data("this is message {$tag}", 1024); $n = pn_send($lnk, $msg); if ($n != strlen($msg)) { print "error sending message: {$cd}"; } if (pn_advance($lnk)) { print "sent {$tag}\n"; pn_delivery($lnk, "delivery-{$counter}"); $counter++; } } } if (pn_updated($delivery)) { // the disposition was updated, let's report it and settle the delivery print "disposition for {$tag}: " . pn_remote_disposition($delivery) . "\n"; // we could clear the updated flag if we didn't want to settle // pn_clear($delivery); pn_settle($delivery); } $delivery = pn_work_next($delivery); } // teardown any terminating links $lnk = pn_link_head($conn, PN_LOCAL_ACTIVE | PN_REMOTE_CLOSED);
$conn = pn_connection(); pn_connector_set_connection($c, $conn); pn_connection_set_hostname($conn, "rschloming.servicebus.appfabriclabs.com"); pn_connection_set_container($conn, "asdf"); $ssn = pn_session($conn); $snd = pn_sender($ssn, "sender"); pn_set_target($snd, "queue1"); $rcv = pn_receiver($ssn, "receiver"); pn_set_source($rcv, "queue1"); // open all the endpoints pn_connection_open($conn); pn_session_open($ssn); pn_link_open($snd); pn_link_open($rcv); // set up an initial delivery pn_delivery($snd, "delivery-{$counter}"); $counter++; // allocate some initial credit pn_flow($rcv, min($count ? $count : 10, 10)); $done = false; while (!$done) { // wait until there is an active connector or listener pn_driver_wait($driver, -1); // cycle through all connectors with I/O activity while ($c = pn_driver_connector($driver)) { // process work due to I/O events pn_connector_process($c); $h = pn_connector_context($c); $h($c); if (pn_connector_closed($c)) { pn_connection_free(pn_connector_connection($c));