我们可以使用Solace Python API一次调用读取或消耗多条消息吗?

huangapple go评论63阅读模式
英文:

Can we read or consume multiple messages with only one call from queue using solace python api

问题

我有一个队列,有多个主题订阅它。我发布了多条消息到不同的主题,我想通过只做一个调用来读取所有这些消息。如何使用Solace Python API实现这一点?

我尝试使用Solace PubSub+包中的持久消息接收器模块。

英文:

I have a queue with multiple topics subscribed to it. I published multiple messages to various topics and I want to read all those messages by making only one call. How to achieve this using solace python apis

I tried using persistent message receiver module in solace-pubsubplus package

答案1

得分: 2

Solace消息传递是异步传递。您不需要请求队列将所有消息发送给您,而是您的应用程序会绑定到队列一次,然后每次消息落入队列时,您的应用程序会被触发。这样可以防止您不断地每隔几秒钟询问“队列上是否还有更多消息”。

如果您需要一次处理多条消息,那么您的应用程序可以等待更多消息到达,然后批量处理它们。通常情况下,您的应用程序会在处理消息之前将其存储X秒或直到获得Y条消息,然后进行处理并确认它们。只需确保在等待其他消息到达时不要阻塞回调/onMessage线程。

这不显示批量消息处理,但是这是一个使用Python从Solace队列消费的示例。https://github.com/SolaceSamples/solace-samples-python/blob/main/patterns/guaranteed_subscriber.py

英文:

Solace messaging is async delivery. You don't request a queue to send you all the message on it, but rather your app would bind to the queue once and then your app essentially gets triggered each time a message lands on the queue. This prevents you from continually having to say "are there any more messages on the queue?" every few seconds.

If you need to process multiple messages at once then your app can wait for more messages to arrive before processing them in bulk in your app. Usually your app would store the messages for X seconds or until it gets Y messages before processing them and then ACKing them. Just be sure not to block the callback/onMessage thread while you are waiting for other messages to come in.

This doesn't show the bulk message processing, but is an example of consuming using Python from a Solace queue. https://github.com/SolaceSamples/solace-samples-python/blob/main/patterns/guaranteed_subscriber.py

huangapple
  • 本文由 发表于 2023年6月26日 18:47:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76555961.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定