You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Jeff Talley <ai...@ups.com> on 2008/02/14 16:32:31 UTC

Synchronous calls from client into Camel

How can I set up Camel when running in the same JVM as a client application
so that I can have the client make a call to an interface that is
implemented by Camel. I am basically wanting the client to make business
calls on an interface and have the implementation of that interface injected
into the client by Spring. The implementation would be provided by Camel
which could make RMI calls, web service calls, etc. on the client's behalf
and have the results returned back to the client on a blocking synchronous
call. What would the Java DSL style routing look like?

I would also like to have the client make an asynchronous call into Camel
and provide a callback interface. Camel would then communicate with a remote
application through queues, correlate the response with the request and
provide the results to the client using the provided callback. Is this
possible?

Thanks,
Jeff
-- 
View this message in context: http://www.nabble.com/Synchronous-calls-from-client-into-Camel-tp15481216s22882p15481216.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Synchronous calls from client into Camel

Posted by Willem Jiang <wi...@gmail.com>.
Hi Jeff,

Could you take a look at these two test cases[1][2] in the camel-cxf 
component?
 I think that is what you want ;)

[1]https://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerRouterTest.java
[2]https://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerTest.java

Willem.

Jeff Talley wrote:
> James.Strachan wrote:
>   
>>>  How can I set up Camel when running in the same JVM as a client
>>> application
>>>  so that I can have the client make a call to an interface that is
>>>  implemented by Camel. I am basically wanting the client to make business
>>>  calls on an interface and have the implementation of that interface
>>> injected
>>>  into the client by Spring. The implementation would be provided by Camel
>>>  which could make RMI calls, web service calls, etc. on the client's
>>> behalf
>>>  and have the results returned back to the client on a blocking
>>> synchronous
>>>  call. What would the Java DSL style routing look like?
>>>       
>> If using Camel as a kinda remoting implementation you could try the
>> Spring Remoting feature...
>> http://activemq.apache.org/camel/spring-remoting.html
>>
>>     
> This looks like what I am looking for but I am not getting something. Let's
> say I have an interface like:
>
> public interface MathService {
>    public int add(int a, int b);
>    public int subtract(int a, int b);
> }
>
> And that interface is implemented by some web service on a remote server. I
> could export a proxy from camel like this:
>
> <camel:proxy id="mathServiceProxy" serviceUrl="direct:add"
> serviceInterface="com.example.MathService"/>
>
> I could then inject this proxy into my client application. If I want Camel
> to route this request to a web service and return the result to the calling
> client, what would the routing look like. I want to put something like:
>
> from("direct:add").to("cxf:mathService")
>
> Is this correct? I'm not seeing how the result of the call to the web
> service makes it back to the caller.
>
> I'm also not sure how I specify how to specify which method will be called.
> Is it direct:MathService?add or just direct:add and I have to export for
> each method?
>
>
>   


Re: Synchronous calls from client into Camel

Posted by Jeff Talley <ai...@ups.com>.

James.Strachan wrote:
> 
>>  How can I set up Camel when running in the same JVM as a client
>> application
>>  so that I can have the client make a call to an interface that is
>>  implemented by Camel. I am basically wanting the client to make business
>>  calls on an interface and have the implementation of that interface
>> injected
>>  into the client by Spring. The implementation would be provided by Camel
>>  which could make RMI calls, web service calls, etc. on the client's
>> behalf
>>  and have the results returned back to the client on a blocking
>> synchronous
>>  call. What would the Java DSL style routing look like?
> 
> If using Camel as a kinda remoting implementation you could try the
> Spring Remoting feature...
> http://activemq.apache.org/camel/spring-remoting.html
> 
This looks like what I am looking for but I am not getting something. Let's
say I have an interface like:

public interface MathService {
   public int add(int a, int b);
   public int subtract(int a, int b);
}

And that interface is implemented by some web service on a remote server. I
could export a proxy from camel like this:

<camel:proxy id="mathServiceProxy" serviceUrl="direct:add"
serviceInterface="com.example.MathService"/>

I could then inject this proxy into my client application. If I want Camel
to route this request to a web service and return the result to the calling
client, what would the routing look like. I want to put something like:

from("direct:add").to("cxf:mathService")

Is this correct? I'm not seeing how the result of the call to the web
service makes it back to the caller.

I'm also not sure how I specify how to specify which method will be called.
Is it direct:MathService?add or just direct:add and I have to export for
each method?


-- 
View this message in context: http://www.nabble.com/Synchronous-calls-from-client-into-Camel-tp15481216s22882p15490201.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Synchronous calls from client into Camel

Posted by James Strachan <ja...@gmail.com>.
On 14/02/2008, Jeff Talley <ai...@ups.com> wrote:
>
>  How can I set up Camel when running in the same JVM as a client application
>  so that I can have the client make a call to an interface that is
>  implemented by Camel. I am basically wanting the client to make business
>  calls on an interface and have the implementation of that interface injected
>  into the client by Spring. The implementation would be provided by Camel
>  which could make RMI calls, web service calls, etc. on the client's behalf
>  and have the results returned back to the client on a blocking synchronous
>  call. What would the Java DSL style routing look like?

If using Camel as a kinda remoting implementation you could try the
Spring Remoting feature...
http://activemq.apache.org/camel/spring-remoting.html

>  I would also like to have the client make an asynchronous call into Camel
>  and provide a callback interface. Camel would then communicate with a remote
>  application through queues, correlate the response with the request and
>  provide the results to the client using the provided callback. Is this
>  possible?

It should be :). We implemented something like this on the Lingo
project (http://lingo.codehaus.org/) - we've just not yet made the
client side proxy or server side stub smart enough to deal with
oneways and callbacks yet. It shouldn't be that hard to do btw - as
we've done it before.

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com