Artemis and stomp.py using client acknowledgment not behaving as expected

I can’t get the ack=’client’ to behave as expected. I think that a message consumed by the code below should nack it and send it to the DLQ. But no! The message just disappears. I guess that it is considered processed.If, on the other hand, I just throw an error, it does end up in the DLQ.

I want to ack it if all is well, and nack it if it does not work as expected.

Producer.py

import stomp

# STOMP server configuration
server = 'localhost'
port = 61613
username = 'artemis'
password = 'artemis'
destination = 'your.queue.name'
message = 'hello :-)'

# Create a connection to the STOMP server
conn = stomp.Connection([(server, port)])
conn.set_listener('', stomp.PrintingListener())

# Connect to the server
conn.connect(username, password, wait=True)

# Send a durable message to the specified destination
conn.send(destination=destination, body=message, headers={'persistent': 'true'})

# Disconnect from the server
conn.disconnect()

Consumer.py

import stomp
import time

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

    def on_error(self, frame):
        print('Received an error:')
        print(f'Headers: {frame.headers}')
        print(f'Body: {frame.body}')

    def on_message(self, frame):
        print('Received a message:')
        print(f'Headers: {frame.headers}')
        print(f'Body: {frame.body}')
        
        time.sleep(1)
        
        #self.conn.ack(frame.headers['message-id'], frame.headers['subscription'])
        
        # This line ha no effect 4 what I can tell.
        self.conn.nack(frame.headers['message-id'], frame.headers['subscription'])
        
        #error will send it DLQ!
        #raise Exception("I will send this message to DLQ!")
        print('Done!!!')

def main():
    server = 'localhost'
    port = 61613
    username = 'artemis'
    password = 'artemis'
    destination = 'your.queue.name'

    conn = stomp.Connection([(server, port)], heartbeats=(4000, 4000))
    conn.set_listener('', MyListener(conn))

    try:
        conn.connect(username, password, wait=True)
    except Exception as e:
        print(f'Failed to connect to STOMP server: {e}')
        return

    try:
        # Ack modes:
        # stuff I tried:
        # client-individual
        # https://jasonrbriggs.github.io/stomp.py/api.html
        # client
        # https://activemq.apache.org/components/artemis/documentation/1.4.0/pre-acknowledge.html
        # CLIENT_ACKNOWLEDGE

        conn.subscribe(destination=destination, id='1', ack='client', headers={'subscription-type': 'ANYCAST'})
    except Exception as e:
        print(f'Failed to subscribe to queue: {e}')
        conn.disconnect()
        return

    print('Waiting for messages...')
    
    # Keep the main thread alive to receive messages
    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        print('Disconnecting...')
        conn.disconnect()
    except Exception as e:
        print(f'An unexpected error occurred: {e}')
        conn.disconnect()

if __name__ == '__main__':
    main()

broker.xml


<addresses>
    <address name="your.queue.name">
        <anycast>
            <queue name="your.queue.name" />
        </anycast>
        <dead-letter-address>DLQ.your.queue.name</dead-letter-address>
        <expiry-address>ExpiryQueue</expiry-address>
        <redelivery-delay>5000</redelivery-delay> <!-- 5 seconds delay before redelivery -->
        <max-delivery-attempts>1</max-delivery-attempts> <!-- Max attempts before moving to DLQ -->
        <redelivery-delay-multiplier>2.0</redelivery-delay-multiplier> <!-- Exponential backoff -->
        <max-redelivery-delay>60000</max-redelivery-delay> <!-- Max delay of 1 minute -->
    </address>
    
    <address name="DLQ.your.queue.name">
        <anycast>
            <queue name="DLQ.your.queue.name" />
        </anycast>
    </address>
</addresses>

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật