Created
June 1, 2017 15:09
-
-
Save kevinmlong/e9374d10d64dfe4c4cfe87afea4d5a40 to your computer and use it in GitHub Desktop.
Example Implementation for PHP Event Bus Using RabbitMQ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Example of PHP Script #1 | |
*/ | |
// Do some work... | |
// Need to send a message | |
// Create an instance of Postmaster | |
$postmaster = Postmaster::create(); | |
// We need something to tell Postmaster to send - let's make a Letter | |
$letter = new Letter(); | |
$letter->setMessage('This is an important message!'); | |
// We need to tell the Postmaster to send the Letter for us | |
$postmaster->send($letter); | |
// Do some more work... | |
/** | |
* Example of PHP Script #2 | |
* This is a very simple script that creates a LetterCarrier and then waits for messages. | |
* Messages received are processed by the carrier's receivedMessage method | |
*/ | |
$letterCarrier = new LetterCarrier(); | |
$letterCarrier->waitForMail(); | |
/* In the console for PHP Script #2 we should see the output of receivedMessage: | |
* The message in the letter is: This is an important message! | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment