ActiveMQ 与ActiveMQ-CPP

AI权益加码!Claude Code、Cursor等20+工具免费用! 购周边限时加赠Coding Plan Lite,畅享主流AI工具!学习进阶更高效! 阅读详情

一天功夫终于知道怎么使用activeMQ的c++接口了。 花费时间最多的是不知道activemqcpp需要在activeMQ的基础上使用。

下面分别讲述activeMQ和activemqcpp的安装和使用。


一。 ActiveMQ的安装

      1. 下载 源包: http://activemq.apache.org/download-archives.html

       2. tar zxvf  apache-activemq-xxx.bin.tar.gz -C /usr/local
       3. cd apache-activemq-xxx/bin

       4. chmod 755 activemq

       5. 启动   ./activemq start

       启动后就可以查 看:  http://localhost:8161/admin, 默认 用户名和密码都是admin

 二。 安装ActiveMQ-CPP

          需要较多的依赖。参考 http://blog.csdn.net/lgh1700/article/details/51055784

(1)cppunit

打开http://activemq.apache.org/cms/building.html页面,这里介绍了cms build时用到的依赖库。
cppunit下载页面:
https://sourceforge.net/projects/cppunit/files/cppunit/1.12.1/
这里选择1.12.1版本,获取到下载地址后,在linux下可以用wget命令直接下载,或者下载完成后传到linux系统中。

tar解压后,进入目录,编译三部曲,configure、make、make install(install需要root权限):
./configure --prefix=/usr/local/cppunit/
make
make install
执行完后在/usr/local/cppunit/目录下可以看到头文件和库文件。
(2)apr

apr的全称为Apache Portable Runtime(Apache可移植运行时),Apache旗下有很多开源软件。

apr介绍页面:
http://apr.apache.org/download.cgi
这里选择最新的APR 1.5.2版本,地址为:
http://mirrors.hust.edu.cn/apache//apr/apr-1.5.2.tar.gz

同上,解压进入目录,三部曲:
./configure --prefix=/usr/local/apr/
make
make install
(3)apr-util

这里选择最新的APR-util 1.5.4版本,下载地址为:
http://mirrors.hust.edu.cn/apache//apr/apr-util-1.5.4.tar.gz

解压编译:
./configure --prefix=/usr/local/aprutil --with-apr=/usr/local/apr/
make
make install
(4)apr-iconv

这里选择最新的APR iconv 1.2.1版本,地址为:
http://mirrors.hust.edu.cn/apache//apr/apr-iconv-1.2.1.tar.gz

解压编译:
./configure --prefix=/usr/local/apr-iconv/ --with-apr=/usr/local/apr/
make
make install
(5)openssl

这里选择openssl 1.0.0a版本,下载地址为:
http://www.openssl.org/source/openssl-1.0.0a.tar.gz

解压编译:
./config --prefix=/usr/local/openssl/
make
make install

若出现报错
cms.pod around line 457: Expected text after =item, not a number
在root权限下,执行rm -f /usr/bin/pod2man 然后重新make install
(6)ActiveMQ-CPP

这里选择最新的ActiveMQ-CPP 3.9.3版本,下载页面为:
http://activemq.apache.org/cms/activemq-cpp-393-release.html

解压编译:
./configure --prefix=/usr/local/ActiveMQ-CPP --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/aprutil --with-cppunit=/usr/local/cppunit --with-openssl=/usr/local/openssl
make
make install 
这样,/usr/local/下有了ActiveMQ-CPP目录。 包含activemqcpp的头文件和lib文件

三。 示例

        启动ActiveMQ,然后启动activemqcpp的代码。 再查看http://localhost:8161/admin中的queue、topic等

       测试用例使用了别人的:

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *	 http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
// START SNIPPET: demo
#include <activemq/library/ActiveMQCPP.h>
#include <decaf/lang/Thread.h>
#include <decaf/lang/Runnable.h>
#include <decaf/util/concurrent/CountDownLatch.h>
#include <decaf/lang/Integer.h>
#include <decaf/lang/Long.h>
#include <decaf/lang/System.h>
#include <activemq/core/ActiveMQConnectionFactory.h>
#include <activemq/util/Config.h>
#include <cms/Connection.h>
#include <cms/Session.h>
#include <cms/TextMessage.h>
#include <cms/BytesMessage.h>
#include <cms/MapMessage.h>
#include <cms/ExceptionListener.h>
#include <cms/MessageListener.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <memory>
#include <decaf/util/Random.h>
using namespace activemq::core;
using namespace decaf::util::concurrent;
using namespace decaf::util;
using namespace decaf::lang;
us
Linux下安装ActiveMQ CPP ActiveMQ CPPActiveMQ CPP是用C++语言访问ActiveMQ的客户端开发库,也称cms(cpp message service),安装cms开发库需要先安装一些基础库。(1)cppunit打开http://activemq.apache.org/cms/building.html页面,这里介绍了cms build时用到的依赖库。 cppunit下载页面: https://s 阅读详情

相关推荐

ActiveMQ-CPP安装和使用指南

