Project website : http://code.google.com/p/httpsqs/
Working with documents : http://blog.s135.com/httpsqs/
Note: Because there are a lot of things to install, the original text may be written in some brief, so properly supplemented
1. Installing libevent-2.0.12-stable.tar.gz
wget http://httpsqs.googlecode.com/files/libevent-2.0.12-stable.tar.gz
Tar zxvf libevent-2.0.12-stable.tar.gz
CD libevent-2.0.12-stable/
./configure--prefix=/usr/local/libevent-2.0.12-stable/
Make
Make install
Cd.. /
2. Installing tokyocabinet-1.4.47.tar.gz
wget http://httpsqs.googlecode.com/files/tokyocabinet-1.4.47.tar.gz
Tar zxvf tokyocabinet-1.4.47.tar.gz
CD tokyocabinet-1.4.47/
./configure--prefix=/usr/local/tokyocabinet-1.4.47/
#注: To compile the Tokyo cabinet on a 32-bit Linux operating system, use the./configure--enable-off64 instead./configure, which
To make the database file exceed the 2GB limit.
#./configure--enable-off64--prefix=/usr/local/tokyocabinet-1.4.47/
Make
Make install
Cd.. /
When performing the second step, the error is due to the lack of bzip2-1.0.6.tar.gz
Install below
HTTP://WWW.BZIP.ORG/1.0.6/BZIP2-1.0.6.TAR.GZ installation begins;
wget http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
Tar-xvzf bzip2-1.0.6.tar.gz
CD bzip2-1.0.6.
Make
Make install
Repeated installation of tokyocabinet-1.4.47.tar.gz or failed due to a lack of zlib-1.2.5.tar.gz
Install below
HTTP://WWW.WINIMAGE.COM/ZLIBDLL/ZLIB-1.2.5.TAR.GZ installation begins;
wget http://www.winimage.com/zLibDll/zlib-1.2.5.tar.gz
Tar-xvzf zlib-1.2.5.tar.gz
CD zlib-1.2.5.
./configure
Make
sudo make instal
Proceed to 2nd step OK
3. Installing httpsqs-1.7.tar.gz
wget http://httpsqs.googlecode.com/files/httpsqs-1.7.tar.gz
Tar zxvf httpsqs-1.7.tar.gz
CD httpsqs-1.7/
Make
Make install
Cd.. /
4. Testing
If the installation succeeds, Httpsqs–h will appear
------------------------------------------------------------------------------------------------
--
HTTP Simple Queue Service-httpsqs v1.7 (April 14, 2011)
Author:zhang Yan (http://blog.s135.com), e-mail: [email protected]
This was free software, and you are welcome to modify and redistribute it under the New BSD
License
-L <ip_addr> interface to listen in, default is 0.0.0.0
-P <num> TCP port number to listen on (default:1218)
-X <path> Database Directory (example:/opt/httpsqs/data)
-T <second> keep-alive timeout for an HTTP request (DEFAULT:60)
-S <second> the interval to sync updated contents to the disk (Default:5)
-C <num> The maximum number of NON-LEAF nodes to be cached (default:1024)
-M <size> database memory cache size in MB (default:100)
-I <file> save PID in <file> (default:/tmp/httpsqs.pid)
-A <auth> the auth password to access Httpsqs (example:mypass123)
-D Run as a daemon
-H Print this help and exit
5. Settings
Storage Directory
#mkdir/usr/local/httpsqs_queue
MKDIR/HOME/BF
vi/home/bf/ Httpsqs . SH
The contents are as follows:
#!/bin/sh
Ulimit-shn 65535
Start method
with password
#/usr/bin/httpsqs-d-P 1218-t 10-c 10000-m 512-x/usr/local/httpsqs_queue-a pwd123
No password
#/usr/bin/httpsqs-d-P 1218-t 10-c 10000-m 512-x/usr/local/httpsqs_queue
The method of killing
# Killall Httpsqs
Note You need to open the firewall port
Vim/etc/sysconfig/iptables
Add the following line to open firewall 1218 port:
-A input-m State--state new-m tcp-p TCP--dport 1218-j ACCEPT
Restarting the firewall
#/etc/init.d/iptables Restart
6. Use
Write queue
http://192.168.2.103:1218/?name=your_queue_name&opt=put&data=TEXT&auth=pwd123
Read queue
http://192.168.2.103:1218/?charset=utf-8&name=your_queue_name&opt=get&auth=pwd123
Write queue no password
Http://192.168.2.103:1218/?name=your_queue_name&opt=put&data=TEXT
Read Queue no password
Http://192.168.2.103:1218/?charset=utf-8&name=your_queue_name&opt=get
Write queue
http://192.168.2.103:1218/?name=your_queue_name&opt=put&data=TEXT&auth=pwd123
Read queue
http://192.168.2.103:1218/?charset=utf-8&name=your_queue_name&opt=get&auth=pwd123
7.php Expansion
Reference: http://code.google.com/p/php-httpsqs-client/
Installation Instructions
If
Occurs when running/usr/local/webserver/php/bin/phpize: Configuring for:php API Version:20041225zend Module API no:2006061 3Zend Extension Api no:220060519cannot find autoconf. Please check your autoconf installation and THE$PHP_AUTOCONF environment variable. Then, the rerun this script. According to the online solution is: Yum install M4yum install autoconf
#./configure--enable-httpsqs--with-php-config=/usr/local/php/bin/php-config # make && make install
Add a row #接着在php the. Ini extension = Httpsqs . So ;
Function description
/** * Create HTTPSQS Connection * @param string $host server address, can be empty, default to 127.0.0.1 * @param int $port server port, can be empty, default is 1218 * @return Res Ource */= httpsqs_connect("127.0.0.1", 1218);
/** * Write queue data * @param resource $hr Server connection handle * @param string $queue queue name * @param string $data Write Data ; * @param string $charset character set, can be empty, default is utf-8 * @return boolean */ $ Putres = httpsqs_put ( $hr , "Testqueue" , "This is a test Data" , "UTF-8" );
/** * get queue last data * @param resource $hr * @param String $queue * @param boolean $return _array returns an array, nullable, false & nbsp Return array format: Array (' pos ' + = ' queue insertion point ', ' data ' = ' value ') * @param string $charset can be empty * @return mixed */ $content = httpsqs_get ( $hr , "Testqueue" , True , "UTF-8" );
/** * Get queue status * @param resource $hr * @param string $queue * @param boolean $return _json returns the JSON format of the status, can be empty, default to false * @return string& nbsp; */ $status = httpsqs_status ( $hr , "Testqueue" , true );
/** * Gets the queue some point data * @param resource $HR * @param string $queue * @param int $pos The position of the data to get * @param string $ CharSet can be empty * @return string*/= httpsqs_view($hr, " testqueue",ten,"UTF-8");
/** * Queue Reset * @param resource $hr * @param string $queue * @return Boolean*= http Sqs_reset($hr,"Testqueue");
/** * Set Queue maximum number of data bars * @param resource $hr * @param string $queue * @param int $maxqueue Queue maximum number of data bars * @return Boolea n */= httpsqs_maxqueue($hr,"Testqueue" ,10000);
/** * Modify the time interval when flushing memory buffer contents to disk * @param resource $hr * @param string $queue * @param int $synctime time interval * @return Boolean *= httpsqs_synctime($hr, "Testqueue",ten);
Object invocation
//parameter corresponds to Httpsqs_connect$hr= New Httpsqs($host,$port); //parameter corresponds to Httpsqs_get$hr -Get($queuename,$return _array,$charset); //parameter corresponds to Httpsqs_put$hr -put($queuename,$data,$charset); //parameter corresponds to Httpsqs_status$hr -Status($queuename,$return _json); //parameter corresponds to Httpsqs_view$hr -View($queuename,$pos); //parameter corresponds to Httpsqs_reset$hr -Reset($queuename); //parameter corresponds to Httpsqs_maxqueue$hr -Maxqueue($queuename); //parameter corresponds to Httpsqs_synctime$hr -Synctime($queuename);
Example
//Fetch data daemon$hr=Httpsqs_connect($host,$port); while (1) {$data=Httpsqs_get($hr,$queuename,$charset); if ($data=== false) {Sleep(1); } Else { //do something ... } } //or$hr= New Httpsqs($host,$port); while (1) {$data=$hr -Get($queuename,$charset); if ($data=== false) {Sleep(1); } Else { //do something ... } } //Write Data$hr=Httpsqs_connect($hort,$port);Httpsqs_put($hr,$queuename,$data,$charset); //or$hr= New Httpsqs($hort,$port);$hr -put($queuename,$data,$charset);
Write
<?php
$HR = Httpsqs_connect ("127.0.0.1", 1218);
$putRes = Httpsqs_put ($hr, "Testqueue", "Text", "UTF-8");
?>
Read
<?php
$HR = Httpsqs_connect ("127.0.0.1", 1218);
$content = Httpsqs_get ($hr, "Testqueue", True, "UTF-8");
Print_r ($content);
echo $content [' data '];
?>
PHP Message Queuing HTTPSQS installation and use