我尝试使用apache camel使用gtalk帐户发送即时消息。
我使用了apache camel xmpp组件。我能够连接到我的jabber帐户并成功发送消息。对于jabber帐户,我使用以下网址
XMPP://abc@jabber.org/praveen@gmail.com密码=秘密“
这会从我的abc jabber帐户向praveen gmail帐户发送一条消息。但是,当我尝试从我的Gmail帐户发送邮件时,它失败并出现以下异常
XMPP://talk.google.com:5222/abc@jabber.org服务名= gmail.com&安培;用户=普利文&安培;密码=秘密
Caused by: SASL authentication PLAIN failed: invalid-authzid:
at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:337)
at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:203)
at org.apache.camel.component.xmpp.XmppEndpoint.createConnection(XmppEndpoint.java:169)
at org.apache.camel.component.xmpp.XmppPrivateChatProducer.doStart(XmppPrivateChatProducer.java:105)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:387)
... 7 more
当我对此进行一些研究时,我发现Google不支持SASL。所以我需要设置
setSASLAuthenticationEnabled(false);
on org.jivesoftware.smack.ConnectionConfiguration让它运行起来。但我在camel文档中找不到任何参数来设置此参数。
有没有人成功完成此操作?如果是的话,能否请您提供一些有关此事的信息?
谢谢, Palanivel Rajan B
答案 0 :(得分:2)
查看源代码,似乎没有办法在当前的实现中执行此操作。
if (port > 0) {
if (getServiceName() == null) {
connection = new XMPPConnection(new ConnectionConfiguration(host, port));
} else {
connection = new XMPPConnection(new ConnectionConfiguration(host, port, serviceName));
}
} else {
connection = new XMPPConnection(host);
}
将此功能添加到XMPP组件应该不难(并且您可能希望在这种情况下为此添加补丁,因此它可能会进入驼峰的未来版本)或者您可以从XmppEndpoint类派生并覆盖createConnection方法。您可能需要覆盖XMPP组件中的其他一些类,以确保使用自定义端点而不是原始端点。