stomp.py | Python client library for accessing messaging servers

 by   jasonrbriggs Python Version: 8.1.0 License: Apache-2.0

kandi X-RAY | stomp.py Summary

kandi X-RAY | stomp.py Summary

stomp.py is a Python library typically used in Web Services, RabbitMQ applications. stomp.py has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has high support. You can install using 'pip install stomp.py' or download it from GitHub, PyPI.

"stomp.py" is a Python client library for accessing messaging servers (such as ActiveMQ, Artemis or RabbitMQ) using the STOMP protocol _ (versions 1.0 , 1.1 and 1.2 _). It can also be run as a standalone, command-line client for testing. A basic example of using stomp.py can be found here _. More info can be found on GitHub _.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              stomp.py has a highly active ecosystem.
              It has 432 star(s) with 144 fork(s). There are 38 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 14 open issues and 184 have been closed. On average issues are closed in 200 days. There are no pull requests.
              OutlinedDot
              It has a negative sentiment in the developer community.
              The latest version of stomp.py is 8.1.0

            kandi-Quality Quality

              stomp.py has 0 bugs and 0 code smells.

            kandi-Security Security

              stomp.py has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              stomp.py code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              stomp.py is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              stomp.py releases are not available. You will need to build from source code and install.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              It has 3879 lines of code, 407 functions and 40 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed stomp.py and discovered the below as its top functions. This is intended to give you an instant insight into stomp.py implemented functionality, and help decide if they suit your requirements.
            • Try to establish a connection
            • Check if the current host needs SSL
            • Get the SSL params
            • Enable keepalive
            • Try to connect to the server
            • Return True if the current host needs SSL
            • Get SSL parameters
            • Disconnects the socket
            • Join characters together
            • Sends a message
            • Send a message to destination
            • Nack a message
            • Disconnect a device
            • Begin a transaction
            • Event handler
            • Join chars together
            • Nack an item
            • Unsubscribe from a destination
            • Show stats
            • Receive data from the server
            • Subscribe to a destination
            • Acknowledge a message
            • Establish a connection
            • Send file
            • Send a frame
            • Establish connection
            • Process a frame
            Get all kandi verified functions for this library.

            stomp.py Key Features

            No Key Features are available at this moment for stomp.py.

            stomp.py Examples and Code Snippets

            Extracting data using multiple header tags with stomp
            Pythondot img1Lines of Code : 2dot img1License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            JMSType in ('BOALF','BOD','SEL')
            
            ActiveMQ - STOMP+SSL with Python STOMP client
            Pythondot img2Lines of Code : 52dot img2License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            openssl genrsa -out client.key 4096
            
            openssl req -new -out client.csr -key client.key
            openssl x509 -req -days 365 -in client.csr -signkey client.key -out client.pem
            rm client.csr
            
            keytool -ge
            Subscription with selector does not work from python - stomp.py
            Pythondot img3Lines of Code : 11dot img3License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            headers = {}
            headers['selector'] = "type='test'"
            conn = stomp.Connection12([(args.host, args.port)], auto_content_length=False)
            conn.start()
            conn.connect(login=args.user, passcode=args.password)
            conn.send(body=body, headers=headers, destin
            Django + Activemq and long running connections in the Webserver
            Pythondot img4Lines of Code : 34dot img4License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            POST /api/generate_report
            {
                 "report_id": 1337
            }
            
            GET /api/report?id=1337
            {
                "ready": false
            }
            
            GET /api/report?id=1337
            {
                "ready": true,
                "report": "Lorem ipsum..."
            }
            
            import sto

            Community Discussions

            QUESTION

            Implementing heartbeat in stomp.py
            Asked 2022-Feb-20 at 20:49

            I am seeing behavior in our stomp.py 7.0 client (listener only) where after some idle time of not receiving messages the ActiveMQ 5.15.9 broker seems to drop the client (i.e. looking at the ActiveMQ management console shows zero consumers). The odd thing is the on_disconnected handler of the client never gets called and we have a health check on the client service that checks the connection is_connected(), however it still returns true.

            Based on my understanding/research (please correct if any of this is false) this is due to the broker trying to clean-up resources it perceives as inactive. Also based on my research "heartbeating" can be used to avoid this perception on the broker.

            I know how to send the heartbeat header from the client and how to check the response from the server/broker (as far as what it expects) in on_connected but my question is how do I send the actual heartbeat from the client to the server/broker? Do I need to send a message on the queue I am listening to? If so how do I send a "heartbeat message" and not have to adjust message handling code in my listeners? Do I send it without a body? Also does the broker need to be configured to accept heartbeats? and If it is not configured would declaring and sending them from the client still result in the broker disconnecting the client?

            ...

            ANSWER

            Answered 2022-Feb-18 at 19:54

            Heart-beating is part of STOMP 1.2 so as long as your client supports STOMP 1.2 you should be able to configure heart-beating when the connection is established. Also, if your broker supports STOMP 1.2 it should accept the heart-beat header and adjust its behavior accordingly. You shouldn't have to send your own heart-beats. In the absence of any "normal" STOMP frames the client itself should send an EOL as described in the specification.

            If your client doesn't support STOMP 1.2 then you should upgrade to a client that does. The STOMP 1.2 spec was released in October 2012, almost a decade ago now so there's been plenty of time to implement support.

            Source https://stackoverflow.com/questions/71178856

            QUESTION

            Message count is not zero even after all messages are consumed and acknowledged
            Asked 2021-Aug-14 at 11:05

            We have containerized ActiveMQ Artemis 2.16.0 and deployed it as a K8s deployment for KEDA.

            We use STOMP using stomp.py python module. The ACK-mode is set as client-individual and consumerWindowSize = 0 on the connection. We are promptly acknowledging the message as soon as we read it.

            The problem is, sometimes, the message count in the web console does not become zero even after all the messages are actually consumed and acknowledged. When I browse the queue, I don't see any messages in it. This is causing KEDA to spin up pods unnecessarily. Please refer to the attached screenshots I attached in the JIRA for this issue.

            ...

            ANSWER

            Answered 2021-Aug-14 at 11:05

            I fixed the issue in my application code. My requirement was one queue listener should consume only one message and exit gracefully. So, soon after sending ACK for the consumed message, I disconnected the connection, instead of waiting for the sleep duration to disconnect.

            Thanks, Justin, for spending time on this.

            Source https://stackoverflow.com/questions/68712010

            QUESTION

            ActiveMQ/STOMP Clear Schedule Messages Pointed To Destination
            Asked 2021-Jun-08 at 14:28

            I would like to remove messages that are scheduled to be delivered to a specific queue but i'm finding the process to be unnecessarily burdensome.

            Here I am sending a blank message to a queue with a delay:

            ...

            ANSWER

            Answered 2021-Jun-08 at 04:00

            In order to remove specific messages you need to know the ID which you can get via a browse of the scheduled messages. The only other option available is to use the start and stop time options in the remove operations to remove all messages inside a range.

            Source https://stackoverflow.com/questions/67878771

            QUESTION

            Trouble subscribing to ActiveMQ Artemis with Stomp. Queue already exists
            Asked 2021-May-26 at 03:19

            What am I doing wrong here? I'm trying to use Stomp to test some things with Artemis 2.13.0, but when I uses either the command line utility of a Python script, I can't subscribe to a queue, even after I use the utility to publish a message to an address.

            Also, if I give it a new queue name, it creates it, but then doesn't pull messages I publish to it. This is confusing. My actual Java app behaves nothing like this -- it's using JMS

            I'm connection like this with the utility:

            ...

            ANSWER

            Answered 2021-May-26 at 03:19

            I recommend you try the latest release of ActiveMQ Artemis. Since 2.13.0 was released a year ago a handful of STOMP related issues have been fixed specifically ARTEMIS-2817 which looks like your use-case.

            It's not clear to me why you're using the fully-qualified-queue-name (FQQN) so I'm inclined to think this is not the right approach, but regardless the issue you're hitting should be fixed in later versions. If you want multiple consumers to share the messages on a single subscription then using FQQN would be a good option there.

            Also, if you want to use the topic/ or queue/ prefix to control routing semantics from the broker then you should set the anycastPrefix and multicastPrefix appropriately as described in the documentation.

            This may be coincidence but ARTEMIS-2817 was originally reported by "BENJAMIN Lee WARRICK" which is surprisingly similar to "BenW" (i.e. your name).

            Source https://stackoverflow.com/questions/67680724

            QUESTION

            Python stomp.py connection gets disconnected and listener stops working
            Asked 2021-Jan-25 at 17:08

            I am writing a python script using the python stomp library to connect and subscribe to an ActiveMQ message queue.

            My code is very similar to the examples in the documentation "Dealing with disconnects" with the addition of the timer being placed in a loop for a long running listener.

            The listener class is working to receive and process messages. However after a few minutes, the connection gets disconnected and then the listener stops picking up messages.

            Problem:

            The on_disconnected method is getting called which runs the connect_and_subscribe() method, however it seems the listener stops working after this happens. Perhaps the listener needs to be re-initialized? After the script is run again, the listener is re-created, it starts picking up messages again, but this is not practical to keep running the script again periodically.

            Question 1: How can I set this up to re-connect and re-create the listener automatically?

            Question 2: Is there a better way to initialize a long-running listener rather than the timeout loop?

            ...

            ANSWER

            Answered 2021-Jan-25 at 17:08

            I was able to solve this issue by refactoring the retry attempts loop and the on_error handler. Also, I have installed and configured supervisor in the docker container to run and manage the listener process. That way if the listener program stops it will be automatically restarted by the supervisor process manager.

            Updated python stomp listener script

            init_listener.py

            Source https://stackoverflow.com/questions/65838058

            QUESTION

            Placing stomp.py consumer/producer inside Flask-Gunicorn python application
            Asked 2020-Sep-26 at 03:48

            I have an existing flask application (having a bunch of REST apis) which is hosted by Gunicorn. I also have to send and receive messages from AmazonMQ in the same application. I have functions using stomp.py to send/receive messages from AmazonMQ, but I am not sure where to place them, or how should I use them so as to keep existing flow intact

            ...

            ANSWER

            Answered 2020-Sep-26 at 03:48

            Hey thanks for help @AKX, I resolved the issue by triggering the whole process of messaging (Creation of connection, subscription to channel etc) by a method call from on_starting(server) method in gunicorn_config.py

            Source https://stackoverflow.com/questions/63741450

            QUESTION

            How to specify topic or queue when sending/subscribing to a JMS object, ActiveMQ Artemis and STOMP
            Asked 2020-Mar-11 at 16:29

            I'm using ActiveMQ Artemis messaging system, and I'm testing my setup with STOMP (stomp.py).

            I created an "address" on Artemis called Site.SOF.Order.Fulfillment.Submission.ActiveOmni.Topic, and attached two queues to it:

            • Site.SOF.Order.Fulfillment.Submission.ActiveOmni.queue (multicast)
            • Site.SOF.Order.Fulfillment.Submission.ActiveOmni.log.queue (multicast)

            Here are the exported bindings:

            ...

            ANSWER

            Answered 2020-Mar-11 at 16:25

            Let me provide some background information first...

            The ActiveMQ Artemis address model includes 3 main elements - addresses, queues, and routing types. These are low-level entities which are used to implement all the different semantics for all the different protocols and configurations the broker supports.

            STOMP, by contrast, just supports ambiguous "destinations." The STOMP 1.2 specification says this about destinations:

            A STOMP server is modelled as a set of destinations to which messages can be sent. The STOMP protocol treats destinations as opaque string and their syntax is server implementation specific. Additionally STOMP does not define what the delivery semantics of destinations should be. The delivery, or “message exchange”, semantics of destinations can vary from server to server and even from destination to destination. This allows servers to be creative with the semantics that they can support with STOMP.

            In the core address model messages are sent to addresses and consumed from queues. Addresses and queues are named independently so the names that the core producer and consumer use can be different.

            ActiveMQ Artemis supports both point-to-point and pub/sub semantics for STOMP destinations. You can read more about how to configure these semantics in the latest ActiveMQ Artemis STOMP documentation.

            In the STOMP point-to-point use-case a message is sent to a destination and consumed from that same destination. The name that both the STOMP producer and consumer use are the same. In order to support these semantics the broker uses a core address and a core anycast queue with the same name.

            In the STOMP pub/sub use-case a client creates a subscription on a destination which it can then use to receive messages sent to that destination. The name that both the STOMP subscriber and producer use are the same. In order to support these semantics the broker uses a core address and a core multicast queue with different names. The name of the core queue is generated by the broker automatically. The subscriber can then receive the messages directly from the underlying core subscription queue.

            All this stuff is done behind the scenes for STOMP clients, but it's important to understand how STOMP maps to ActiveMQ Artemis' address model so you can configure things appropriately

            In your case you've configured an address with 2 multicast queues and you're trying to consume from those queues. This use-case is a mix between point-to-point and pub/sub because you have statically defined queues (i.e. not queues auto-created by the broker in response to a subscriber) but the queues are multicast. These queues are like statically configured durable subscriptions. To access the queues directly you need to use their fully-qualified queue name (i.e. FQQN) from your client. The FQQN follows the pattern of

            :: so in your case you'd use either

            Source https://stackoverflow.com/questions/60635567

            QUESTION

            What is stomp.py on_before_message method used for?
            Asked 2020-Mar-10 at 15:38

            I am using the Class - PrintingListener from stomp.py, and it has the method: on_before_message.

            I am not sure why this method is called. I cannot understand the definition. Could someone clarify the use of this method and when it is called?

            ...

            ANSWER

            Answered 2020-Mar-10 at 15:38

            According to the stomp.py documentation, the PrintingListener "just prints all interactions between the client and server." The on_before_message is one of the methods defined by stomp.py therefore the PrintingListener invokes it.

            The stomp.py API documentation says this about on_before_message:

            Called by the STOMP connection before a message is returned to the client app. Returns a tuple containing the headers and body (so that implementing listeners can pre-process the content).

            Parameters:

            • headers (dict) – the message headers
            • body – the message body

            As stated here, on_before_message is invoked "so that implementing listeners can pre-process the content." If you don't need to pre-process the content of the message (i.e. the headers or the body) then you can ignore this method.

            As the name indicates on_before_message is invoked immediately before on_message.

            Source https://stackoverflow.com/questions/60613605

            QUESTION

            When to send ACK or NACK on queue listener in STOMP
            Asked 2020-Feb-12 at 19:48

            The question is when to send the ACK or NACK frames to the broker. The STOMP specification says:

            ACK is used to acknowledge consumption of a message from a subscription using client or client-individual acknowledgment. Any messages received from such a subscription will not be considered to have been consumed until the message has been acknowledged via an ACK.

            "Consumption" would mean for me "after received and processed". So I can imagine two scenarios.

            Scenario A after receiving the message:

            ...

            ANSWER

            Answered 2020-Feb-12 at 09:45

            As you said, 'Consumption' would mean 'after received and processed', you need to acknowledge the message when you have successfully processed your message without any exceptions. So scenario B will be the apt one.

            From the documentation

            NACK is the opposite of ACK. It is used to tell the server that the client did not consume the message.

            So NACK in this context would mean that you have received the message and did not process it successfully.

            Note: If you are maintaining a separate queue for failed messages(ones that cause Exceptions), then you can publish those message to another(dlq queue in your case) and positively acknowledge(ACK) to the original queue for those failed messages.

            Source https://stackoverflow.com/questions/60184723

            QUESTION

            python stomp client - connect to endpoint
            Asked 2020-Jan-13 at 21:02

            I have this stomp client in javascript:

            ...

            ANSWER

            Answered 2020-Jan-13 at 21:02

            Your JavaScript based STOMP client will use websockets to connect to the broker since it is restricted by the web browser environment where it runs. Python STOMP clients don't have this restriction and will simply use a standard TCP connection. I'm not aware of any Python STOMP clients which support websockets. I recommend you configure your STOMP broker to accept both websocket and normal TCP STOMP connections.

            Source https://stackoverflow.com/questions/59723363

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install stomp.py

            You can install using 'pip install stomp.py' or download it from GitHub, PyPI.
            You can use stomp.py like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install stomp.py

          • CLONE
          • HTTPS

            https://github.com/jasonrbriggs/stomp.py.git

          • CLI

            gh repo clone jasonrbriggs/stomp.py

          • sshUrl

            git@github.com:jasonrbriggs/stomp.py.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Python Libraries

            public-apis

            by public-apis

            system-design-primer

            by donnemartin

            Python

            by TheAlgorithms

            Python-100-Days

            by jackfrued

            youtube-dl

            by ytdl-org

            Try Top Libraries by jasonrbriggs

            proton

            by jasonrbriggsJava