本文介绍了Apache的骆驼代理不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题可能与我的概念的理解了。

ActionClass 正在调用代理bean是 AccountingInterface 。代理bean接口与 AccountingUtil 类实现。所以我期待 XML AccountingUtil 返回到 SEDA传递:accountingQueue ,然后流出来控制台。


的ApplicationContext

Issue might be related to my understanding of the concept too.
ActionClass is invoking proxy bean which is AccountingInterface. Proxy bean interface is implemented with AccountingUtil class. So I am expecting xml returned by AccountingUtil to be passed through seda:accountingQueue and then streamed out on console.
ApplicationContext

    <bean id="accountingInterface" class="org.apache.camel.spring.remoting.CamelProxyFactoryBean">
      <property name="serviceUrl" value="seda:accountingQueue"/>
      <property name="serviceInterface" value="acord.transaction.util.AccountingInterface"/>
    </bean>
    <route>
        <from uri="seda:accountingQueue"/>
        <setHeader headerName="nowInMillis">
           <groovy>new Date().getTime()</groovy>
         </setHeader>
         <to uri="stream:out"/>
    </route>

AccountingInterface

public interface AccountingInterface
{
    void send(String xml);
    String accountingUpdate(EDITDate accountingProcessDate);
}

AccountingUtil

public class AccountingUtil implements AccountingInterface
{
  public String accountingUpdate(EDITDate accountingProcessDate)
     {
       //doSomething
      return xml;
    }

ActionClass

AccountingInterface accountingInterface = (AccountingInterface) AppContext.getBean("accountingInterface");
accountingInterface.accountingUpdate(accountingProcessDate);

但我得到异常:

No body available of type: java.lang.String but has value: BeanInvocation public abstract java.lang.String acord.transaction.util.AccountingInterface.accountingUpdate(edit.common.EDITDate) with [2012/11/08]] of type: org.apache.camel.component.bean.BeanInvocation on: Message: BeanInvocation public abstract java.lang.String acord.transaction.util.AccountingInterface.accountingUpdate(edit.common.EDITDate) with [2012/11/08]]. Caused by: No type converter available to convert from type: org.apache.camel.component.bean.BeanInvocation to the required type: java.lang.String with value BeanInvocation public abstract java.lang.String acord.transaction.util.AccountingInterface.accountingUpdate(edit.common.EDITDate) with [2012/11/08]]. Exchange[Message: BeanInvocation public abstract java.lang.String acord.transaction.util.AccountingInterface.accountingUpdate(edit.common.EDITDate) with [2012/11/08]]]. Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: org.apache.camel.component.bean.BeanInvocation to the required type: java.lang.String with value BeanInvocation public abstract java.lang.String acord.transaction.util.AccountingInterface.accountingUpdate(edit.common.EDITDate) with [2012/11/08]]]
    at org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:101)

还有一个问题我有多个的serviceURL proxyBean(接口)
我想不同的方法来调用不同的的serviceURL ,但一个单一的界面的一部分。

One more issue Can I have multiple serviceURL for single proxyBean(interface)?
I want different method to call different serviceURL but part of a single interface.

推荐答案

更新:
啊,刚明白你的问题。首先是有点第一。

Update:Ah, just understood your question. Was a bit first in the first place.

在做代理功能骆驼转换调用(哪种方法/接口和哪些参数)转换成BeanInvocation对象。也就是说然后通过选择(在你的案件SEDA)的骆驼端点要处理的通过。但您要打印到std出来,而不是在调用 AccountingInterface 的bean实例(如 AccountingUpdateACORDUtil 您案件)。

When doing Proxying Camel translates the call (to which method/interface and what arguments) into a BeanInvocation object. That is then passed over the Camel endpoint of choice (seda in your case) to be processed. But you are trying to print it to std out rather than invoke a bean instance of AccountingInterface (such as AccountingUpdateACORDUtil in your case).

不,不同的方法会调用相同的URL但..嗯,在 BeanInvocation 不同的方法。这当然可以通过路由在骆驼航线您的要求,如获得第一它发送给一个简单的直接:routeAccoutingRequest 然后看调用的方法找出哪些端点它应该到了选择的结构。

And no, different methods will call the same URL but with .. well, different methods in the BeanInvocation. This can of course be achieved by routing your request in a Camel route such as first sending it to a simple direct:routeAccoutingRequest then look at the invoked method to figure out which endpoint it should go to in a choice construct.

您可以使用一个简单的对象,ProducerTemplates才达到的东西,如发送字符串,调用不同的方法等。代理是代理豆调用建立你自己的逻辑。

You can build your own logic using a plain object with ProducerTemplates to achive things such as sending Strings, invoking different methods etc. The proxy is for proxying bean invocations.

这篇关于Apache的骆驼代理不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 00:32