Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get response for send() in stomp.py to retry in case of failure #407

Open
umesh191994 opened this issue Oct 26, 2022 · 0 comments
Open

Get response for send() in stomp.py to retry in case of failure #407

umesh191994 opened this issue Oct 26, 2022 · 0 comments

Comments

@umesh191994
Copy link

umesh191994 commented Oct 26, 2022

Below is my listener class with the subscriber

import os
import time
import stomp

def connect_and_subscribe(conn):
    conn.connect('guest', 'guest', wait=True)
    conn.subscribe(destination='/queue/test', id=1, ack='auto')

class MyListener(stomp.ConnectionListener):
    def __init__(self, conn):
        self.conn = conn

    def on_error(self, frame):
        print('received an error "%s"' % frame.body)

    def on_message(self, frame):
        print('received a message "%s"' % frame.body)
        for x in range(10):
            print(x)
            time.sleep(1)
        print('processed message')

    def on_disconnected(self):
        print('disconnected')
        connect_and_subscribe(self.conn)

conn = stomp.Connection([('localhost', 62613)], heartbeats=(4000, 4000))
conn.set_listener('', MyListener(conn))
connect_and_subscribe(conn)
time.sleep(60)
conn.disconnect()

Below is my producer code

import stomp
conn = stomp.Connection([('localhost', 62613)])
conn.connect('guest', 'guest', wait=True)
result = conn.send('/queue/test', 'test message')

I need to get the result/status of sent data, in order use that status to retry in case of failover

I know this details can be received in on_send listener

on_send SEND {'content-length': 5, 'destination': '/queue/test'} b'a test message'

But for this I need to create a class inheriting ConnectionListener, and add method on_send Listener to get the response.

Is it possible to get the response without creating any class?

Thanks again!

@jasonrbriggs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant