Python active download installation test

Source: Internet
Author: User

Software Version:

Apache-activemq-5.7.0-bin.tar.gz

Stomp.py-3.1.1.tar.gz

:

Http://activemq.apache.org/download.html

Http://code.google.com/p/stomppy/downloads/list

Activemq installation:

Tar-zxvf apache-activemq-5.7.0-bin.tar.gz

Music apache-activemq-5.7.0/usr/local/activemq/

Configuration change:

Vi/usr/local/activemq/conf/activemq. xml

Chmod-r 777/usr/local/activemq/

Add a sentence

<transportConnectors>            <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->            <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireformat.maxFrameSize=104857600"/>            <transportConnector name="stomp+nio" uri="stomp+nio://0.0.0.0:61613"/></transportConnectors>

Start the service:

/Usr/local/activemq/bin/activemq start

Check:

[Root @ localhost pythontest] # netstat-an | grep 61616
Tcp 0 0: 61616: * LISTEN
[Root @ localhost pythontest] # netstat-an | grep 61613
Tcp 0 0: 61613: * LISTEN

Http: // 192.168.10.62: 8161/admin

Stomp installation:

Tar-zxvf stomp.py-3.1.1.tar.gz

Cd stomp. py-3.1.1

Python setup. py install -- prefix =/usr/local/python27 (python installation directory)

Complete.

Python demo

From: http://blog.csdn.net/xiarendeniao/article/details/7053958#comments

#!/usr/bin/python## Usage: stomp_send.py <msize> <nmsgs>#import sysimport osimport loggingimport stompimport timeimport jsonlogging.basicConfig()nmsgs = int(sys.argv[1])msg = {'pid':1,'id':1,'start_at':"time",'type':'parse_title','articleid':0, 'from':1, 'to':361}dest = '/queue/worker'start = time.time()conn = stomp.Connection([('172.16.1.217', 61612)])conn.start()conn.connect(wait=True)for i in range(nmsgs):msg['articleid'] = iconn.send(json.write(msg), destination=dest)print "send one"conn.disconnect()print "OK Finished msgs %d time %f" % (nmsgs, (time.time()-start))

Mq_rective.py

import sysimport osimport loggingimport stompimport jsonimport timeclass MyListener(object):def on_error(self, headers, message):print 'received an error %s' % messagedef on_message(self, headers, message):print 'received a message %s' % message#print headers['message-id']#sys.exit(0)conn.ack({'message-id':headers['message-id']})dest = '/queue/test1'logging.basicConfig()conn = stomp.Connection([('172.16.1.217', 61612)])conn.set_listener('', MyListener())conn.start()conn.connect(wait=True)conn.subscribe(destination=dest, ack='client')while True:try:time.sleep(1)except:break

Run:

[Root @ localhost pythontest] # python mq_send.py 4
Send one
Send one
Send one
Send one
OK Finished msgs 4 time 0.015546
[Root @ localhost pythontest] #

[Root @ localhost pythontest] # python mq_receive.py
Received a message {"start_at": "time", "pid": 1, "to": 361, "articleid": 0, "from": 1, "type ": "parse_title", "id": 1}
Received a message {"start_at": "time", "pid": 1, "to": 361, "articleid": 1, "from": 1, "type ": "parse_title", "id": 1}
Received a message {"start_at": "time", "pid": 1, "to": 361, "articleid": 2, "from": 1, "type ": "parse_title", "id": 1}
Received a message {"start_at": "time", "pid": 1, "to": 361, "articleid": 3, "from": 1, "type ": "parse_title", "id": 1}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.