1
votes

Issue might be related to my understanding of the concept too.
ActionClass is invoking proxy bean which is AccountingInterface. Proxy bean interface is implemented with AccountingUtil class. So I am expecting xml returned by AccountingUtil to be passed through seda:accountingQueue and then streamed out on console.
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>

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);

But I am getting exception:

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)

One more issue Can I have multiple serviceURL for single proxyBean(interface)?
I want different method to call different serviceURL but part of a single interface.

1

1 Answers

0
votes

Update: Ah, just understood your question. Was a bit first in the first place.

When doing Proxying Camel translates the call (to which method/interface and what arguments) into a BeanInvocation object. That is then passed over the Camel endpoint of choice (seda in your case) to be processed. But you are trying to print it to std out rather than invoke a bean instance of AccountingInterface (such as AccountingUpdateACORDUtil in your case).

And no, different methods will call the same URL but with .. well, different methods in the BeanInvocation. This can of course be achieved by routing your request in a Camel route such as first sending it to a simple direct:routeAccoutingRequest then look at the invoked method to figure out which endpoint it should go to in a choice construct.

You can build your own logic using a plain object with ProducerTemplates to achive things such as sending Strings, invoking different methods etc. The proxy is for proxying bean invocations.