读旧事件

发布于 2024-09-24 01:54:32 字数 163 浏览 6 评论 0原文

我在使用 Smack 3.1 的应用程序和运行 openfire 的服务器时遇到问题。启动应用程序后,它将读取节点上的最后一条消息。这是行不通的,因为消息被解析、处理并放入数据库中。除了在有效负载中发送消息创建时间之外,还有什么方法可以阻止这种重复吗? (实际上,如果有任何信号表明消息已被“消耗”,那就太棒了)

I am having a problem with an application using Smack 3.1 and a server running openfire. Upon starting the application, it will read the last message on the node. This doesn't work since the messages are parsed, processed and placed into a db. Besides sending a message creation time in the payload, is there any way to stop this duplication? (Actually if there is anyway to signal that a message has been "consumed" would be fantastic)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

可遇━不可求 2024-10-01 01:54:32

如果您指的是 pubsub,那么您可以配置节点,使其不使用 persist_itemsmax_items 持久化项目。

如果您无法控制节点创建,那么您可以做的是检查延迟命名空间(jabber:x:delay 和/或 urn:xmpp:delay) 如果是 PEP ,

public void processPacket(Packet pkt) {
   DelayInformation delay = (DelayInformation)pkg.getExtension("x", "jabber:x:delay");
   if (delay != null)
      return; //Discard this packet
   delay = (DelayInformation)pkg.getExtension("x", "urn:xmpp:delay");
   if (delay != null)
      return; //Discard this as well
   //Otherwise this is a good packet
   ...
}

您还可以通过检查 DelayInformation 对象来做出一些决定,例如时间长短、原因等。

那么您将始终获得发布的最后一项,我认为没有办法确定是否延迟即。数据包中没有延迟信息。

您需要获取每夜构建构建您自己的以获得 pubsub 支持。我认为当前版本 Smack 3.1.0 不支持 pubsub。

If you are referring to pubsub then you can either configure the node so that it does not persist items with persist_items and max_items.

If you have no control over the node creation then what you can do is check for the delay namespace (jabber:x:delay and/or urn:xmpp:delay) in the packet

public void processPacket(Packet pkt) {
   DelayInformation delay = (DelayInformation)pkg.getExtension("x", "jabber:x:delay");
   if (delay != null)
      return; //Discard this packet
   delay = (DelayInformation)pkg.getExtension("x", "urn:xmpp:delay");
   if (delay != null)
      return; //Discard this as well
   //Otherwise this is a good packet
   ...
}

You can also make some decision by examining the DelayInformation object as to how long, reason, etc.

If it is PEP then you will always get the last item published and I think there is no way of determining if it was delayed viz. there is no delay info in the packet.

You need to either get nightly builds or build your own for pubsub support. I don't think the current version Smack 3.1.0 supoorts pubsub.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文