前面我们已经学了怎样部署ActiveMQ。
我们知道通过ActiveMQ的一个管理后台能够查看任务队列。
今天
用PHP来操作ActiveMQ。我们能够借助一个第三方扩展。
下载:
composer require fusesource/stomp-php:2.0.*
然后新建test.php:
<?php
require __DIR__.'/vendor/autoload.php'; //引入自己主动载入的文件
$connect = new FuseSourceStompStomp('tcp://10.211.55.13/:61613');
$connect->connect();
$userId = 1001;
$result = $connect->send('email',$userId); //比方发邮件
var_dump($result);
发送消息成功。打印bool(true)
我们在ActiveMQ自带的管理后台查看,确实有一个名为”email”的队列。
上面我们发送的一个id,我们还能够发送json数据。
$data = array('id'=>1001,'email'=>'110@qq.com','content'=>'test');
$result = $connect->send('email',json_encode($data));
我们在MQ后台能够查看消息具体
上面的代码到这里,还不够完美。假设我们server重新启动了activemq。没有处理的消息会丢失。
这个时候我们须要用到send()
方法的第三个參数。
//消息持久化 persistent为true,字符串的'true'
$result = $connect->send('email',json_encode($data),array('persistent'=>'true'));
前面我们完毕了『发送』
给mqserver发送消息(email消息)。
那么在mq的队列中的任务,又是怎么处理的呢?
<?php
require __DIR__.'/vendor/autoload.php'; //引入自己主动载入的文件
$connect = new FuseSourceStompStomp('tcp://10.211.55.13/:61613');
$connect->connect();
//订阅队列消息
$connect->subscribe('email');
if ($connect->hasFrameToRead()){
$frame = $connect->readFrame();
print_r(
git clone Failed to connect to 127.0.0.1 port 43213: Connection refused
chrome不能浏览任何网页,提示配置proxy,Ubuntu
Ubuntu16下用virtualbox 安装Windows虚拟机
mobilenet之Depthwise +Pointwise
联想电脑t450,t460p,t470等安装好ubuntu后启动找不到系统
tensorflow-serving-gpu 本地编译并使用
git克隆远程仓库的时候断电了,使用git-fetch断点续传
java ->Servlet接口
java ->Tomcat服务器
- 最新文章
-
make,makefile,cmake“暴力编译法”的个人经验或理解。
tensorflow 1.9 ,bazel 0.15.0,源码编ERROR, Skipping, '//tensorflow/tools/pip_package:build_pip_package',error loading packageCuda Configuration Error, Cannot find libdevice.10.bc under /usr/local/cuda-8.0
git 提交丢失Warning, you are leaving 2 commits behind,
kalman filter卡尔曼滤波器- 数学推导和原理理解-----网上讲的比较好的kalman filter和整理、将预测值和观测值融和
faster rcnn源码阅读笔记1
MTCNN源码阅读之训练测试过程,其和faster -rcnn 等目标识别的区别在哪里?
Mask RCNN 源码阅读(update)
texmaker报错:could not start command 解决
关于吴恩达机器学习支持向量机的问题,讲到对偶前有一个最小化f(w)使用拉格朗日求解时转化成一个最大的相等式的理解和一些困惑
python,opencv,imread,imwrite,存储,读取图像像素不一致,这种情况是label使用jpg格式
- 热门文章
-
ImportError: No module named pycocotools.coco,pycocotools/_mask.so: undefined symbol: _Py_ZeroStruct
TypeError: Fetch argument None has invalid type <type 'NoneType'>
深度学习中,使用regularization正则化(weight_decay)的好处,loss=nan
Could not find a package,configuration file provided by "G2O" ,G2OConfig.cmake,g2o-config.cmake
cmake 指定连接的opencv版本
cmake find_package 中,include_directories,target_link_libraries 的值怎么知道?
Could not find a package configuration file provided by "Sophus",SophusConfig.cmake
tensorflow报错error,tf.concat Expected int32, got list containing Tensors of type '_Message' instead
service mysqld start,Failed to start mysqld.service: Access denied
Ubuntu下解决MySQL自启动,chkconfig list 全部off 情况