PHP Synchronous vs. Asynchronous operations

Synchronous vs. Asynchronous operations

By default this client is configured to work in a synchronous mode, which means that for every command (except CONNECT) the client will wait for the receipt . You can set the client to work in the asynchronous mode, by setting the sync property of the StompConnection object to false.

Asynchronous client
$conn = new Stomp("tcp://localhost:61613");
$conn->sync = false;

You can also perform single operations in desired mode, no matter of the global client settings, by passing additional parameter to the appropriate method

Asynchronous method
$this->conn->send("/queue/test", "test", null, true);

Some things you have to consider when deciding whether to use synchrnous os asynchronous mode

  • When you use asynchronous mode broker errors will be ignored
  • Asynchronous method allows you to send messages faster, since will not wait for broker's response

Labels

php php Delete
synchronous synchronous Delete
asynchronous asynchronous Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.