MqController.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * @link http://www.yiiframework.com/
  4. * @copyright Copyright (c) 2008 Yii Software LLC
  5. * @license http://www.yiiframework.com/license/
  6. */
  7. namespace console\controllers;
  8. use yii\console\Controller;
  9. use components\PhpClient;
  10. use PhpAmqpLib\Message\AMQPMessage;
  11. use PhpAmqpLib\Connection\AMQPStreamConnection;
  12. /**
  13. * This command echoes the first argument that you have entered.
  14. *
  15. * This command is provided as an example for you to learn how to create console commands.
  16. *
  17. * @author Qiang Xue <qiang.xue@gmail.com>
  18. * @since 2.0
  19. */
  20. class MqController extends Controller
  21. {
  22. /**
  23. * This command echoes what you have entered as the message.
  24. * @param string $message the message to be echoed.
  25. */
  26. public function actionIndex($message = 'rabbit mq begin')
  27. {
  28. echo $message . "\n";
  29. $client = new PhpClient();
  30. $responses = $client->call('mq begin'); //在这里传入发送给服务端脚本的内容
  31. }
  32. /**
  33. * This command echoes what you have entered as the message.
  34. * @param string $message the message to be echoed.
  35. */
  36. public function actionReceive($message = 'rabbit mq Receive')
  37. {
  38. $client = new PhpClient();
  39. $responses = $client->call('direct type test','logs'); //在这里传入发送给服务端脚本的内容
  40. var_dump("Receive Message OK");
  41. }
  42. /**
  43. * This command echoes what you have entered as the message.
  44. * @param string $message the message to be echoed.
  45. */
  46. public function actionSend($message = 'rabbit mq send')
  47. {
  48. echo $message . "\n";
  49. $client = new PhpClient();
  50. $responses = $client->call('direct type test','logs'); //在这里传入发送给服务端脚本的内容
  51. var_dump("Send Message OK");
  52. }
  53. }