Stomp Client Stomp::commit

stomp_commit

(PECL stomp >= 0.1.0)

Stomp::commit -- stomp_commit — 진행 중인 트랜잭션을 커밋합니다.


설명

객체 지향 스타일(메소드):

public Stomp::commit(string $transaction_id, array $headers = ?): bool

절차 스타일:

stomp_commit(resource $link, string $transaction_id, array $headers = ?): bool

진행 중인 트랜잭션을 커밋합니다.


매개변수

link
절차 스타일만 해당: stomp_connect()에 의해 반환된 stomp 링크 식별자입니다.
transaction_id
중단할 트랜잭션입니다.
headers
추가 헤더를 포함하는 연관 배열(예: receipt).

반환 값

성공하면 true를, 실패하면 false를 반환합니다.


Examples

예제 #1 객체 지향 스타일

                  
<?php
/* connection */
try {
    $stomp = new Stomp('tcp://localhost:61613');
} catch(StompException $e) {
    die('Connection failed: ' . $e->getMessage());
}

/* begin a transaction */
$stomp->begin('t1');

/* send a message to the queue */
$stomp->send('/queue/foo', 'bar', array('transaction' => 't1'));

/* commit */
$stomp->commit('t1');

/* close connection */
unset($stomp);
?>
                  
                

예제 #2 절차적 스타일

                  
<?php
/* connection */
$link = stomp_connect('tcp://localhost:61613');

/* check connection */
if (!$link) {
    die('Connection failed: ' . stomp_connect_error());
}

/* begin a transaction */
stomp_begin($link, 't1');

/* send a message to the queue 'foo' */
stomp_send($link, '/queue/foo', 'bar', array('transaction' => 't1'));

/* commit */
stomp_commit($link, 't1');

/* close connection */
stomp_close($link);
?>
                  
                

메모

Stomp는 본질적으로 비동기식입니다. receipt 헤더를 추가하여 동기 통신을 구현할 수 있습니다. 이렇게 하면 서버가 메시지 수신을 확인하거나 읽기 제한 시간에 도달할 때까지 메서드가 아무 것도 반환하지 않습니다.