Can a piece of code read from multiple Kentico Installations at the sametime?

Tomaso Pye asked on May 20, 2015 22:17

I have a WCF service that engages the CMSApplication and reads Banners from Kentico, converts them into pocos and then sends them back to the caller. Our original intention was to have multiple sites backed by a single Kentico DB. In this case, a caller could specify the site for which it wanted to retrieve banners.

We discovered that certain requirements caused each site to need its own DB. My service still needs to be able to pull Banners from Kentico, according to the site specified by the caller. I'd like to keep using CMSApplication if possible, but I am not really seeing anything that looks like I can have more than a single instance of Kentico active in my service at a time.

Is there any way to keep 3 instances of CMSApplication, with different connection strings, alive in a single AppDomain?

Recent Answers


Brenden Kehren answered on May 21, 2015 01:16

Can you take advantage of the RESTful services offered in v8 or not?

If not what you'd need to do is add references to the DLLs needed in your WCF service that would allow you to call/access that Kentico database using the Kentico API.

0 votesVote for this answer Mark as a Correct answer

Tomaso Pye answered on May 21, 2015 01:29

Hi Brenden, I appreciate the response.

I am already using the DLLs which is fine for a single Kentico DB. However I am going to have 3 active at once, with each request potentially asking for banners from a different DB. There does not appear to be a way to get a handle on the CMSApplication instance to cache it or even specify more than 1 connection string.

Obviously the REST services avoid the issue, as it is just a matter of what endpoint I am calling. I wanted to avoid them however due to the physical architecture of our environments.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 21, 2015 13:25

If you want to call 3 databases at once, you need 3 connections and some sort of event/handler to perform those actions when you say GoGetBanners(). When GoGetBanners() is called then your data access method will know it has to communicate with each server and then merge the results and send them back to you as a single result.

So what I see is a table or config of sorts that holds your connections, you iterate through each of them every time your data access methods are called and simply add any results to a dataset and return that dataset to your business logic with the results of all 3 databases. This would assume you have all the class names the same in all instances of Kentico. Your GoGetBanners() method could pass in similar parameters as what Kentico accepts, ClassName, Where, OrderBy, etc.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.