You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by tatha <ta...@gmail.com> on 2011/09/24 13:41:07 UTC

Invoking a Camel end point deployed in remote Server from JUnit test case

Hi All,

I am a newbie in Camel and have to deliver a module in a very short notice.
You know how it is :).My question may be a very basic question but i would
really appreciate if someone could guide me on it. 

The requirement is to invoke a camel endpoint service deployed in a tomcat
server from a junit test case. The Service has been injected with the
CamelContext and it has got a set of exposed methods which needs to be
called.We are using Spring 2.5 and Camel 2 in our project. The Spring config
is below


&lt;bean name="/DispatcherService"
class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter"&gt;
        &lt;property name="service" ref="dispatcherService"/&gt;
        &lt;property name="serviceInterface"
value="test.DispatcherService"/&gt;
    &lt;/bean&gt;
	
	&lt;camelContext id="dispatcherCamelContext" trace="true"
xmlns="http://camel.apache.org/schema/spring"&gt;
		&lt;route&gt;
  			&lt;from uri="direct:dispatcherChannel" /&gt;
  				&lt;!-- use comma as a delimiter for String based values --&gt;
  				&lt;recipientList delimiter=","&gt;
    				&lt;header&gt;serviceEndpoints&lt;/header&gt;
  				&lt;/recipientList&gt;
		&lt;/route&gt;
	&lt;/camelContext&gt;

	&lt;bean id="dispatcherService" class="test.DispatcherServiceImpl"&gt;
		&lt;property name="context" ref="dispatcherCamelContext" /&gt;
	&lt;/bean&gt;



