问题也可能与我对这个概念的理解有关。
ActionClass
正在调用代理 bean,即AccountingInterface
. 代理bean接口是用AccountingUtil
类实现的。所以我期待xml
返回的AccountingUtil
通过seda:accountingQueue
,然后在控制台上流出。
应用程序上下文
<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);
}
会计工具
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)
还有一个问题我可以有多个serviceURL
单proxyBean(interface)
吗?
我想要不同的方法来调用不同serviceURL
但属于单个接口的一部分。