本文介绍了如何安装ActiveMQ-CPP以及使用ActiveMQ-CPP发送和接收消息。希望这个简单的示例能帮助您入门ActiveMQ-CPP,并在您的项目中实现高效的消息传输和处理。下载ActiveMQ-CPP:在ActiveMQ-CPP官方网站(http://activemq.apache.org/cms/index.html)上下载最新版本的ActiveMQ-CPP。请记住,在使用ActiveMQ-CPP时,需要遵守Apache ActiveMQ的相关许可证和使用条款。

BitLordX的博客 414

activemqcpp开发基础手册专业资料.doc

activemqcpp开发基础手册专业资料.doc

ActiveMQ-cpp的安装使用

至此,我们完成了ActiveMQ-cpp的安装和使用。通过以上步骤,你可以在C++项目中方便地使用ActiveMQ-cpp进行消息的发送和接收。当然,在实际项目中,你还可以进一步深入学习ActiveMQ-cpp的高级特性和更多使用方法。ActiveMQ-cpp是一个用于C++开发的开源消息中间件,它为C++开发者提供了方便的消息传递和异步通信的功能。在上述代码中,brokerURI是ActiveMQ服务器的地址和端口,默认情况下ActiveMQ使用61616作为通信端口。二、使用ActiveMQ-cpp

HackNebulaZ的博客 276

ActiveMQ-CPP动态库在vc++中的调用

activemq-cpp的源码版本为3.8.3,其他源码版本在资源文本中有说明,由于动态库的使用编译器有关,上传了由vs2008和vs2013编译的动态库,分别有debug和release两个版本,测试工程为vs2013版本。

activeMq-CPP的使用

activeMq-CPP应用程序demo author: 陈训 一、avtiveMq服务端的安装 1、从官网获取软件包: 网址:http://activemq.apache.org/activemq-590-release.html 2、解压运行activeMq wget   http://archive.apache.org/dist/activemq/apache-active

chen 1万+

Mqtt开发笔记:Mqtt服务器搭建

使用到mqtt服务器(中间件)。

长沙红胖子 Qt・西安|省级科研团队从业背景,深耕双一流体系高精尖技术配套研发|剥离高精尖机理,沉淀高端特种行业领域 Qt 工程化落地经验|博文仅分享通用技术总结,输出公开普适工程思路。 6万+

ActiveMQ进行C++C#的通信3 - 编译ActiveMQ-CPP

本文主要介绍了在Windows环境下使用VS2012编译ActiveMQ-CPP的过程,包含了CppUnit、APR等编译过程,并对在编译时可能会遇到的问题进行分析解决。

pigautumn的专栏 1974

ActiveMQActiveMQ-CPP安装及测试

  在介绍ActiveMQ-CP之前,先介绍下CMS(C++ Messaging Service),CMS是C++程序消息中间件进行通信的一种标准接口,可以通过CMS接口类似ActiveMQ这样的消息中间件进行通信,它能够让C++程序消息中间件之间的交互更加优雅和便捷。   ActiceMQ-CPP是CMS的一种实现,是一个能够ActiveMQ进行通信的C++客户端库,Acti...

weixin_30955617的博客 382

eclipse下用ActiveMQCPP开发ActiveMQ应用体验

之前都是使用vi+make方式进行程序开发,可以说是一种传统+质朴的*nix开发方式。有一段时间用eclipse做Java的开发,突然想真正的在eclipse下用一把eclipse cdt结果不料却这样好使,在讨厌了微软.net开发工具之后,又发现了这样一个有效的东东。回想当时还曾用Visual studio开发然后向Linux移植的做法,想来也有些可笑,毕竟还有很多什么字符集,类库兼容性的一堆的

cnhome的专栏 2130

ActiveMQ-CPP编译

ActiveMQ CPP C++

bodybo的专栏 1万+

ActiveMQ-CPP

  http://activemq.apache.org/cms/overview.html 参考:http://www.1to8.com/post/ActiveMQ_cpp.html Using ActiveMQ-CPP:http://activemq.apache.org/cms/using-activemq-cpp.html

董磊的专栏 604

linux activemq-cpp编译

仅作为编译记录http://blog.csdn.net/lgh1700/article/details/51055784http://activemq.apache.org/cms/building.html依赖库versioncppunit-1.14.0.tar.gzapr-1.6.2.tar.gzapr-util-1.6.0.tar.gzapr-iconv-1.2.1.tar.gze2fspro

zim3oo的博客 1180

c++ ActiveMQ

C++中使用ActiveMQ,你可以使用库,这是一个ActiveMQC++客户端实现。下面是一个简单的步骤说明,用于在C++项目中设置和使用。

xie__jin__cheng的博客 594

ActiveMQ-CPP在linux环境下的编译

linux c++ ActiveMQ CPP ActiveMQ-CPP

bodybo的专栏 6569

Linux下安装ActiveMQ-CPP

参考文章。

燃犀的博客 605

Linux 下ActiveMQ-CPP的安装

使用C++连接ActiveMQ总是复杂一些,下面是环境搭建的步骤(至少耗时30分钟(☄⊙ω⊙)☄),以及测试代码。 安装activeMQ 服务端 wget http://mirrors.shu.edu.cn/apache//activemq/5.15.4/apache-activemq-5.15.4-bin.tar.gz tar xvf apache-activemq-5.15.4-b...

qiyu_gfh 598

使用ActiveMQ进行C++C#的通信4 - 使用C++连接ActiveMQ

本文从activemq-cpp的examples中分析生产者/消费者模型代码,分离出适合自己需要的消息发送代码。

pigautumn的专栏 1158
上一篇: 网络io模型
下一篇: c++ new string数组问题
一个人的场域
博客等级 码龄14年 196粉丝 83原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值