CakeFest 2024: The Official CakePHP Conference

Stomp::abort

stomp_abort

(PECL stomp >= 0.1.0)

Stomp::abort -- stomp_abortRolls back a transaction in progress

Beschreibung

Objektorientierter Stil (method):

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

Prozeduraler Stil:

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

Rolls back a transaction in progress.

Parameter-Liste

link

Nur für prozedurale Aufrufe: Die Stomp-Verbindung, die von stomp_connect() zurückgegeben wurde.

transaction_id

The transaction to abort.

headers

Assoziatives Array, welches alle zusätzlichen Header beinhaltet (z. B. receipt).

Rückgabewerte

Gibt bei Erfolg true zurück. Bei einem Fehler wird false zurückgegeben.

Beispiele

Beispiel #1 Objektorientierter Stil

<?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'));

/* rollback */
$stomp->abort('t1');

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

Beispiel #2 Prozeduraler Stil

<?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'));

/* rollback */
stomp_abort($link, 't1');

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

?>

Anmerkungen

Tipp

Eine grundlegende Eigenschaft von Stomp ist die Synchronität. Synchrone Kommunikation kann durch das Hinzufügen eines Empfangsheaders (receipt-Header) implementiert werden. Dies führt dazu, dass Methoden solange nichts zurückgeben, bis der Server den Empfang der Nachricht bestätigt hat oder der Lese-Timeout überschritten wurde.

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top