1

問題は、私の概念の理解にも関連している可能性があります。
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);
}

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)

もう1つの問題serviceURLシングルに対して複数を使用できますproxyBean(interface)か?
異なる方法で、異なるserviceURLが単一のインターフェイスの一部を呼び出す必要があります。

4

1 に答える 1

0

更新: ああ、あなたの質問を理解しました。そもそも少し先だった。

Proxying Camel を実行すると、呼び出し (メソッド/インターフェースと引数) が BeanInvocation オブジェクトに変換されます。その後、選択した Camel エンドポイント (この場合は seda) に渡されて処理されます。AccountingInterfaceしかし、 (あなたの場合のように)のBeanインスタンスを呼び出すのではなく、標準出力に出力しようとしていAccountingUpdateACORDUtilます。

いいえ、異なるメソッドは同じ URL を呼び出しますが、.. の異なるメソッドを使用しBeanInvocationます。direct:routeAccoutingRequestこれはもちろん、最初にリクエストを単純なメソッドに送信してから、呼び出されたメソッドを調べて、choice コンストラクトでどのエンドポイントに移動する必要があるかを判断するなど、Camel ルートでリクエストをルーティングすることで実現できます。

ProducerTemplates でプレーン オブジェクトを使用して独自のロジックを構築し、文字列の送信、さまざまなメソッドの呼び出しなどを実現できます。プロキシは、Bean 呼び出しをプロキシするためのものです。

于 2013-06-24T22:23:05.877 に答える