Giter Club home page Giter Club logo

Comments (4)

nikipore avatar nikipore commented on June 23, 2024

Please describe your problem more clearly. What does "slow to consumer the msg" mean? Is there any exception being thrown?

The problem might be that you are using a timeout of 0 seconds which might be too little for your queue. Use None, or some large enough value.

from stompest.

wcc526 avatar wcc526 commented on June 23, 2024

what is the stompest consumer's max QPS?

I use the stompest consumer for activemq to consume message.
But sometimes the queue has many message block.
I found the problem is stompest consumer consume the message rate is slow.

 class ActiveMQConsumer(object):
def __init__(self, dest, uri, login, passcode, message_type=None):
    self.dest = dest
    self.config = StompConfig(uri=uri, login=login, passcode=passcode)
    self.message_type = message_type
    self.client = Stomp(self.config)
    self.parser = StompParser('1.0')
    self.client.connect()

    headers = {
        StompSpec.ACK_HEADER: StompSpec.ACK_CLIENT_INDIVIDUAL,
        'activemq.prefetchSize': '1000',
    }
    if message_type == 'MapMessage':
        headers['transformation'] = 'jms-map-json'
    self.client.subscribe(self.dest, headers)

def __map_json_to_dict(self, body):
    ret_dict = {}
    body_dict = json.loads(body)
    for entry in body_dict['map']['entry']:
        key = entry['string'][0]
        value = entry['string'][1]
        ret_dict[key] = value
    return ret_dict

def recv(self):
    if self.client.canRead(0):
        self.frame = self.client.receiveFrame()
        self.client.ack(self.frame)
        if self.message_type == 'MapMessage':
            body = self.__map_json_to_dict(self.frame.body)
        else:
            body = json.loads(self.frame.body)
        return body
    else:
        return None

def ack(self):
    self.client.ack(self.frame)

def __del__(self):
    self.client.disconnect()

I use mutl-thread function to consume the message

mq_consumer = ActiveMQConsumer(dest=config.get('activemq', 'document_audit_consumer_dest'),
                               uri=config.get('activemq', 'document_audit_uri'),
                               login=config.get('activemq', 'document_audit_login'),
                               passcode=config.get('activemq', 'document_audit_passcode'),
                               message_type='MapMessage')
while True:
    try:
        msg = mq_consumer.recv()
        if msg:
            # LOG.debug(msg)
            msg_queue.put(msg)
    except Exception, e:
        LOG.error(e, exc_info=True)

from stompest.

nikipore avatar nikipore commented on June 23, 2024

Please boil your problem down. Which queue is blocking? The ActiveMQ queue or your local msg_queue? The sync client can consume a lot of messages per second, definitely more than one. Please run the sync example to convince yourself.

from stompest.

wcc526 avatar wcc526 commented on June 23, 2024

Please close this problem.
I restart the activemq, and the consumer qps is ok now.
Maybe is the problem is activemq.

from stompest.

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.