Skip to main content

Http Client RA

16 replies [Last post]
abhayani
Offline
Joined: 2005-04-04

Hi Guys,

Here is the design page for HTTP Client RA for Mobicents
http://groups.google.com/group/mobicents-public/web/mobicents-http-clien...

Please provide your valuable feedback on design.

amit.bhayani

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
abhayani
Offline
Joined: 2005-04-04

Hi Guys,

The final version of http-client-ra is ready
To know more about http-client-ra look at link
http://groups.google.com/group/mobicents-public/web/mobicents-http-clien...

A very simple example using http-client-ra is ready, to check out follow the link
https://mobicents-examples.dev.java.net/source/browse/mobicents-examples...

Example (SBB) is a simple Service which reads the RSS Feed URL (specified in sbb-jar.xml) using ROME api (https://rome.dev.java.net/)
For each link present in parsed RSS Feed, SBB uses http-client-ra to send the Request Asynchronously and just displays the Response when it arrives.

SBB uses timer facility to periodically check if there are any update in RSS Feed link and if there are updates it retrieves the content for each link present in RSS Feed.

amit.bhayani

crisbergua
Offline
Joined: 2007-11-05

Hi,

I'm trying to test the HttpClient RA using "Mobicents 1.0.03.GA" and this httpclientra-example, but i'm having some problems...
I launch mobicents, then i deploy the httpclient ra which is inside resources folder, and finally i try to deploy the example which i have stored in mobicents/examples but it doesn't work.
I suppose i have to change build.xml but i don't know if it's only a dependencies problem or maybe it's not possible to test the example with 1.0.03.GA.

Thanks in advance
Regards

abhayani
Offline
Joined: 2005-04-04

What is the error that you are getting?

crisbergua
Offline
Joined: 2007-11-05

Compiling errors related with mobicents-ant-common-service.xml,

But i using Mobicents 1.0.03.GA there's no xml folder with this xml and others... so do i have to check and move all these files?

abhayani
Offline
Joined: 2005-04-04

Aah right httpclientra-example is using mobicents-ant-common-service.xml and as of now its not shipped with binary.

I believe it would be much easy for you to check out the Mobicents source and Mobicents-examples source and work on it if you want to use httpclientra-example

Else you will have to modify the httpclientra-example/build.xml if you port it to Mobicents Binary. You can refer the call-controller2 or googletalkbot example. The build file should be able to create the deployable jar file.

crisbergua
Offline
Joined: 2007-11-05

Ok thanks!

I'll try to port it then

eduardomartins
Offline
Joined: 2005-10-10

I recommend to go instead for the building of mobicents and mobicents-examples sources, messing with ant scripts may consume a lot of precious time

crisbergua
Offline
Joined: 2007-11-05

Hi again,

I've tried using the sources but there are still some problems deploying the example:

Target management-init doesn't exists in HttpClientRAExample, used for "undeploy". I've modified this part,



and i have also add these pathelements

Now the deploy is successful but there's a WARNING!!! about Mobicents tools...ant tasks and cli must be compiled.

Anyway, console shows a IOException, java.net.UnknownHostException: rss.cnn.com

abhayani
Offline
Joined: 2005-04-04

My bad, I have removed depends="management-init" from my local file but never checked in :(
Thanks for pointing out that.

You don't have to add all those ra related jar files to
.
takes care of that. Just make sure that
pointing to right mobicents (src) and /mobicents/ra/http-client-ra has the necessary jar files (just call ant and it will create jar as well as deploy the RA)

Also the default target for build is deploy now so that you just have to call ant

>>Anyway, console shows a IOException, java.net.UnknownHostException: rss.cnn.com
Are you connected to net? If you open HttpClientRAExampleSbb.java it looks for a 'RSSFeedURL' as env property that is specified in HttpClientRAExample-sbb-jar.xml

The functionality of SBB is such that it uses timer facility to peridoically check if there are any update in RSS Feed link and if there are updates it retrieves the content for each
link present in RSS Feed.

Look at /httpclientra-example/README.txt. Hope that clears all your doubts

amit.bhayani

eduardomartins
Offline
Joined: 2005-10-10

1) I think the client should be private stuff of the RA, you don't an SBB to shut it down do you? :-)

2) Try to provide a clean interface similar to the underlying API.

