- 浏览: 2542950 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
Using ApacheMQ with Perl Client
1. install apacheMQ
download the file : apache-activemq-5.5.0-bin.tar.gz
unzip the file
>tar zxvf apache-activemq-5.5.0-bin.tar.gz
>mv apache-activemq-5.5.0/ /opt/activemq/
link the file
>sudo ln -sf /opt/activemq/bin/activemq /etc/init.d/
tell ubuntu to start ActiveMQ on boot:
>sudo update-rc.d activemq defaults
Defaults and Local Configuration
>sudo /etc/init.d/activemq setup /etc/default/activemq
modify the configuration file
>vi /etc/default/activemq
ACTIVEMQ_USER=""
uncomment the lines:
ACTIVEMQ_SUNJMX_START="-Dcom.sun.management.jmxremote.port=11099 "
ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.password.file=${ACTIVEMQ_CONFIG_DIR}/jmx.password"
ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.access.file=${ACTIVEMQ_CONFIG_DIR}/jmx.access"
ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.ssl=false"
ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote"
ACTIVEMQ_SUNJMX_CONTROL="--jmxurl service:jmx:rmi:///jndi/rmi://127.0.0.1:11099/jmxrmi --jmxuser controlRole --jmxpassword abcd1234"
#ACTIVEMQ_SUNJMX_CONTROL=""
error message:
Error: Password file read access must be restricted: /opt/activemq/conf/jmx.password
add my user name to the files
>vi /opt/activemq/conf/jmx.password
>vi /opt/activemq/conf/jmx.access
>sudo chmod 600 /opt/activemq/conf/jmx.access
>sudo chmod 600 /opt/activemq/conf/jmx.password
test if it is work
>netstat -an|grep 61616
access the web console
http://localhost:8161/admin/
I need to start the stomp mode.
>/etc/init.d/activemq stop
>cd /opt/activemq
>bin/activemq console xbean:conf/activemq-stomp.xml
2. Install Perl client API
>cpan
cpan>install Net::Stomp
Net::Stomp is a streaming Text Orientated Messaging Protocol Client
Add a sample queue 'foo' to our activemq.
Below is the example that how to send the message via perl client:
# send a message to the queue 'foo'
use Net::Stomp;
my $stomp = Net::Stomp->new( { hostname => 'localhost', port => '61613' } );
$stomp->connect(
#{ login => 'hello', passcode => 'there' }
);
$stomp->send(
{ destination => '/queue/foo', body => '<userId>sillycat</userId><message>test message</message>' } );
$stomp->disconnect;
Get the message from the queue:
# subscribe to messages from the queue 'foo'
use Net::Stomp;
my $stomp = Net::Stomp->new( { hostname => 'localhost', port => '61613' } );
$stomp->connect(
#{ login => 'hello', passcode => 'there' }
);
$stomp->subscribe(
{ destination => '/queue/foo',
'ack' => 'client',
'activemq.prefetchSize' => 1
}
);
while (1) {
my $frame = $stomp->receive_frame;
#warn $frame->body; # do something here
$message = $frame->body;
if($message){
print $message;
$stomp->ack( { frame => $frame } );
last;
}
}
$stomp->disconnect;
other methods:
# write your own frame
#my $frame = Net::Stomp::Frame->new(
# { command => $command, headers => $conf, body => $body } );
#$self->send_frame($frame);
# connect with failover supporting similar URI to ActiveMQ
#$stomp = Net::Stomp->new({ failover => "failover://tcp://primary:61616" });
# "?randomize=..." and other parameters are ignored currently
#$stomp = Net::Stomp->new({ failover => "failover:(tcp://primary:61616,tcp://secondary:61616)?randomize=false" });
# Or in a more natural perl way
#$stomp = Net::Stomp->new({ hosts => [
# { hostname => 'primary', port => 61616 },
# { hostname => 'secondary', port => 61616 },
#] });
references:
http://activemq.apache.org/
http://activemq.apache.org/getting-started.html
http://hi.baidu.com/luohuazju/blog/item/9902c74e2619f40fb3de05fa.html
http://www.jmkg.co.uk/2010/08/31/installing-activemq-on-ubuntu/
http://servicebus.blogspot.com/2011/02/installing-apache-active-mq-on-ubuntu.html
http://stomp.codehaus.org/Perl%20Client
http://search.cpan.org/dist/Net-Stomp/lib/Net/Stomp.pm
http://activemq.apache.org/stomp.html
1. install apacheMQ
download the file : apache-activemq-5.5.0-bin.tar.gz
unzip the file
>tar zxvf apache-activemq-5.5.0-bin.tar.gz
>mv apache-activemq-5.5.0/ /opt/activemq/
link the file
>sudo ln -sf /opt/activemq/bin/activemq /etc/init.d/
tell ubuntu to start ActiveMQ on boot:
>sudo update-rc.d activemq defaults
Defaults and Local Configuration
>sudo /etc/init.d/activemq setup /etc/default/activemq
modify the configuration file
>vi /etc/default/activemq
ACTIVEMQ_USER=""
uncomment the lines:
ACTIVEMQ_SUNJMX_START="-Dcom.sun.management.jmxremote.port=11099 "
ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.password.file=${ACTIVEMQ_CONFIG_DIR}/jmx.password"
ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.access.file=${ACTIVEMQ_CONFIG_DIR}/jmx.access"
ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.ssl=false"
ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote"
ACTIVEMQ_SUNJMX_CONTROL="--jmxurl service:jmx:rmi:///jndi/rmi://127.0.0.1:11099/jmxrmi --jmxuser controlRole --jmxpassword abcd1234"
#ACTIVEMQ_SUNJMX_CONTROL=""
error message:
Error: Password file read access must be restricted: /opt/activemq/conf/jmx.password
add my user name to the files
>vi /opt/activemq/conf/jmx.password
>vi /opt/activemq/conf/jmx.access
>sudo chmod 600 /opt/activemq/conf/jmx.access
>sudo chmod 600 /opt/activemq/conf/jmx.password
test if it is work
>netstat -an|grep 61616
access the web console
http://localhost:8161/admin/
I need to start the stomp mode.
>/etc/init.d/activemq stop
>cd /opt/activemq
>bin/activemq console xbean:conf/activemq-stomp.xml
2. Install Perl client API
>cpan
cpan>install Net::Stomp
Net::Stomp is a streaming Text Orientated Messaging Protocol Client
Add a sample queue 'foo' to our activemq.
Below is the example that how to send the message via perl client:
# send a message to the queue 'foo'
use Net::Stomp;
my $stomp = Net::Stomp->new( { hostname => 'localhost', port => '61613' } );
$stomp->connect(
#{ login => 'hello', passcode => 'there' }
);
$stomp->send(
{ destination => '/queue/foo', body => '<userId>sillycat</userId><message>test message</message>' } );
$stomp->disconnect;
Get the message from the queue:
# subscribe to messages from the queue 'foo'
use Net::Stomp;
my $stomp = Net::Stomp->new( { hostname => 'localhost', port => '61613' } );
$stomp->connect(
#{ login => 'hello', passcode => 'there' }
);
$stomp->subscribe(
{ destination => '/queue/foo',
'ack' => 'client',
'activemq.prefetchSize' => 1
}
);
while (1) {
my $frame = $stomp->receive_frame;
#warn $frame->body; # do something here
$message = $frame->body;
if($message){
print $message;
$stomp->ack( { frame => $frame } );
last;
}
}
$stomp->disconnect;
other methods:
# write your own frame
#my $frame = Net::Stomp::Frame->new(
# { command => $command, headers => $conf, body => $body } );
#$self->send_frame($frame);
# connect with failover supporting similar URI to ActiveMQ
#$stomp = Net::Stomp->new({ failover => "failover://tcp://primary:61616" });
# "?randomize=..." and other parameters are ignored currently
#$stomp = Net::Stomp->new({ failover => "failover:(tcp://primary:61616,tcp://secondary:61616)?randomize=false" });
# Or in a more natural perl way
#$stomp = Net::Stomp->new({ hosts => [
# { hostname => 'primary', port => 61616 },
# { hostname => 'secondary', port => 61616 },
#] });
references:
http://activemq.apache.org/
http://activemq.apache.org/getting-started.html
http://hi.baidu.com/luohuazju/blog/item/9902c74e2619f40fb3de05fa.html
http://www.jmkg.co.uk/2010/08/31/installing-activemq-on-ubuntu/
http://servicebus.blogspot.com/2011/02/installing-apache-active-mq-on-ubuntu.html
http://stomp.codehaus.org/Perl%20Client
http://search.cpan.org/dist/Net-Stomp/lib/Net/Stomp.pm
http://activemq.apache.org/stomp.html
发表评论
-
NodeJS12 and Zlib
2020-04-01 07:44 468NodeJS12 and Zlib It works as ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 330Traefik 2020(1)Introduction and ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 428Private Registry 2020(1)No auth ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 377Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 468NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 414Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 332Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 243GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 445GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 321GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 307Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 310Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 286Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 303Serverless with NodeJS and Tenc ... -
NodeJS MySQL Library and npmjs
2020-02-07 06:21 282NodeJS MySQL Library and npmjs ... -
Python Library 2019(1)requests and aiohttp
2019-12-18 01:12 257Python Library 2019(1)requests ... -
NodeJS Installation 2019
2019-10-20 02:57 565NodeJS Installation 2019 Insta ... -
Monitor Tool 2019(2)Monit on Multiple Instances and Email Alerts
2019-10-18 10:57 257Monitor Tool 2019(2)Monit on Mu ... -
Sqlite Database 2019(1)Sqlite3 Installation and Docker phpsqliteadmin
2019-09-05 11:24 362Sqlite Database 2019(1)Sqlite3 ... -
Supervisor 2019(2)Ubuntu and Multiple Services
2019-08-19 10:53 366Supervisor 2019(2)Ubuntu and Mu ...
相关推荐
### 使用Expect与Perl进行自动化交互任务 #### 一、什么是Expect? Expect是一种基于TCL工具包的编程语言,专门设计用于自动化交互式任务。它的核心功能在于能够等待某个事件发生,并在该事件发生后执行相应的操作...
to write simple programs using Perl. This programming language is explicitly designed to work with text. In addition, it is open-source software that is available over the Web for free. That is, you ...
Using Swift With Cocoa and Objective-C中文版,OC和Swift混合使用
《使用Tcl与Synopsys工具》是一份深入探讨如何结合Tcl脚本语言与Synopsys设计工具的官方文档。这份文档详细介绍了Tcl的基础语法,并特别关注了其在Design Compiler (DC)中的实际应用。Tcl是一种强大的文本处理语言,...
Using Swift with Cocoa and Objective-C (Swift 4) EN.epub 去除 DRM
Web Client Programming with Perl is a behind-the-scenes look at how your web browser interacts with web servers. Readers of this book will learn how the Web works and how to write software that is ...
Using SVG with CSS3 and HTML5 Vector Graphics for Web Design 英文azw3 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
Using Red Hat Client with NetApp Storage over nfs.pdf
《Visual Studio Tools for Office Using C# with Excel, Word, Outlook and InfoPath》是一本非常全面且实用的指南,它不仅深入浅出地介绍了 VSTO 的各个方面,而且还提供了大量的实例和代码片段,对于想要使用 C# ...
Using Client Pull with Perl G Using Server Push with Perl G From Here G Chapter 7 Dynamic and Interactive HTML Content in Perl and CGI Creating User-Specific Pages Allowing the User to Shop for ...
Yong Li , Student Member, IEEE, Jiabei Zeng , Member, IEEE, Shiguang Shan , Member, IEEE, and Xilin Chen, Fellow, IEEE
Using Scalable Vector Graphics (SVG) for illustrations only scratches the surface of this format’s potential on the web. With this practical guide, you’ll learn how to use SVG not only for ...
Using Swift with Cocoa and Objective-C (Swift 4),equb格式,非pdf格式,导入ibooks中观看,解决中国区用户无法下载文档的问题
Using Kivy and NumPy, you will create cross-platform data science applications with low overheads. This book will help you apply deep learning and computer vision concepts from scratch, step-by-step ...
Perl is supplied as standard with most Linux revisions, and even some commer- cial Unix installations include Perl as a standard option. In fact, I have access to a wider range and more easily ...
"using_perl_for_web_prog"这个主题表明我们将探讨如何使用Perl进行Web编程。在这个压缩包中,包含了一个Readme.txt文件和一个名为"using_perl_for_web_prog"的文件或目录,这可能是一个教程、代码示例或相关资源的...
It begins with a fast-paced but thorough tutorial on building web content with the Template Toolkit, and then walks you through generating and using data files, particularly with XML. It also ...
中文名: Apache, MySQL, memcached和Perl开发Web应用程序 ...Chapter 14: Using mod_perl Handlers Chapter 15: More mod_perl Chapter 16: Perl and Ajax Chapter 17: Search Engine Application