Thanks Emmanuel;
Sorry for the late response. Other priorities came in, I just had chance to
work on this again, Just to recap, you told me if Mina application is using
another application for lengthy operations operations(>1000ms), I don't need
to sit and wait for the response, I can do it asynchronously and grap the
session and write the response in it when response comes back from other
server.
Is there any build in methods in API to handle this scenario. I am thinking
about making calls asynchronously using a FutureTask, and keeping the
session and futuretask in a application level hashmap. I'll probably check
every element of hashmap everysecond to see if they are complete, whenever I
see a complete response, I will write it back to the associated session and
will delete it from the hasmap. Following is a sample that I provided, do
you think that this is a good approach?
ExecutorService es = Executors.newFixedThreadPool(1);
FutureTask <Message> future = new FutureTask<Message>(
new Callable<Message>()
{
public Message call()
{
try {
return
Util.sendSynchAndWait(voidMessage,30000);
} catch (SyncTimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
} catch (JMSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
}
);
es.execute(future);
//Pseudo code to save the futuretask and session into a hashmap
MapEntry me = new MapEntry(future, session);
asyncMap.add(key,me);
On Mon, Mar 29, 2010 at 8:06 PM, Emmanuel Lécharny <[email protected]>wrote:
> On 3/30/10 1:21 AM, Erinc Arikan wrote:
>
>> Unfortunately I can't lower that processing time, application is supposed
>> to
>> authorize credit card transactions, and to do that it needs to make remote
>> calls to a credit card authorizer system and that's taking around 1000 ms
>> on
>> average. So I guess I will give the new settings a try tonight, and will
>> write a small test application to test that.
>>
> You may want to do that asynchronlously, instead of waiting for the
> response.
>
> MINA is perfect for that.
>
> When the response from the remote server arrives, then you grab the
> associated session, and write the response to the client. No more problem
> with the number of clients you can handle in parallel...
>
>
> --
> Regards,
> Cordialement,
> Emmanuel Lécharny
> www.nextury.com
>
>
>