问题也可能与我对这个概念的理解有关。
ActionClass
正在调用代理bean,即AccountingInterface
。代理bean接口使用AccountingUtil
类实现。所以我期待AccountingUtil
返回xml
通过seda:accountingQueue
,然后流出控制台。
的ApplicationContextApache Camel Proxy不起作用
<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(interface)
?
我想用不同的方法调用不同的serviceURL
,但只是单个接口的一部分。
这应该不是我想的问题。对于一个简单的用例,普通代理bean正在工作。这种方法在骆驼行动中提到。 “代理接口方法的返回”会转到服务url吗? –
阅读这个问题有点太快了。根本改变了答案 –
我明白了每个代理bean都有onUR serviceURL的意思。无法理解我的流程为什么会出错。更新我的问题以解释代码流。 –