Java Apache Camel代理不工作

Java Apache Camel代理不工作,java,apache-camel,Java,Apache Camel,这个问题也可能与我对这个概念的理解有关。 ActionClass正在调用代理bean,代理bean是AccountingInterface。代理bean接口是用AccountingUtil类实现的。所以我希望AccountingUtil返回的xml通过seda:accountingQueue传递,然后在控制台上流式输出。 应用程序上下文 会计直至 动作类 但我有个例外: No body available of type: java.lang.String but has value: Bean

这个问题也可能与我对这个概念的理解有关。 ActionClass正在调用代理bean,代理bean是AccountingInterface。代理bean接口是用AccountingUtil类实现的。所以我希望AccountingUtil返回的xml通过seda:accountingQueue传递,然后在控制台上流式输出。 应用程序上下文

会计直至

动作类

但我有个例外:

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)
还有一个问题,我可以为单个代理BeanInterface提供多个serviceURL吗?我希望使用不同的方法调用不同的serviceURL,但只是单个接口的一部分。

更新: 啊,我刚刚明白你的问题。一开始有点领先

在执行代理时,Camel将对哪个方法/接口的调用以及哪些参数转换为BeanInvocation对象。然后将其传递到要处理的案例中选择的Camel端点seda。但您正在尝试将其打印到std out,而不是在您的案例中调用AccountingUpdateACORDUtil之类的AccountingInterface的bean实例

不,不同的方法将调用相同的URL,但使用。。嗯,在这个职业中有不同的方法。当然,这可以通过在驼峰路由中路由您的请求来实现,比如首先将请求发送到一个简单的direct:routeAccountingRequest,然后查看调用的方法,以确定它应该在choice构造中到达哪个端点


您可以使用带有ProducerTemplates的普通对象构建自己的逻辑,以实现诸如发送字符串、调用不同方法等功能。代理用于代理bean调用。

我认为这应该不是问题。对于一个简单的用例,普通代理bean正在工作。《骆驼行动》中提到了这种方法。代理接口方法的返回将转到服务url,这是一个公平的假设吗?读这个问题有点太快了。答案完全改变了,我明白你的意思,每个代理bean都有一个onw serviceURL。无法理解为什么我的流出现错误。更新了我的问题以解释代码流。我想问题在于我对整个隐藏中间件概念本身的理解:查看我的另一个[问题][1],具体到这个想法。[1]:
public interface AccountingInterface 
{
    void send(String xml);
    String accountingUpdate(EDITDate accountingProcessDate);
}
public class AccountingUtil implements AccountingInterface
{
  public String accountingUpdate(EDITDate accountingProcessDate)
     {
       //doSomething
      return xml;
    }
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)