Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@yakuter
Created May 5, 2019 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yakuter/2a262b2db86b1bd6a15821345b923810 to your computer and use it in GitHub Desktop.
Save yakuter/2a262b2db86b1bd6a15821345b923810 to your computer and use it in GitHub Desktop.
PHP and NATS.io Example
<?php
require_once 'vendor/autoload.php';
// Yeni bağlantı nesnesi oluşturma ve bağlanma
$client = new \Nats\Connection();
$client->connect();
// Subscriber
$callback = function($payload)
{
printf("Data: <strong>%s</strong>", $payload);
};
$sid = $client->subscribe("foo", $callback);
// Publisher
$client->publish('foo', 'Erhan Yakut');
// 1 mesaj gelene kadar bekletme
$client->wait(1);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment