• Welcome to KonaKart Community Forum. Please login or sign up.
 

Slow java api

Started by giacomokk, January 25, 2019, 10:41:10 am

Previous topic - Next topic

giacomokk

Hi, konakart java api calls are really slow.
I instantiate kkAdminEng and kkEng in this way:

KKWSEngIf eng = new KKWSEngIfServiceLocator().getKKWebServiceEng();
KKWSAdminIf adminEng = new KKWSAdminIfServiceLocator().getKKWSAdmin();

Is that correct? If not, can it affect the response speed?
Thanks.
Giacomo

Brian

I don't know why you say the APIs are slow.  If used correctly the KonaKart APIs are efficient and fast.

SOAP, being a relatively heavy protocol, is always going to be a little slower than using POJOs or JSON, but still perfectly fast enough for most purposes.

You shouldn't instantiate your engines in the way you have described.

It's better to instantiate your engines like this:

EngineConfigIf engConfig = new EngineConfig();
engConfig.setMode(EngineConfig.MODE_SINGLE_STORE);
           
KKEngIf engine = new KKWSEng(engConfig);


If you do this you simply code against the KKEngIf which allows you to swap the engine at any time (including at runtime if required).  The implementation details are hidden from you by simply instantiating the engine for the required protocol (in the above case, SOAP).

(The equivalent is true for the KKAdminIf engines).



giacomokk

Hi Brian,

and what is the code if i want to swap to pojos or json?

Thanks.
G

Brian

Simply replace KKWSEng with com.konakart.app.KKEng (for POJO), com.konakart.json.KKJSONEng (for JSON), com.konakart.jws.KKJAXWSEng (for JAXWS) or com.konakart.rmi.KKRMIEng (for RMI) .

EngineConfigIf engConfig = new EngineConfig();
engConfig.setMode(EngineConfig.MODE_SINGLE_STORE);
           
KKEngIf engine = new com.konakart.app.KKEng(engConfig);


You can also instantiate them by name if you wish:

/*
* Instantiate a java JSON Engine by name
* KKEngIf jsonEng = new KKJSONEng(engConfig);
*/
KKEngIf jsonEng = new KKEngineUtils().getKKEngByName("com.konakart.json.KKJSONEng", engConfig);