通过 Mule ESB CE 连接 Ejabbered
Posted
技术标签:
【中文标题】通过 Mule ESB CE 连接 Ejabbered【英文标题】:Connect Ejabbered via Mule ESB CE 【发布时间】:2013-04-11 02:59:35 【问题描述】:我尝试将 Ejabberd 服务器放在 Mule ESB 社区版的后面,这意味着所有发往 Ejabberd 服务器的消息都必须先到 ESB。
我在文档中使用了xmpp连接器,如下xml配置:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xmpp="http://www.mulesoft.org/schema/mule/xmpp"
xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd
http://www.mulesoft.org/schema/mule/xmpp http://www.mulesoft.org/schema/mule/xmpp/3.1/mule-xmpp.xsd
http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/3.1/mule-stdio.xsd">
<xmpp:connector name="xmppConnector" host="192.168.1.132" port="5222" user="whh@whh.com" password="password"/>
<flow name="stdio2xmpp">
<stdio:inbound-endpoint system="IN"/>
<xmpp:outbound-endpoint type="CHAT" recipient="sjc@whh.com"/>
</flow>
<flow name="xmpp2stdio">
<xmpp:inbound-endpoint type="CHAT" from="sjc@whh.com"/>
<xmpp:xmpp-to-object-transformer/>
<stdio:outbound-endpoint system="OUT"/>
</flow>
</mule>
我确定用户名和密码是正确的,因为我可以使用 Pidgin 登录服务器。当我尝试在工作室中运行此流程时,它总是抛出“未连接到服务器”异常。
Exception in thread "main" org.mule.module.launcher.DeploymentStartException: IllegalStateException: Not connected to server.
at org.mule.module.launcher.application.DefaultMuleApplication.start(DefaultMuleApplication.java:174)
at org.mule.module.launcher.application.ApplicationWrapper.start(ApplicationWrapper.java:107)
at org.mule.module.launcher.DefaultMuleDeployer.deploy(DefaultMuleDeployer.java:47)
at org.mule.tooling.server.application.ApplicationDeployer.run(ApplicationDeployer.java:56)
at org.mule.tooling.server.application.ApplicationDeployer.main(ApplicationDeployer.java:88)
Caused by: org.mule.retry.RetryPolicyExhaustedException: Not connected to server.
at org.mule.retry.policies.AbstractPolicyTemplate.execute(AbstractPolicyTemplate.java:105)
at org.mule.transport.AbstractConnector.connect(AbstractConnector.java:1616)
at org.mule.transport.AbstractConnector.start(AbstractConnector.java:428)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mule.lifecycle.phases.DefaultLifecyclePhase.applyLifecycle(DefaultLifecyclePhase.java:225)
at org.mule.lifecycle.RegistryLifecycleManager$RegistryLifecycleCallback.onTransition(RegistryLifecycleManager.java:276)
at org.mule.lifecycle.RegistryLifecycleManager.invokePhase(RegistryLifecycleManager.java:155)
at org.mule.lifecycle.RegistryLifecycleManager.fireLifecycle(RegistryLifecycleManager.java:126)
at org.mule.registry.AbstractRegistryBroker.fireLifecycle(AbstractRegistryBroker.java:80)
at org.mule.registry.MuleRegistryHelper.fireLifecycle(MuleRegistryHelper.java:120)
at org.mule.lifecycle.MuleContextLifecycleManager$MuleContextLifecycleCallback.onTransition(MuleContextLifecycleManager.java:94)
at org.mule.lifecycle.MuleContextLifecycleManager$MuleContextLifecycleCallback.onTransition(MuleContextLifecycleManager.java:90)
at org.mule.lifecycle.MuleContextLifecycleManager.invokePhase(MuleContextLifecycleManager.java:72)
at org.mule.lifecycle.MuleContextLifecycleManager.fireLifecycle(MuleContextLifecycleManager.java:64)
at org.mule.DefaultMuleContext.start(DefaultMuleContext.java:250)
at org.mule.module.launcher.application.DefaultMuleApplication.start(DefaultMuleApplication.java:151)
... 4 more
Caused by: java.lang.IllegalStateException: Not connected to server.
at org.jivesoftware.smack.XMPPConnection.addPacketListener(XMPPConnection.java:747)
at org.jivesoftware.smackx.ServiceDiscoveryManager.init(ServiceDiscoveryManager.java:270)
at org.jivesoftware.smackx.ServiceDiscoveryManager.(ServiceDiscoveryManager.java:80)
at org.jivesoftware.smackx.ServiceDiscoveryManager$1.connectionCreated(ServiceDiscoveryManager.java:66)
at org.jivesoftware.smack.XMPPConnection.initConnection(XMPPConnection.java:957)
at org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection.java:904)
at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:1415)
at org.mule.transport.xmpp.XmppConnector.connectToJabberServer(XmppConnector.java:137)
at org.mule.transport.xmpp.XmppConnector.doConnect(XmppConnector.java:84)
at org.mule.transport.AbstractConnector$5.doWork(AbstractConnector.java:1556)
at org.mule.retry.policies.AbstractPolicyTemplate.execute(AbstractPolicyTemplate.java:67)
... 22 more
有人对这个问题有想法吗?谢谢。
【问题讨论】:
【参考方案1】:mule 它建立在 Smack 之上,在建立连接时可能会遇到问题。
您能否验证 xmpp 服务器是否已启动?一旦你知道它继续调试 Smack。 Smack connection init 只捕获可能抛出的异常子集。 例如。它会忽略 NPE 并声称该连接正常。 它也不是线程安全的,所以原型只有一个到 xmpp 服务器的连接。
【讨论】:
我确定服务器已启动。好的,我会尝试在 mule esb 中调试 Smack。以上是关于通过 Mule ESB CE 连接 Ejabbered的主要内容,如果未能解决你的问题,请参考以下文章
Mule ESB-3.Build a webservice proxy
Mule ESB-3.Build a webservice proxy