Coder Social home page Coder Social logo

Comments (6)

xinghailong avatar xinghailong commented on July 17, 2024

http://pythonhosted.org//stompy/reference/stompy.stomp.html

from stomp.py.

jasonrbriggs avatar jasonrbriggs commented on July 17, 2024

Sorry, no idea what you mean by a "long connection".

In addition, you've got the wrong project. stompy (the page you reference above) is nothing to do with stomp.py.

Think you should probably be directing your question to the owner of that project: https://bitbucket.org/benjaminws/python-stomp/

from stomp.py.

xinghailong avatar xinghailong commented on July 17, 2024

Hi, stompy can use "clientid" to connect old connection, but I can not find the relevant parameter of stom.py. So I want to know how can I find that ?

from stomp.py.

xinghailong avatar xinghailong commented on July 17, 2024

I want to use the persistent connection to send message, I do not want the "start" "connect" "disconnect" appear frequently.

from stomp.py.

jasonrbriggs avatar jasonrbriggs commented on July 17, 2024

I believe clientid is something activemq specific. It's not a stomp header. So there is no relevant parameter. I you check the API documentation (http://jasonrbriggs.github.io/stomp.py/classstomp_1_1protocol_1_1_protocol12.html) you'll see that you can send arbitrary headers using the headers parameter.

As for persistent connections, the connection will stay open as long as the server allows.

from stomp.py.

xinghailong avatar xinghailong commented on July 17, 2024
class MyListener(object):
    def __init__(self,conn):
        self.conn = conn

    def on_message(self, headers, message):
        # some data processing for message
        send_msg = json.dumps(send_msg)

        # send to next queue
        dest = '/queue/smtp'
        ef.sendMessage(send_msg,dest,self.conn)


def branch(i,stomp_host):
    if stomp_host != None:
        #get message from JMS
        conn = stomp.Connection([(stomp_host[0],stomp_host[1])],user=stomp_host[2],passcode=stomp_host[3])
        conn.set_listener('', MyListener(conn))
        conn.start()
        conn.connect(wait=True)
        conn.subscribe(headers={'destination':'/queue/edm','activemq.prefetchSize':1, 'ack':'auto'})
        time.sleep(1)
        #conn.disconnect()
        while True:
            try:  
                time.sleep(1)  
            except:  
                break
    else:
        ef.edmLogs('stomp_host error branch','sysLog.log')

def sendMessage(send_msg,dest,conn=False):
    if conn:
        conn.send(send_msg, destination=dest)
    else:
        stomp_host = MQSelect()
        if stomp_host == None :
            edmLogs('error about mq ','runlog.log',True,False)
        else :
            conn = stomp.Connection([(stomp_host[0], stomp_host[1])],user=stomp_host[2],passcode=stomp_host[3])
            conn.start()
            conn.connect(wait=True)
            conn.send(send_msg, destination=dest)
            conn.disconnect() 

Use “conn” to send message,but sometimes it do not work. Can you give me some suggestions?

测试环境没问题,正式环境不行,还真是头疼!

from stomp.py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.