what i am not able to find is to find how can we call the end point uri
direct:dispatcherChannel deployed in a tomcat server (http://someIP:8080)
from a junit which uses spring configuration.

Can some one please help me.

Thanking all in advance.

Thanks
tatha

 




--
View this message in context: http://camel.465427.n5.nabble.com/Invoking-a-Camel-end-point-deployed-in-remote-Server-from-JUnit-test-case-tp4836420p4836420.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Invoking a Camel end point deployed in remote Server from JUnit test case

Posted by tatha <ta...@gmail.com>.
Hi Claus,

Thanks for your inputs.

We cant upgrade the version , but we will do something similar to what you
suggested in point no 2. Instead of calling a Servlet, we will call a
business class using Spring remote invocation. We will configure the
business class with camel context.

I have already tested it out with a test program. Will update the project
code and move on from there.

Thanks for your suggestions, though the current task was a rare one off r&d
into Camel, but surely would like to understand Camel more in future so that
it will help us to make better technical architecture decisions.

Thanks
Tatha

On Sun, Sep 25, 2011 at 5:58 PM, Claus Ibsen-2 [via Camel] <
ml-node+s465427n4838329h88@n5.nabble.com> wrote:

> On Sun, Sep 25, 2011 at 9:18 AM, tatha <[hidden email]<http://user/SendEmail.jtp?type=node&node=4838329&i=0>>
> wrote:
> > Hi Claus,
> >
> > Thanks for the response.
> >
> > We are using Camel 2.0.0. Yes you are right, the Tomcat runs on one JVM
> and
> > the JUNIT needs to run on another JVM, so in short we have to do a remote
>
> > communication to call the endpoint.
> >
> Camel 2.0.0 is a very old release. You may consider if possible to upgrade.
>
>
> Yes that you need. For example you can use HTTP as remote communication.
> Tomcat is a web server, so it can already exposes a service over HTTP.
>
> You can use the Camel servlet component
> http://camel.apache.org/servlet
>
> You can also just create a regular servlet in Tomcat, and from the
> servlet invoke the Camel direct endpoint,
> using a ProducerTemplate.
>
> For example we used to have an Axis example that shows how to use Axis
> (Servlet) with Camel.
> You can use that as an inspiration
>
> https://svn.apache.org/repos/asf/camel/tags/camel-2.7.0/examples/camel-example-axis/
>
>
>
>
> > The DispatcherServiceImpl is a simple stateless business class, which has
>
> > business methods which accepts xml inputs and processes that to return a
> > response xml.
> >
> > I hope that helps. I was able to call the end point if its running on the
>
> > same JVM, but not in the case mentioned.
> >
> > Thanks,
> >
> > Tatha
> >
> > On Sat, Sep 24, 2011 at 6:56 PM, Claus Ibsen-2 [via Camel] <
> > [hidden email] <http://user/SendEmail.jtp?type=node&node=4838329&i=1>>
> wrote:
> >
> >> Hi
> >>
> >> Welcome to the Camel community.
> >>
> >> What version of Camel are you using?
> >>
> >> Does your unit test run in one JVM, and Tomcat in another JMV
> >> (possible on a remote server)?
> >> So what you need to do is a remote communication from JVM to JVM over
> >> the network?
> >>
> >>
> >> What do you do in this bean, DispatcherServiceImpl ?
> >>
> >>
> >>
> >>
> >> On Sat, Sep 24, 2011 at 1:41 PM, tatha <[hidden email]<
> http://user/SendEmail.jtp?type=node&node=4836572&i=0>>
> >> wrote:
> >>
> >> > Hi All,
> >> >
> >> > I am a newbie in Camel and have to deliver a module in a very short
> >> notice.
> >> > You know how it is :).My question may be a very basic question but i
> >> would
> >> > really appreciate if someone could guide me on it.
> >> >
> >> > The requirement is to invoke a camel endpoint service deployed in a
> >> tomcat
> >> > server from a junit test case. The Service has been injected with the
> >> > CamelContext and it has got a set of exposed methods which needs to be
>
> >> > called.We are using Spring 2.5 and Camel 2 in our project. The Spring
> >> config
> >> > is below
> >> >
> >> >
> >> > &lt;bean name="/DispatcherService"
> >> >
> >>
> class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter"&gt;
>
> >>
> >> >        &lt;property name="service" ref="dispatcherService"/&gt;
> >> >        &lt;property name="serviceInterface"
> >> > value="test.DispatcherService"/&gt;
> >> >    &lt;/bean&gt;
> >> >
> >> >        &lt;camelContext id="dispatcherCamelContext" trace="true"
> >> > xmlns="http://camel.apache.org/schema/spring"&gt;
> >> >                &lt;route&gt;
> >> >                        &lt;from uri="direct:dispatcherChannel" /&gt;
> >> >                                &lt;!-- use comma as a delimiter for
> >> String based values --&gt;
> >> >                                &lt;recipientList delimiter=","&gt;
> >> >
> >>  &lt;header&gt;serviceEndpoints&lt;/header&gt;
> >> >                                &lt;/recipientList&gt;
> >> >                &lt;/route&gt;
> >> >        &lt;/camelContext&gt;
> >> >
> >> >        &lt;bean id="dispatcherService"
> >> class="test.DispatcherServiceImpl"&gt;
> >> >                &lt;property name="context"
> ref="dispatcherCamelContext"
> >> /&gt;
> >> >        &lt;/bean&gt;
> >> >
> >> >
> >> >
> >> > what i am not able to find is to find how can we call the end point
> uri
> >> > direct:dispatcherChannel deployed in a tomcat server (
> http://someIP:8080)
> >>
> >> > from a junit which uses spring configuration.
> >> >
> >> > Can some one please help me.
> >> >
> >> > Thanking all in advance.
> >> >
> >> > Thanks
> >> > tatha
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > --
> >> > View this message in context:
> >>
> http://camel.465427.n5.nabble.com/Invoking-a-Camel-end-point-deployed-in-remote-Server-from-JUnit-test-case-tp4836420p4836420.html
> >> > Sent from the Camel - Users mailing list archive at Nabble.com.
> >>
> >>
> >>
> >> --
> >> Claus Ibsen
> >> -----------------
> >> FuseSource
> >> Email: [hidden email]<
> http://user/SendEmail.jtp?type=node&node=4836572&i=1>
> >> Web: http://fusesource.com
> >> Twitter: davsclaus, fusenews
> >> Blog: http://davsclaus.blogspot.com/
> >> Author of Camel in Action: http://www.manning.com/ibsen/
> >>
> >>
> >> ------------------------------
> >>  If you reply to this email, your message will be added to the
> discussion
> >> below:
> >>
> >>
> http://camel.465427.n5.nabble.com/Invoking-a-Camel-end-point-deployed-in-remote-Server-from-JUnit-test-case-tp4836420p4836572.html
> >>  To unsubscribe from Invoking a Camel end point deployed in remote
> Server
> >> from JUnit test case, click here<
>
> >>
> >>
> >
> >
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/Invoking-a-Camel-end-point-deployed-in-remote-Server-from-JUnit-test-case-tp4836420p4837929.html
>
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: [hidden email]<http://user/SendEmail.jtp?type=node&node=4838329&i=2>
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://camel.465427.n5.nabble.com/Invoking-a-Camel-end-point-deployed-in-remote-Server-from-JUnit-test-case-tp4836420p4838329.html
>  To unsubscribe from Invoking a Camel end point deployed in remote Server
> from JUnit test case, click here<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4836420&code=dGF0aGEucm95QGdtYWlsLmNvbXw0ODM2NDIwfC0xNDMwMjA5Njk5>.
>
>


--
View this message in context: http://camel.465427.n5.nabble.com/Invoking-a-Camel-end-point-deployed-in-remote-Server-from-JUnit-test-case-tp4836420p4840686.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Invoking a Camel end point deployed in remote Server from JUnit test case

Posted by Claus Ibsen <cl...@gmail.com>.
On Sun, Sep 25, 2011 at 9:18 AM, tatha <ta...@gmail.com> wrote:
> Hi Claus,
>
> Thanks for the response.
>
> We are using Camel 2.0.0. Yes you are right, the Tomcat runs on one JVM and
> the JUNIT needs to run on another JVM, so in short we have to do a remote
> communication to call the endpoint.
>
Camel 2.0.0 is a very old release. You may consider if possible to upgrade.

Yes that you need. For example you can use HTTP as remote communication.
Tomcat is a web server, so it can already exposes a service over HTTP.

You can use the Camel servlet component
http://camel.apache.org/servlet

You can also just create a regular servlet in Tomcat, and from the
servlet invoke the Camel direct endpoint,
using a ProducerTemplate.

For example we used to have an Axis example that shows how to use Axis
(Servlet) with Camel.
You can use that as an inspiration
https://svn.apache.org/repos/asf/camel/tags/camel-2.7.0/examples/camel-example-axis/




> The DispatcherServiceImpl is a simple stateless business class, which has
> business methods which accepts xml inputs and processes that to return a
> response xml.
>
> I hope that helps. I was able to call the end point if its running on the
> same JVM, but not in the case mentioned.
>
> Thanks,
>
> Tatha
>
> On Sat, Sep 24, 2011 at 6:56 PM, Claus Ibsen-2 [via Camel] <
> ml-node+s465427n4836572h21@n5.nabble.com> wrote:
>
>> Hi
>>
>> Welcome to the Camel community.
>>
>> What version of Camel are you using?
>>
>> Does your unit test run in one JVM, and Tomcat in another JMV
>> (possible on a remote server)?
>> So what you need to do is a remote communication from JVM to JVM over
>> the network?
>>
>>
>> What do you do in this bean, DispatcherServiceImpl ?
>>
>>
>>
>>
>> On Sat, Sep 24, 2011 at 1:41 PM, tatha <[hidden email]<http://user/SendEmail.jtp?type=node&node=4836572&i=0>>
>> wrote:
>>
>> > Hi All,
>> >
>> > I am a newbie in Camel and have to deliver a module in a very short
>> notice.
>> > You know how it is :).My question may be a very basic question but i
>> would
>> > really appreciate if someone could guide me on it.
>> >
>> > The requirement is to invoke a camel endpoint service deployed in a
>> tomcat
>> > server from a junit test case. The Service has been injected with the
>> > CamelContext and it has got a set of exposed methods which needs to be
>> > called.We are using Spring 2.5 and Camel 2 in our project. The Spring
>> config
>> > is below
>> >
>> >
>> > &lt;bean name="/DispatcherService"
>> >
>> class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter"&gt;
>>
>> >        &lt;property name="service" ref="dispatcherService"/&gt;
>> >        &lt;property name="serviceInterface"
>> > value="test.DispatcherService"/&gt;
>> >    &lt;/bean&gt;
>> >
>> >        &lt;camelContext id="dispatcherCamelContext" trace="true"
>> > xmlns="http://camel.apache.org/schema/spring"&gt;
>> >                &lt;route&gt;
>> >                        &lt;from uri="direct:dispatcherChannel" /&gt;
>> >                                &lt;!-- use comma as a delimiter for
>> String based values --&gt;
>> >                                &lt;recipientList delimiter=","&gt;
>> >
>>  &lt;header&gt;serviceEndpoints&lt;/header&gt;
>> >                                &lt;/recipientList&gt;
>> >                &lt;/route&gt;
>> >        &lt;/camelContext&gt;
>> >
>> >        &lt;bean id="dispatcherService"
>> class="test.DispatcherServiceImpl"&gt;
>> >                &lt;property name="context" ref="dispatcherCamelContext"
>> /&gt;
>> >        &lt;/bean&gt;
>> >
>> >
>> >
>> > what i am not able to find is to find how can we call the end point uri
>> > direct:dispatcherChannel deployed in a tomcat server (http://someIP:8080)
>>
>> > from a junit which uses spring configuration.
>> >
>> > Can some one please help me.
>> >
>> > Thanking all in advance.
>> >
>> > Thanks
>> > tatha
>> >
>> >
>> >
>> >
>> >
>> >
>> > --
>> > View this message in context:
>> http://camel.465427.n5.nabble.com/Invoking-a-Camel-end-point-deployed-in-remote-Server-from-JUnit-test-case-tp4836420p4836420.html
>> > Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> FuseSource
>> Email: [hidden email]<http://user/SendEmail.jtp?type=node&node=4836572&i=1>
>> Web: http://fusesource.com
>> Twitter: davsclaus, fusenews
>> Blog: http://davsclaus.blogspot.com/
>> Author of Camel in Action: http://www.manning.com/ibsen/
>>
>>
>> ------------------------------
>>  If you reply to this email, your message will be added to the discussion
>> below:
>>
>> http://camel.465427.n5.nabble.com/Invoking-a-Camel-end-point-deployed-in-remote-Server-from-JUnit-test-case-tp4836420p4836572.html
>>  To unsubscribe from Invoking a Camel end point deployed in remote Server
>> from JUnit test case, click here<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4836420&code=dGF0aGEucm95QGdtYWlsLmNvbXw0ODM2NDIwfC0xNDMwMjA5Njk5>.
>>
>>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Invoking-a-Camel-end-point-deployed-in-remote-Server-from-JUnit-test-case-tp4836420p4837929.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Invoking a Camel end point deployed in remote Server from JUnit test case

Posted by tatha <ta...@gmail.com>.
Hi Claus,

Thanks for the response.

We are using Camel 2.0.0. Yes you are right, the Tomcat runs on one JVM and
the JUNIT needs to run on another JVM, so in short we have to do a remote
communication to call the endpoint.

The DispatcherServiceImpl is a simple stateless business class, which has
business methods which accepts xml inputs and processes that to return a
response xml.

I hope that helps. I was able to call the end point if its running on the
same JVM, but not in the case mentioned.

Thanks,

Tatha

On Sat, Sep 24, 2011 at 6:56 PM, Claus Ibsen-2 [via Camel] <
ml-node+s465427n4836572h21@n5.nabble.com> wrote:

> Hi
>
> Welcome to the Camel community.
>
> What version of Camel are you using?
>
> Does your unit test run in one JVM, and Tomcat in another JMV
> (possible on a remote server)?
> So what you need to do is a remote communication from JVM to JVM over
> the network?
>
>
> What do you do in this bean, DispatcherServiceImpl ?
>
>
>
>
> On Sat, Sep 24, 2011 at 1:41 PM, tatha <[hidden email]<http://user/SendEmail.jtp?type=node&node=4836572&i=0>>
> wrote:
>
> > Hi All,
> >
> > I am a newbie in Camel and have to deliver a module in a very short
> notice.
> > You know how it is :).My question may be a very basic question but i
> would
> > really appreciate if someone could guide me on it.
> >
> > The requirement is to invoke a camel endpoint service deployed in a
> tomcat
> > server from a junit test case. The Service has been injected with the
> > CamelContext and it has got a set of exposed methods which needs to be
> > called.We are using Spring 2.5 and Camel 2 in our project. The Spring
> config
> > is below
> >
> >
> > &lt;bean name="/DispatcherService"
> >
> class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter"&gt;
>
> >        &lt;property name="service" ref="dispatcherService"/&gt;
> >        &lt;property name="serviceInterface"
> > value="test.DispatcherService"/&gt;
> >    &lt;/bean&gt;
> >
> >        &lt;camelContext id="dispatcherCamelContext" trace="true"
> > xmlns="http://camel.apache.org/schema/spring"&gt;
> >                &lt;route&gt;
> >                        &lt;from uri="direct:dispatcherChannel" /&gt;
> >                                &lt;!-- use comma as a delimiter for
> String based values --&gt;
> >                                &lt;recipientList delimiter=","&gt;
> >
>  &lt;header&gt;serviceEndpoints&lt;/header&gt;
> >                                &lt;/recipientList&gt;
> >                &lt;/route&gt;
> >        &lt;/camelContext&gt;
> >
> >        &lt;bean id="dispatcherService"
> class="test.DispatcherServiceImpl"&gt;
> >                &lt;property name="context" ref="dispatcherCamelContext"
> /&gt;
> >        &lt;/bean&gt;
> >
> >
> >
> > what i am not able to find is to find how can we call the end point uri
> > direct:dispatcherChannel deployed in a tomcat server (http://someIP:8080)
>
> > from a junit which uses spring configuration.
> >
> > Can some one please help me.
> >
> > Thanking all in advance.
> >
> > Thanks
> > tatha
> >
> >
> >
> >
> >
> >
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/Invoking-a-Camel-end-point-deployed-in-remote-Server-from-JUnit-test-case-tp4836420p4836420.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: [hidden email]<http://user/SendEmail.jtp?type=node&node=4836572&i=1>
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://camel.465427.n5.nabble.com/Invoking-a-Camel-end-point-deployed-in-remote-Server-from-JUnit-test-case-tp4836420p4836572.html
>  To unsubscribe from Invoking a Camel end point deployed in remote Server
> from JUnit test case, click here<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4836420&code=dGF0aGEucm95QGdtYWlsLmNvbXw0ODM2NDIwfC0xNDMwMjA5Njk5>.
>
>


--
View this message in context: http://camel.465427.n5.nabble.com/Invoking-a-Camel-end-point-deployed-in-remote-Server-from-JUnit-test-case-tp4836420p4837929.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Invoking a Camel end point deployed in remote Server from JUnit test case

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Welcome to the Camel community.

What version of Camel are you using?

Does your unit test run in one JVM, and Tomcat in another JMV
(possible on a remote server)?
So what you need to do is a remote communication from JVM to JVM over
the network?


What do you do in this bean, DispatcherServiceImpl ?




On Sat, Sep 24, 2011 at 1:41 PM, tatha <ta...@gmail.com> wrote:
> Hi All,
>
> I am a newbie in Camel and have to deliver a module in a very short notice.
> You know how it is :).My question may be a very basic question but i would
> really appreciate if someone could guide me on it.
>
> The requirement is to invoke a camel endpoint service deployed in a tomcat
> server from a junit test case. The Service has been injected with the
> CamelContext and it has got a set of exposed methods which needs to be
> called.We are using Spring 2.5 and Camel 2 in our project. The Spring config
> is below
>
>
> &lt;bean name="/DispatcherService"
> class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter"&gt;
>        &lt;property name="service" ref="dispatcherService"/&gt;
>        &lt;property name="serviceInterface"
> value="test.DispatcherService"/&gt;
>    &lt;/bean&gt;
>
>        &lt;camelContext id="dispatcherCamelContext" trace="true"
> xmlns="http://camel.apache.org/schema/spring"&gt;
>                &lt;route&gt;
>                        &lt;from uri="direct:dispatcherChannel" /&gt;
>                                &lt;!-- use comma as a delimiter for String based values --&gt;
>                                &lt;recipientList delimiter=","&gt;
>                                &lt;header&gt;serviceEndpoints&lt;/header&gt;
>                                &lt;/recipientList&gt;
>                &lt;/route&gt;
>        &lt;/camelContext&gt;
>
>        &lt;bean id="dispatcherService" class="test.DispatcherServiceImpl"&gt;
>                &lt;property name="context" ref="dispatcherCamelContext" /&gt;
>        &lt;/bean&gt;
>
>
>
> what i am not able to find is to find how can we call the end point uri
> direct:dispatcherChannel deployed in a tomcat server (http://someIP:8080)
> from a junit which uses spring configuration.
>
> Can some one please help me.
>
> Thanking all in advance.
>
> Thanks
> tatha
>
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Invoking-a-Camel-end-point-deployed-in-remote-Server-from-JUnit-test-case-tp4836420p4836420.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/