【发布时间】:2013-06-24 21:15:34
【问题描述】:
问题也可能与我对这个概念的理解有关。 ActionClass 正在调用代理 bean,它是 AccountingInterface。代理 bean 接口是用AccountingUtil 类实现的。所以我期待AccountingUtil 返回的xml 会通过seda:accountingQueue,然后在控制台上流出。
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>
会计接口
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;
}
动作类
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)
还有一个问题 单个proxyBean(interface) 可以有多个serviceURL 吗?
我想要不同的方法来调用不同的serviceURL,但它是单个接口的一部分。
【问题讨论】:
标签: java apache-camel