3) I prefer the async method in the client activity, so you need to create the activity first, then get it's aci and attach the local object, and finally call the executeMethod()

My proposal (from 1,2 & 3) would be:

HtttClientRA sbb interface {
public int executeMethod(HttpMethod method);
public HttpClientActivity createActivity();
}

HttpClientActivity interface {
public void executeMethod(HttpMethod);
public void endActivity();
public void setEndOnReceivingResponse(boolean value);
public boolean getEndOnReceivingResponse();
}

HttpClientResponseEvent interface {
// the int that returns in sync executeMethod()
public int getExecuteMethodInt();
public HttpMethod getHttpMethod();
public Exception getException();
}

4) What about http session data on the activity, it would be nice to have that.

abhayani
Offline
Joined: 2005-04-04

Thanks Eduardo,

For pts 1 and 2 I was bit confused whether to expose the api directly or create an interface for HttpClient, but I agree with your point.

3) Ok

4) Step by Step. I am getting the design ready for initial stuff, will add Session functionality once the initial design looks good.

Will modify the wiki page.

ivelin
Offline
Joined: 2003-07-13

the latest page looks nice.

i) I'd change getHttpMethod to createHttpMethod

ii) Question : Is it better to expose the HttpClient directly or HttpClientResourceAdaptorSbbInterface should expose the individual methods of HttpClient?

What could be a disadvantage of exposing the apache class directly? On the other hand how many of its methods are practically used? If only a few, then its clearly better to provide an RA Type wrapper

abhayani
Offline
Joined: 2005-04-04

Thanks for feedback Ivelin

i) Ok 'createHttpMethod' sounds better

ii) The confusion I had was if we provide RA Type Wrapper then as and when HttpClient interface changes and we upgrade the libraries, the SBBInterface code also will change. The reason why I felt this is because in HttpClient 3.1 version I see lot of deprecated methods which will go off soon.

As per my experience not all of available methods of HttpClient will be used and the one which will be used often are

HttpClientParams getParams()
HttpState getState()
void setParams(HttpClientParams params)
void setState(HttpState state)

http://jakarta.apache.org/commons/httpclient/apidocs/index.html?org/apac...

SBBInterface can expose above listed methods only as of now and if community feels that it needs to expose more methods we can do that latter.

Disadvantage of exposing the apache class directly is developer can directly call HttpClient.getHttpConnectionManager().getConnection(HostConfiguration hostConfiguration).close() to close the socket.

amit.bhayani

ivelin
Offline
Joined: 2003-07-13

> As per my experience not all of available methods of
> HttpClient will be used and the one which will be
> used often are

so I thought

>
> HttpClientParams getParams()
> ttpState getState()
> void setParams(HttpClientParams params)
> void setState(HttpState state)
>
> http://jakarta.apache.org/commons/httpclient/apidocs/i
> ndex.html?org/apache/commons/httpclient/package-tree.h
> tml
>
> SBBInterface can expose above listed methods only as
> of now and if community feels that it needs to expose
> more methods we can do that latter.

I'm with you.

>
> Disadvantage of exposing the apache class directly is
> developer can directly call
> HttpClient.getHttpConnectionManager().getConnection(Ho
> stConfiguration hostConfiguration).close() to close
> the socket.

scary.

abhayani
Offline
Joined: 2005-04-04

Ok made the modifications and checked in the first round of code
https://mobicents.dev.java.net/source/browse/mobicents/ra/http-client-ra/

There are no test case as of now, how ever RA gets deployed without problems.

Made changes to class diagram
http://groups.google.com/group/mobicents-public/web/mobicents-http-clien...

One more change is added Response class which acts as wrapper over response part of HttpMethod. This is because once httpMethod.releaseConnection(); is called http.getResponseBody(); returns null.

Also http client ra makes use of java.util.concurrent.* from JDK 5 to achieve asynchronous behavior hence http client ra will work only with JDK 5. I guess that shouldn't be a problem.

amit.bhayani

ivelin
Offline
Joined: 2003-07-13

looks good!

a few tests are in order.