Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // было
- list($queue, $connection, $exchange) = amqp_connect(RABBIT_HOST);
- amqp_add([
- 'action' => $action,
- 'server' => RABBIT_HOST,
- 'order_type' => $app_type,
- 'app_id' => $app_id,
- 'bank' => $app['bank_code'],
- 'sequence' => 1,
- 'starttime' => 0,
- 'uniqid' => uniqid()
- ], $connection, $exchange);
- // Счетчик процессов
- // стало
- list($queue, $connection, $exchange) = amqp_connect(RABBIT_HOST);
- // проверка наличия задачи в очереди
- $found = false;
- while (true) {
- if ($envelope = $queue->get()) {
- $m = json_decode($envelope->getBody());
- if ($m->server == RABBIT_HOST && $m->action == $action && $app['bank_code'] == $m->bank && $app_type == $m->order_type && $app_id == $m->app_id) {
- $found = true;
- break;
- }
- $m = null;
- } else {
- break;
- }
- }
- if ($found) {
- $connection->disconnect();
- return false;
- }
- amqp_add([
- 'action' => $action,
- 'server' => RABBIT_HOST,
- 'order_type' => $app_type,
- 'app_id' => $app_id,
- 'bank' => $app['bank_code'],
- 'sequence' => 1,
- 'starttime' => 0,
- 'uniqid' => uniqid()
- ], $connection, $exchange);
- // Счетчик процессов
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement