CakeFest 2024: The Official CakePHP Conference

Класс Stomp

(PECL stomp >= 0.1.0)

Введение

Представляет связь между PHP и Stomp совместимым брокером сообщений (Message Broker).

Обзор классов

class Stomp {
/* Методы */
public __construct(
    string $broker = ini_get("stomp.default_broker_uri"),
    string $username = ?,
    string $password = ?,
    array $headers = ?
)
public abort(string $transaction_id, array $headers = ?): bool
stomp_abort(resource $link, string $transaction_id, array $headers = ?): bool
public ack(mixed $msg, array $headers = ?): bool
stomp_ack(resource $link, mixed $msg, array $headers = ?): bool
public begin(string $transaction_id, array $headers = ?): bool
stomp_begin(resource $link, string $transaction_id, array $headers = ?): bool
public commit(string $transaction_id, array $headers = ?): bool
stomp_commit(resource $link, string $transaction_id, array $headers = ?): bool
stomp_connect(
    string $broker = ini_get("stomp.default_broker_uri"),
    string $username = ?,
    string $password = ?,
    array $headers = ?
): resource
stomp_close(resource $link): bool
public error(): string
stomp_error(resource $link): string
stomp_get_read_timeout(resource $link): array
stomp_get_session_id(resource $link): string|false
public hasFrame(): bool
stomp_has_frame(resource $link): bool
public readFrame(string $class_name = "stompFrame"): stompframe
stomp_read_frame(resource $link): array
public send(string $destination, mixed $msg, array $headers = ?): bool
stomp_send(
    resource $link,
    string $destination,
    mixed $msg,
    array $headers = ?
): bool
public setReadTimeout(int $seconds, int $microseconds = ?): void
stomp_set_read_timeout(resource $link, int $seconds, int $microseconds = ?): void
public subscribe(string $destination, array $headers = ?): bool
stomp_subscribe(resource $link, string $destination, array $headers = ?): bool
public unsubscribe(string $destination, array $headers = ?): bool
stomp_unsubscribe(resource $link, string $destination, array $headers = ?): bool
public __destruct()
}

Содержание

  • Stomp::abort — Отменяет выполнение текущей транзакции
  • Stomp::ack — Подтверждает получение сообщения
  • Stomp::begin — Создаёт транзакцию
  • Stomp::commit — Выполняет текущую транзакцию
  • Stomp::__construct — Открывает соединение
  • Stomp::__destruct — Закрывает Stomp-соединение
  • Stomp::error — Возвращает последнюю ошибку Stomp
  • Stomp::getReadTimeout — Возвращает время максимального ожидания операции чтения
  • Stomp::getSessionId — Возвращает идентификатор текущей сессии Stomp
  • Stomp::hasFrame — Проверяет, возможно ли чтение фрейма
  • Stomp::readFrame — Выполняет операцию чтения следующего фрейма
  • Stomp::send — Отправляет сообщение
  • Stomp::setReadTimeout — Устанавливает предельное время ожидания операции чтения
  • Stomp::subscribe — Регистрирует подписку на указанную рассылку
  • Stomp::unsubscribe — Удаляет существующую подписку
add a note

User Contributed Notes 1 note

up
1
guilherme dot geronimo at gmail dot com
6 years ago
In some cases (E.g. ActiveMQ), when you have many consumers you need to identify your "client-id" during the connection process, otherwise the server can misunderstand your connection and create new topics/queues:

<?php
$stomp
= new Stomp($url, $user, $password, array('client-id'=> $clientId ));
?>
To Top