JBoss ESB 消息被错误的服务接收
我在 jboss-esb.xml 中配置了多个服务,当我向其中一项服务发送消息时,我的消息将由已配置的服务之一接收(即使该消息不适用于该服务)!
如果我再次发送相同的消息,另一个服务将处理该消息(以循环方式),它不是随机的,就像每个服务轮流拦截该消息。
例如,如果我配置了 3 个服务。第一次发送消息,服务 1 会收到,第二次发送消息,服务 2 会收到,第三次发送消息,服务 3 会收到。我第四次发送它,服务 1 将收到它并重复循环。
我怀疑我配置 jboss-esb.xml 的方式有问题,但我一无所知。
这是我调用服务的方式,
ServiceInvoker invoker = new ServiceInvoker("NTIAdaptor", "SearchAccountByParentInternalId");
Message replyMessage = invoker.deliverSync(requestMessage, TIMEOUT);
这是 jboss-esb.xml,
<?xml version="1.0"?>
<jbossesb parameterReloadSecs="5"
xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd http://anonsvn.jboss.org/repos/labs/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd">
<providers>
<jms-provider connection-factory="ConnectionFactory" name="JMS Provider">
<jms-bus busid="NTI">
<jms-message-filter dest-name="queue/NTIAdaptor" dest-type="QUEUE"/>
</jms-bus>
</jms-provider>
</providers>
<services>
<service category="NTIAdaptor"
description="SearchAccountByExternalId" name="SearchAccountByExternalId">
<listeners>
<jms-listener busidref="NTI" name="JMS"/>
</listeners>
<actions mep="RequestResponse" webservice="true">
<action class="com.krona.esb.action.AuthenticateAction" name="authenticate"/>
<action class="com.krona.esb.action.LogAction" name="logStart"/>
<action
class="com.krona.esb.account.action.SearchAccountByExternalIdAction"
name="process" process="process"/>
<action class="com.krona.esb.action.LogAction" name="logEnd"/>
</actions>
</service>
<service category="NTIAdaptor"
description="SearchAccountByInternalId" name="SearchAccountByInternalId">
<listeners>
<jms-listener busidref="NTI" name="JMS"/>
</listeners>
<actions mep="RequestResponse" webservice="true">
<action class="com.krona.esb.action.AuthenticateAction" name="authenticate"/>
<action class="com.krona.esb.action.LogAction" name="logStart"/>
<action
class="com.krona.esb.account.action.SearchAccountByInternalIdAction"
name="process" process="process"/>
<action class="com.krona.esb.action.LogAction" name="logEnd"/>
</actions>
</service>
<service category="NTIAdaptor"
description="SearchAccountByParentInternalId" name="SearchAccountByParentInternalId">
<listeners>
<jms-listener busidref="NTI" name="JMS"/>
</listeners>
<actions mep="RequestResponse" webservice="true">
<action class="com.krona.esb.action.AuthenticateAction" name="authenticate"/>
<action class="com.krona.esb.action.LogAction" name="logStart"/>
<action
class="com.krona.esb.account.action.SearchAccountByParentInternalIdAction"
name="process" process="process"/>
<action class="com.krona.esb.action.LogAction" name="logEnd"/>
</actions>
</service>
<service category="NTIAdaptor"
description="SearchAccountByServiceExternalId" name="SearchAccountByServiceExternalId">
<listeners>
<jms-listener busidref="NTI" name="JMS"/>
</listeners>
<actions mep="RequestResponse" webservice="true">
<action class="com.krona.esb.action.AuthenticateAction" name="authenticate"/>
<action class="com.krona.esb.action.LogAction" name="logStart"/>
<action
class="com.krona.esb.account.action.SearchAccountByServiceExternalIdAction"
name="process" process="process"/>
<action class="com.krona.esb.action.LogAction" name="logEnd"/>
</actions>
</service>
</services>
</jbossesb>
I have several services configured in jboss-esb.xml, when I send message to one of the service, my message will be received by one of the configured services (even though the message is not meant for that service)!
If I send the same message again, another service will process that message (in round-robin maner), it is not random, it is like each service takes turn to intercept the message.
Example, if I have 3 services configured. First time I send a message, Service 1 will receive it, second time I send a message, Service 2 will receive it, third time I send the message, Service 3 will receive it. Fourth time I send it, Service 1 will receive it and the cycle repeat..
I suspect there is something wrong with the way I configured my jboss-esb.xml, but I am clueless.
Here is how I invoke the service,
ServiceInvoker invoker = new ServiceInvoker("NTIAdaptor", "SearchAccountByParentInternalId");
Message replyMessage = invoker.deliverSync(requestMessage, TIMEOUT);
And here is the jboss-esb.xml,
<?xml version="1.0"?>
<jbossesb parameterReloadSecs="5"
xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd http://anonsvn.jboss.org/repos/labs/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd">
<providers>
<jms-provider connection-factory="ConnectionFactory" name="JMS Provider">
<jms-bus busid="NTI">
<jms-message-filter dest-name="queue/NTIAdaptor" dest-type="QUEUE"/>
</jms-bus>
</jms-provider>
</providers>
<services>
<service category="NTIAdaptor"
description="SearchAccountByExternalId" name="SearchAccountByExternalId">
<listeners>
<jms-listener busidref="NTI" name="JMS"/>
</listeners>
<actions mep="RequestResponse" webservice="true">
<action class="com.krona.esb.action.AuthenticateAction" name="authenticate"/>
<action class="com.krona.esb.action.LogAction" name="logStart"/>
<action
class="com.krona.esb.account.action.SearchAccountByExternalIdAction"
name="process" process="process"/>
<action class="com.krona.esb.action.LogAction" name="logEnd"/>
</actions>
</service>
<service category="NTIAdaptor"
description="SearchAccountByInternalId" name="SearchAccountByInternalId">
<listeners>
<jms-listener busidref="NTI" name="JMS"/>
</listeners>
<actions mep="RequestResponse" webservice="true">
<action class="com.krona.esb.action.AuthenticateAction" name="authenticate"/>
<action class="com.krona.esb.action.LogAction" name="logStart"/>
<action
class="com.krona.esb.account.action.SearchAccountByInternalIdAction"
name="process" process="process"/>
<action class="com.krona.esb.action.LogAction" name="logEnd"/>
</actions>
</service>
<service category="NTIAdaptor"
description="SearchAccountByParentInternalId" name="SearchAccountByParentInternalId">
<listeners>
<jms-listener busidref="NTI" name="JMS"/>
</listeners>
<actions mep="RequestResponse" webservice="true">
<action class="com.krona.esb.action.AuthenticateAction" name="authenticate"/>
<action class="com.krona.esb.action.LogAction" name="logStart"/>
<action
class="com.krona.esb.account.action.SearchAccountByParentInternalIdAction"
name="process" process="process"/>
<action class="com.krona.esb.action.LogAction" name="logEnd"/>
</actions>
</service>
<service category="NTIAdaptor"
description="SearchAccountByServiceExternalId" name="SearchAccountByServiceExternalId">
<listeners>
<jms-listener busidref="NTI" name="JMS"/>
</listeners>
<actions mep="RequestResponse" webservice="true">
<action class="com.krona.esb.action.AuthenticateAction" name="authenticate"/>
<action class="com.krona.esb.action.LogAction" name="logStart"/>
<action
class="com.krona.esb.account.action.SearchAccountByServiceExternalIdAction"
name="process" process="process"/>
<action class="com.krona.esb.action.LogAction" name="logEnd"/>
</actions>
</service>
</services>
</jbossesb>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您遇到该问题是因为您在各个服务中使用相同的 jms-bus。尝试为每个服务 jms 侦听器使用不同的 jms-bus。
You are experiencing that problem because you're using the same jms-bus across services. Try using a different jms-bus for each service jms listener.
如果不是曼努埃尔所说的那样,我们也遇到了与您类似的问题,消息发送到了错误的服务。
在我们的例子中,当我们将监听器从一种服务更改为另一种服务时,juddi 寄存器没有改变。所以我们最终有 2 个服务监听同一个队列。
If is not what Manuel says, we had a similar problem to yours, messages were getting to the wrong services.
In our case it was that the juddi register wasn't altered when we changed a listener from one services to another. So we ended with 2 services listening to the same queue.