On 7 Dec 2007, at 03:37, Chiradeep_Banik wrote:
Hi Michele,
Thank you very much. I have 2 more queries:-
1. onComplete() call back method:-
The webservice server would send response and callback method
onComplete() would be called everytime a response is received. If
the processing logic implemented in onComplete() (like XML
parsing , database transactions) take a bit long to execute, would
it mean response message objects received from server would pile up?
Yes.
Can this cause any issue with memory, performance etc?
It depends (I'm talking about performance). If responses are
independent (and onComplete() includes some I/O such as transactions)
than it makes sense to use a thread pool and process responses
concurrently.
Anyway, I can move the processing logic to a different class and
create objects of the new class everytime a response comes. Do you
see any issue with this approach?
public void onComplete() {
this.received.incrementAndGet();
// eventually do something here
if (isComplete()) {
synchronized(lock) {
lock.notify();
}
}
}
2. I am planning to use Axis2 version 1.3. Callback implementation
with this version is a bit different and the generated code (from
Axis2 WSDL2Java) creates a stub and a callback class where I can
implement the processing functionality.
I had to increase the setTimeOutInMilliSeconds() parameter in my
generated stub to receive long running requests from the server.
Previously my client was not able to catch long running
requests .Is this correct?
Yes.
Michele
Thanks and Regards,
Chiradeep
-----Original Message-----
From: Michele Mazzucco [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 06, 2007 9:20 PM
To: [email protected]
Subject: Re: Query about AXIS2 1.3 asynchronous web service
On 6 Dec 2007, at 09:40, Chiradeep_Banik wrote:
>
> Thank you for your response Michele.
>
> My project requirement is:-
>
> 1. Make multiple, almost simultaneous calls for e.g. 1000 to the
> web service server.
OK, use a single ServiceClient/OperationClient object to send all
your requests.
>
> 2. The server would take some time (could be hours) to send the
> response back and on receipt of the response client would process
> the response data received. The client has no further job after
> sending request to server to be done.
>
> On this requirement, I thought of using asynchronous web service
> interface to the server as provided by Axis2.
>
> Axis2 would use callback mechanism and polling mechanism to track
> when the response is received. So does this mean that all my 1000
> client threads would be alive and in memory unless a response comes
> back from server? Until the client receives a response from server,
> the client has nothing to do in my case.
There's no need to create 1000 callback objects - one will be enough:
public class Sender {
final int toSend = 1000;
final Object lock = new Object();
class MyCallback implements Callback {
private AtomicInteger received = new AtomicInteger(0);
// implement onFault, onError and onMessage
public boolean isComplete() {
return toSend == this.received.get();
}
public void onComplete() {
this.received.incrementAndGet();
// eventually do something here
if (isComplete()) {
synchronized(lock) {
lock.notify();
}
}
}
}
public void sendMessages() {
MyCallback callback = new MyCallback();
// create ServiceClient and send your messages here
for (int i = 0; i < toSend; i++) {
// create message
sender.sendReceiveNonBlocking(message,
callback);
}
// now wait
while (! callback.isComplete()) {
try {
synchronized(lock) {
lock.wait();
}
} catch (InterruptedException e) {
Thread.interrupted();
} finally {
sender.cleanup();
}
}
}
}
>
> In case of a JMS/MQ interface, I can create 1000 requests and put
> them in the queue and my JMS listener can pick up those responses
> once they start arriving. In this case, client would fire a request
> to server and would not keep waiting for response. Can this kind of
> functionality be implemented with Axis2 asynchronous web service?
See above. BTW you can use Axis2 + JMS as well.
>
> I would appreciate any implementation suggestion on my requirement.
>
> Thanks and Regards,
>
> Chiradeep
HTH,
Michele
>
>
> -----Original Message-----
> From: Michele Mazzucco [mailto:[EMAIL PROTECTED]
> Sent: Thursday, December 06, 2007 3:11 AM
> To: [email protected]
> Subject: Re: Query about AXIS2 1.3 asynchronous web service
>
> Chiradeep,
>
> where's the problem?, JMS listeners run in separate threads as well.
> Are you worried about the sleep() call? If so, it's only because the
> main thread has to wait until the response has been received before
> exiting - in the meantime the main thread could accomplish other
> tasks as well.
>
> Michele
>
> On 5 Dec 2007, at 14:51, Chiradeep_Banik wrote:
>
>>
>> Hi,
>>
>> I am new to web service and AXIS2 engine. I have a basic doubt
>> about the asynchronous web service AXIS2 provides. Does it provide
>> a complete asynchronous communication? I have seen the following
>> code in AXIS2 site, the client basically waits until a response
>> comes from server. Comparing this with JMS/MQ communication, the
>> client does not wait when a message is put in the queue and a
>> seperate a seperate MDB picks up the response when send by server.
>>
>> try {
>> OMElement payload = ClientUtil.getEchoOMElement();
>>
>> Options options = new Options();
>> options.setTo(targetEPR);
>> options.setTransportInProtocol
(Constants.TRANSPORT_HTTP);
>> options.setUseSeparateListener(true);
>> options.setAction("urn:echo"); // this is the action
>> mapping we put within the service.xml
>>
>> //Callback to handle the response
>> Callback callback = new Callback() {
>> public void onComplete(AsyncResult result) {
>> System.out.println(result.getResponseEnvelope
());
>> }
>>
>> public void onError(Exception e) {
>> e.printStackTrace();
>> }
>> };
>> //Non-Blocking Invocation
>> sender = new ServiceClient();
>> sender.engageModule(new QName
>> (Constants.MODULE_ADDRESSING));
>> sender.setOptions(options);
>> sender.sendReceiveNonBlocking(payload, callback);
>> //Wait till the callback receives the response.
>> while (!callback.isComplete()) {
>> Thread.sleep(1000);
>> }
>> //Need to close the Client Side Listener.
>> } catch (AxisFault axisFault) {
>> axisFault.printStackTrace();
>> } catch (Exception ex) {
>> ex.printStackTrace();
>> } finally {
>> try {
>> sender.cleanup();
>> } catch (AxisFault axisFault) {
>> //have to ignore this
>> }
>> }
>>
>>
>> Can somebody share with me a sample asynchronous web service client
>> code using AXIS2 1.3?
>>
>> Thanks and Regards,
>>
>> Chiradeep
>>
>> **************** CAUTION - Disclaimer *****************
>> This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION
>> intended solely for the use of the addressee(s). If you are not the
>> intended recipient, please notify the sender by e-mail and delete
>> the original message. Further, you are not to copy, disclose, or
>> distribute this e-mail or its contents to any other person and any
>> such actions are unlawful. This e-mail may contain viruses. Infosys
>> has taken every reasonable precaution to minimize this risk, but is
>> not liable for any damage you may sustain as a result of any virus
>> in this e-mail. You should carry out your own virus checks before
>> opening the e-mail or attachment. Infosys reserves the right to
>> monitor and review the content of all messages sent to or from this
>> e-mail address. Messages sent to or from this e-mail address may be
>> stored on the Infosys e-mail system.
>> ***INFOSYS******** End of Disclaimer ********INFOSYS***
>>
>>
---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]