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

Problem facing during communication between the two stores

Started by kkdubey042@gmail.com, January 20, 2017, 09:23:55 am

Previous topic - Next topic

kkdubey042@gmail.com

Hi Team,

We have purchased konakart 8.3.0.0 EE version 1 liscence this month. and we are in customization and setup phase where we are facing some problems in case of Multi Store - single DB - Shared customer - shared product mode.

We have taken the two kkeclipse generated from the installation folder using build commands and trying to achive the setup as described below:

1) setup of kkeclipse with custom changes                                    2)Setup of same kkeclipse with custom changes.

As discussed with already with Konakart team via mail before purchasing, they told that multiple stores can run on multiple servers but the stores should use the single KKEngine using JSON API, so to do the same we have  enabled the JSON API call in both the store considering one will act as store as well as Engine and other setup will talk to the first store KKEng. So in this way we are not able to use the Managers like CustomerMgrIf,SecurityMgrEE,etc  in store second store setup which is running in different server internally uses the JSON API to talks with the first setup which is running on another server.

In this type of setup to customize certain functionality of storefront we are using  in both the setups below code

KKBasePeer.executeQuery(""), so in this is causing below Exception:

19-Jan 21:29:40 WARN  (?:getConnection:?) Database Connection Failed : Torque is not initialized
org.apache.torque.TorqueException: Torque is not initialized
   at org.apache.torque.TorqueInstance.getConnection(Unknown Source)
   at org.apache.torque.Torque.getConnection(Unknown Source)
   at com.konakart.db.KKBasePeer.executeQuery(Unknown Source)
   at com.konakart.db.KKBasePeer.executeQuery(Unknown Source)
   at com.konakart.db.KKBasePeer.executeQuery(Unknown Source)

This exception is coming in second setup which is calling the KKEng of first setup using JSON API, but if we access the same code from the first setup where engine is running, its executing proper.

If anyone face the same problem and got the solution please posts here..

julie

Looks like there's a bit of confusion....

When in the mode Multi Store - single DB - Shared customer - shared product mode, you have a single (or load balanced) KonaKart installation pointing to a database cluster. If you are communicating with KonaKart through JSON from a Java client, then all API calls are through KKJSONEng or KKJSONAdminEng and when you instantiate the engine in order to make an API call, you pass an EngineConfig object which includes the id of the store that you want to access.

There are many examples under the java_api_examples directory.


kkdubey042@gmail.com

Julie thanks for your reply,

1)Actually we want to use the existing store front given by konakart as it is with some customization in two different servers. As per your license agreement we can not use two KKEng on two different servers with the single license so with the help of JSON API we are using single Engine and we are pointing both the store fronts which are deployed on different servers to the same Engine. So in storefronts we have used the below statement which is causing exception.

KKBasePeer.executeQuery("Query")

For more clarity, how we have our server setups I have attached the image file, please find attachment.

2)Moreover with the same setup, if a user logs in one store front  and if another user tries to login on another store the first store loggedin user is getting logged out. Please clarify this too..





julie

First of all I assume setup B is OK since it's a default installation.

You need to :

  • Enable JSON on server B since A will be communicating to B via JSON

  • In A you have to edit webapps\konakart\WEB-INF\classes\konakart_app.properties so that it uses KKJSONEng instead of KKEng.

  • In A you have to edit webapps\konakart\WEB-INF\classes\konakart.properties to point konakart.json.engine.url to the URL of the JSON servlet in B since the JSON requests have to be sent to B.

  • In BaseAction.java of A in the method getStoreIdFromRequest() you should always return the store id that A needs to access so that when the request is sent to B, it will contain a reference to the store against which the API call needs to be run.


I don't understand what you mean by KKBasePeer.executeQuery("Query") since this is code that can only run in the B engine when you customize a manager or in the OrderIntegrationMgr of B.

kkdubey042@gmail.com

Enable JSON on server B since A will be communicating to B via JSON

We have already enabled the JSON on server both the servers in web.xml file.

In A you have to edit webapps\konakart\WEB-INF\classes\konakart_app.properties so that it uses KKJSONEng instead of KKEng.

We have changed below propertie in server A konakart_app.properties:
konakart.app.engineclass=com.konakart.json.KKJSONEng


In A you have to edit webapps\konakart\WEB-INF\classes\konakart.properties to point konakart.json.engine.url to the URL of the JSON servlet in B since the JSON requests have to be sent to B.

We have edited below properties in server A konakart.properties:
torque.database.default                     = store2
konakart.KKEngIfImplClassName   = com.konakart.json.KKJSONEng
konakart.app.json.engine.classname = com.konakart.json.KKJSONEng
konakart.json.engine.url = http://localhost:8082/nbStore/konakartjson

In BaseAction.java of A in the method getStoreIdFromRequest() you should always return the store id that A needs to access so that when the request is sent to B, it will contain a reference to the store against which the API call needs to be run.

From server A In BaseAction getStoreIdFromRequest() always returns store2 and BaseAction getStoreIdFromRequest() returns store1 in server B always.

After doing the above all four mentioned things, still if two different user tries to login in the two different stores then the user who logged in first store gets logged out when user in second store logs in.

I don't understand what you mean by KKBasePeer.executeQuery("Query") since this is code that can only run in the B engine when you customize a manager or in the OrderIntegrationMgr of B.

We are using KKBasePeer.executeQuery("Some SQL Query") statement in action class itself of server A. So did you mean, we will not be able to user the KKBasePeer in server A.





julie

QuoteWe have already enabled the JSON on server both the servers in web.xml file.


I would only enable B to avoid using A by mistake.

Quote
We are using KKBasePeer.executeQuery("Some SQL Query") statement in action class itself of server A. So did you mean, we will not be able to user the KKBasePeer in server A.


An action class in both A and B does not have direct access to the database. You cannot run SQL from an action class.

QuoteAfter doing the above all four mentioned things, still if two different user tries to login in the two different stores then the user who logged in first store gets logged out when user in second store logs in.


The way you describe it would imply that you can only ever have one user ! This doesn't make any sense to me.