用于服务器端的好的 XMPP Java 库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/177514/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Good XMPP Java Libraries for server side?
提问by Taylor Gautier
I was hoping to implement a simple XMPP server in Java.
我希望用 Java 实现一个简单的 XMPP 服务器。
What I need is a library which can parse and understand xmpp requests from a client. I have looked at Smack (mentioned below) and JSO. Smack appears to be client only so while it might help parsing packets it doesn't know how to respond to clients. Is JSO maintained it looks very old. The only promising avenue is to pull apart Openfire which is an entire commercial (OSS) XMPP server.
我需要的是一个可以解析和理解来自客户端的 xmpp 请求的库。我看过 Smack(下面提到的)和 JSO。Smack 似乎只是客户端,因此虽然它可能有助于解析数据包,但它不知道如何响应客户端。JSO 是否维护它看起来很旧。唯一有前途的途径是拆开 Openfire,它是一个完整的商业 (OSS) XMPP 服务器。
I was just hoping for a few lines of code on top of Netty or Mina, so I could get started processing some messages off the wire.
我只是希望在 Netty 或 Mina 之上有几行代码,这样我就可以开始处理一些离线消息。
Joe -
乔——
Well the answer to what I am trying to do is somewhat long - I'll try to keep it short.
好吧,我正在尝试做的事情的答案有点长 - 我会尽量保持简短。
There are two things, that are only loosely related:
有两件事,只是松散相关的:
1) I wanted to write an XMPP server because I imagine writing a custom protocol for two clients to communicate. Basically I am thinking of a networked iPhone app - but I didn't want to rely on low-level binary protocols because using something like XMPP means the app can "grow up" very quickly from a local wifi based app to an internet based one...
1) 我想编写一个 XMPP 服务器,因为我想为两个客户端编写一个自定义协议来进行通信。基本上我正在考虑一个联网的 iPhone 应用程序 - 但我不想依赖低级二进制协议,因为使用像 XMPP 这样的东西意味着该应用程序可以非常快速地从基于 wifi 的本地应用程序“成长”为基于互联网的应用程序...
The msgs exchanged should be relatively low latency, so strictly speaking a binary protocol would be best, but I felt that it might be worth exploring if XMPP didn't introduce too much overhead such that I could use it and then reap benefits of it's extensability and flexability later.
交换的消息应该是相对较低的延迟,所以严格来说二进制协议最好,但我觉得如果 XMPP 不引入太多开销,我可以使用它,然后从它的可扩展性中获益,这可能值得探索和稍后的灵活性。
2) I work for Terracotta - so I have this crazy bent to cluster everything. As soon as I started thinking about writing some custom server code, I figured I wanted to cluster it. Terracotta makes scaling out Java POJOs trivial, so my thought was to build a super simple XMPP server as a demonstration app for Terracotta. Basically each user would connect to the server over a TCP connection, which would register the user into a hashmap. Each user would have a LinkedBlockingQueue with a listener thread taking message from the queue. Then any connected user that wants to send a message to any other user (e.g. any old chat application) simply issues an XMPP message (as usual) to that user over the connection. The server picks it up, looks up the corresponding user object in a map and places the message onto the queue. Since the queue is clustered, regardless of wether the destination user is connected to the same physical server, or a different physical server, the message is delivered and the thread that is listening picks it up and sends it back down the destination user's tcp connection.
2) 我为 Terracotta 工作 - 所以我疯狂地想把所有东西都聚集在一起。当我开始考虑编写一些自定义服务器代码时,我想我想对它进行集群。Terracotta 使 Java POJO 的扩展变得微不足道,所以我的想法是构建一个超级简单的 XMPP 服务器作为 Terracotta 的演示应用程序。基本上,每个用户都会通过 TCP 连接连接到服务器,这会将用户注册到哈希映射中。每个用户都会有一个 LinkedBlockingQueue,其中有一个侦听器线程从队列中获取消息。然后,任何想要向任何其他用户(例如,任何旧的聊天应用程序)发送消息的已连接用户只需通过连接向该用户发出 XMPP 消息(像往常一样)。服务器拿起它,在地图中查找相应的用户对象并将消息放入队列中。由于队列是集群的,
So - not too short of a summary I'm afraid. But that's what I want to do. I suppose I could just write a plugin for Openfire to accomplish #1 but I think it takes care of a lot of plumbing so it's harder to do #2 (especially since I was hoping for a very small amount of code that could fit into a simple 10-20kb Maven project).
所以 - 恐怕不是太短的总结。但这就是我想做的。我想我可以为 Openfire 编写一个插件来完成 #1,但我认为它需要处理很多管道,所以它更难做 #2(特别是因为我希望有非常少量的代码可以放入一个简单的 10-20kb Maven 项目)。
采纳答案by prakash
http://xmpp.org/xmpp-software/libraries/has a list of software libraries for XMPP. Here is an outdatedsnapshot of it:
http://xmpp.org/xmpp-software/libraries/有一个 XMPP 软件库列表。这是它的过时快照:
ActionScript
动作脚本
C
C
C++
C++
C# / .NET / Mono
C# / .NET / 单声道
Erlang
二郎
Flash
闪光
Haskell
哈斯克尔
Java
爪哇
JavaScript
JavaScript
Lisp
Lisp
Objective-C
目标-C
Perl
珀尔
PHP
PHP
Python
Python
Ruby
红宝石
Tcl
TCL
回答by Joe Hildebrand
Your best bet is to use an existing server, and add your functionality to it. Writing an entire server from scratch, even using a library, is going to be a lotharder than you expect.
最好的办法是使用现有的服务器,并将您的功能添加到其中。从头开始编写整个服务器,即使使用库,也比您预期的要困难得多。
Can you tell us more about the problem you are trying to solve? We can then point you to an appropriate server, and help you with the right place to plug in.
你能告诉我们更多关于你试图解决的问题吗?然后,我们可以将您指向合适的服务器,并帮助您找到正确的插入位置。
回答by smokku
Ignite Realtime shares its Tinder APIwhich is a basic building block extracted from OpenFire just for the creation of server-side components and possibly other servers. It implements basic XMPP building blocks and you are free to start from there.
Ignite Realtime 共享其Tinder API,这是从 OpenFire 中提取的基本构建块,仅用于创建服务器端组件和可能的其他服务器。它实现了基本的 XMPP 构建块,您可以自由地从那里开始。
回答by James Webster
Also from Ignite Realtime is the Whack APIwhich is specifically for building XMPP components
同样来自 Ignite Realtime 的是Whack API,它专门用于构建 XMPP 组件
Whack is an Open Source XMPP (Jabber) component library for XMPP components. A pure Java library, it can be embedded into your applications to create anything from a full XMPP component to simple XMPP integrations such as sending intercepting and acting on certain messages.
Whack 是一个用于 XMPP 组件的开源 XMPP (Jabber) 组件库。一个纯 Java 库,它可以嵌入到您的应用程序中,以创建从完整的 XMPP 组件到简单的 XMPP 集成(例如发送拦截和处理某些消息)的任何内容。
回答by Bill Barnhill
I went through the same search. I first tried Smack and then realized it's targeted at c2s (client to server) and didn't have what I need. I looked at Tinder but didn't like the licensing model (also when I looked it was much more raw). I finally looked at Whack and realized it was what I needed - but it's missing a lot (that's why Tinder came about I think).
我经历了同样的搜索。我首先尝试了 Smack,然后意识到它针对 c2s(客户端到服务器)并且没有我需要的东西。我看着 Tinder 但不喜欢许可模式(而且当我看起来它更原始时)。我终于看了 Whack 并意识到这正是我所需要的——但它缺少了很多(我认为这就是 Tinder 出现的原因)。
So..my solution? Forked Whack, added some code to abstract out things, and try to make it easier to use: http://github.com/Communitivity/Adirondack
所以..我的解决方案?Forked Whack,添加了一些代码抽象出来的东西,并尝试使其更易于使用:http: //github.com/Communitivity/Adirondack
I wrote a Scala library based on that to help create external component based agents, see http://github.com/Communitivity/Shellackand http://github.com/Communitivity/MinimalScalaXMPPComponent
我基于它编写了一个 Scala 库来帮助创建基于外部组件的代理,请参阅 http://github.com/Communitivity/Shellack和http://github.com/Communitivity/MinimalScalaXMPPComponent
One of my main goals was to make it easy to write a component quickly. An example of such a component is below:
我的主要目标之一是让快速编写组件变得容易。此类组件的示例如下:
object Main {
/**
* @param args the command line arguments
*/
def main(args: Array[String]) :Unit = {
new XMPPComponent(
new ComponentConfig() {
def secret() : String = { "secret.goes.here" }
def server() : String = { "communitivity.com" }
def subdomain() : String = { "weather" }
def name() : String = { "US Weather" }
def description() : String = { "Weather component that also supported SPARQL/XMPP" }
},
actor {
loop {
react {
case (pkt:Packet, out : Actor) =>
Console.println("Received packet...\n"+pkt.toXML)
pkt match {
case message:Message =>
val reply = new Message()
reply.setTo(message.getFrom())
reply.setFrom(message.getTo())
reply.setType(message.getType())
reply.setThread(message.getThread())
reply.setBody("Received '"+message.getBody()+"', tyvm")
out ! reply
case _ =>
Console.println("Received something other than Message")
}
case _ =>
Console.println("Received something other than (Packet, actor)")
}
}
}
).start
}
}
回答by ely
check this out:
看一下这个:
this is a lower level library. it is in incubation status and it seems nobody is pushing it. but it is a great api and i hope it will progress.
这是一个较低级别的库。它处于孵化状态,似乎没有人推动它。但它是一个很棒的 api,我希望它会进步。
回答by Flow
I think you already looked at the right solution: Openfire
我认为您已经看过正确的解决方案:Openfire
It's not a commercial solution. It's an XMPP Server on top of Mina and Jettywritten in Java released under the Apache License. Comes pretty close to what you asked for. While I know that you asked for a library, why not use some stable developed open source software that can easily be extended like openfire?
这不是商业解决方案。它是一个基于 Mina 和 Jetty的 XMPP 服务器,用 Java 编写,在 Apache 许可下发布。非常接近你的要求。虽然我知道您要求提供一个库,但为什么不使用一些稳定开发的开源软件,这些软件可以像 openfire 一样轻松扩展?
回答by why
I found a good xmpp server based on Java : http://www.tigase.org/
我找到了一个很好的基于 Java 的 xmpp 服务器:http: //www.tigase.org/
回答by Chuk Lee
回答by user2962207
I know that the intent is to build a small hack in the OP. However, if there is ever an interest in scaling it, end-to-end security, etc. I would suggest looking at Soapbox from Coversant. They are our partner. We use SMACK on our hard realtime virtual machine environment, JamaicaVM to communicate with Soapbox.
我知道目的是在 OP 中构建一个小黑客。但是,如果有人对扩展它、端到端安全性等感兴趣。我建议查看 Coversant 的 Soapbox。他们是我们的合作伙伴。我们在我们的硬实时虚拟机环境 JamaicaVM 上使用 SMACK 与 Soapbox 进行通信。
Also, if the intent is to communicate with a server app, and not to reimplement an XMPP server (e.g. Soapbox), the SMACK client can be used for that. It is a client to the XMPP server, but the instance of actual communications can be from client to client through the XMPP server.
此外,如果意图是与服务器应用程序通信,而不是重新实现 XMPP 服务器(例如 Soapbox),则可以使用 SMACK 客户端。它是 XMPP 服务器的客户端,但实际通信的实例可以通过 XMPP 服务器从客户端到客户端。