微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何确认两个AutoProxy [Queue]指向同一队列?

如何解决如何确认两个AutoProxy [Queue]指向同一队列?

在消息总线的开发环境中,我想让自己陷入困境(!),因为我试图确保给定的队列(或其代理)没有为同一队列注册两次。消息类型。

在调试测试时,在试图避免重复注册函数中,我观察到了

print(registration)  # gives:
RegisterHandlerQueue(messageType=<class 'TestMessage'>,handlerQueue=<Autoproxy[Queue] object,typeid 'Queue' at 0x21da2b12490>
                     )
# great,as expected

print(handlersQueues[registration.messageType])  # gives:
[<Autoproxy[Queue] object,typeid 'Queue' at 0x21da2b12670>]
# somewhat confusing (different memory address from above) 
# but probably ok.
# the storage structure has the form: {messageType:[queue1,queue2,...]}

print(registration.handlerQueue)  # gives:
<queue.Queue object at 0x00000214A15B28E0>
# very problematic: I cannot compare the handlerQueue stored
# in the registration message with the one stored in the 
# handlersQueues dictionary!

print({"test":registration.handlerQueue})  # gives:
{'test': <Autoproxy[Queue] object,typeid 'Queue' at 0x21da2b12490>}
# here it appears as soon as I place the queue in a dictionary,# the proxy is stored instead. Interestingly,it has the same
# address as the proxy stored in the registration message.

最重要的问题是:如何验证两个Autoproxy [Queue]对象指向同一队列或一个Autoproxy指向给定队列?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。