PHP Doku:: Commits a transaction in progress - stomp.commit.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzSonstige DiensteStomp ClientThe Stomp classStomp::commit -- stomp_commit

Ein Service von Reinhard Neidl - Webprogrammierung.

The Stomp class

<<Stomp::begin -- stomp_begin

Stomp::__construct -- stomp_connect>>

Stomp::commit

stomp_commit

(PECL stomp >= 0.1.0)

Stomp::commit -- stomp_commitCommits a transaction in progress

Beschreibung

Object oriented style (method):

public bool Stomp::commit ( string $transaction_id [, array $headers ] )

Procedural style:

bool stomp_commit ( resource $link , string $transaction_id [, array $headers ] )

Commits 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 id.

headers

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

Rückgabewerte

Gibt bei Erfolg TRUE zurück. Im Fehlerfall wird FALSE zurückgegeben.

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 wird dazu führen, dass Methoden nicht zurückkehren, bis der Server den Empfang der Nachricht bestätigt hat oder der Lese-Timeout übershcritten wurde.

Beispiele

Beispiel #1 Object oriented style

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

?>

Beispiel #2 Procedural style

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

?>


Keine BenutzerBeiträge.
- Beiträge aktualisieren...



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)