Question

I'm looking for the best solution to solve this problem :

I have a client and a server.

The client sending request to the server using the call.invoke method. The call for now is synchronous and waiting for the answer.

The time is taking to receive the replay from the server under load is around 1 sec(this is a lot of time).

at the client side we are generating requests around 50-100 request per second , the queue is exploding.

For now i just created a thread pool that will work asynchronous and will send the requests to the server per thread , but the request it self will be synchronous.

The meaning of that is that the thread pool should maintain ~100 threads if we do want that it will work fine.

I'm not sure this is the best solution.

I also was thinking to create somehow 1 thread that will send the requests and 1 thread that will catch the replays, but then i'm afraid that i will pass on the load to the server side.

Few things that are importent:

We cannot effect the code on the server side and we cannot control the time it takes to receive a replay.

while receiving the replay we just use this data to create another data structure and pass it on - so the time stamp is not relay importent.

we are using axis api.

any idea of how is it the best way to solve it? the thread pool of the 100 thread seems fine ? or there some other ways?

Thanks!

Was it helpful?

Solution

You can call axis service using non-blocking client way by registering the callback instance.

Client class:

ServiceClient sc = new ServiceClient();
Options opt= new Options();

//set the target EP
opt.setTo(new EndpointReference("http://localhost:8080/axis2/services/CountryService"));
opt.setAction("urn:getCountryDetails");
sc.setOptions(opt);



sc.sendReceiveNonBlocking(payload, callBack);

// inner class with axisCallback , overide all its methods. onMessage get called once result receive from backend

AxisCallback callBack = new AxisCallback() {

@Override
public void onMessage(MessageContext msgContext) {
    System.out.println(msgContext.getEnvelope().getBody().getFirstElement());
    //this method get called when you received the results from the backend
}
...
}

Reference for writing axis service : http://jayalalk.blogspot.com/2014/01/writing-axis2-services-and-deploying-in.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top