KonaKart Community Forum

Installation / Configuration => Programming of KonaKart => Topic started by: giacomokk on January 25, 2019, 10:41:10 am

Title: Slow java api
Post by: giacomokk on January 25, 2019, 10:41:10 am
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
Title: Re: Slow java api
Post by: Brian on January 25, 2019, 11:00:27 am
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).


Title: Re: Slow java api
Post by: giacomokk on January 25, 2019, 01:33:35 pm
Hi Brian,

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

Thanks.
G
Title: Re: Slow java api
Post by: Brian on January 28, 2019, 08:15:23 am
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);