First a little background… In our current Java Services, we have one called “Query”. This service starts up, connects to a Discovery Svc using discovery-client-lightweight at which point we are able to the classes in JARs like content-core, content-broker, etc. to use Content Svc to retrieve our published pages & components from the Broker DB.

Right now for each Broker DB (one per publication target), I’ve found that we need to spin up a separate instance of “Query” because it seemed that the SDL JARs were locked to talk to a single Discovery Svc.

This has worked for us, but as we move into “Cloud” (AWS), we wanted to look into a means for one instance of “Query” to talk to multiple Discovery Svcs. Therefore, over the past few days I looked into this, and I’m pretty certain the limitation is centralized into a single class in the “content-client-api” JAR. The class is ContentClientProvider.

When we start up we use a “cd_client_conf.xml” file that looks like this:

<?xml version="1.0" encoding="UTF-8"?>
     <DiscoveryService ServiceUri="${TridionServiceUri}" />
     <TokenService ClientId="${TridionClientId}" 
         ClientSecret="${TridionClientSecret}" />

And during startup we set TridionServiceUri, TridionClientId, & TridionClientSecret using System.setProperty() – which allows for us to connect to the Discovery Svc.

What I tried to do was spawn 3 worker threads – 1 for each broker – and thread localize the System properties thus permitting the cd_client_conf.xml to have access to 3 configurations, and from our side of the code this worked well as indicated by these log lines (1 per thread) showing different URIs for TridionServiceUri:

2018-09-04 16:49:32,719 DEBUG c.d.e.s.b.t.BrokerThread [BrokerThread.java:80] BrokerService : DiscoveryDao (DevPreview2) : DiscoveryUtils : http://server.<hidden>.com:8282/discovery.svc
2018-09-04 16:49:32,719 DEBUG c.d.e.s.b.t.BrokerThread [BrokerThread.java:80] BrokerService : DiscoveryDao (DevLive) : DiscoveryUtils : http://server.<hidden>.com:8082/discovery.svc
2018-09-04 16:49:32,719 DEBUG c.d.e.s.b.t.BrokerThread [BrokerThread.java:80] BrokerService : DiscoveryDao (DevPreview) : DiscoveryUtils : http://server.<hidden>.com:8182/discovery.svc

However, the startup logging from the SDL JARs shows only this startup line, instead of 3 (one per thread):

2018-09-04 16:49:31,715 INFO c.s.w.c.c.c.i.BaseClientConfigurationLoader [BaseClientConfigurationLoader.java:223] Resolved ContentServiceCapability: ContentServiceCapability{id='DefaultContentService', lastUpdateTime=1534954415067, uri='http://server:8281/content.svc'} using DiscoveryService: http://server.<hidden>.com:8282/discovery.svc.

What I was able to determine even in a scenario with multiple threads, cd_client_conf.xml is read in once and only once via the class ContentServiceClientConfigurationLoader (derives from BaseClientConfigurationLoader).

The loader is used to initialize an instance of ContentClient inside of ContentClientProvider. There appears to be only a single shared instance of ContentClientProvider as indicated by having these lines of code:

ContentClientProvider provider = ContentClientProvider.getInstance();
ContentClient client = provider.getContentClient();

And then looking at the instance IDs of “provider” and “client” in each of the 3 worker threads, you can see that they are the same instance in all 3 threads.

Therefore it appears that the library, content-client-api, as designed is only able to initialize one time and is locked into connecting to only a single Discovery Svc / Content Svc / Broker DB.

As the documentation on this is limited, and lacks a deep dive, I’m wondering if you have any insight into this? Maybe some suggestions as to what to change to get ContentServiceClientConfigurationLoader & ContentClientProvider to be able to initialize multiple instances from multiple threads instead of being locked to a single instances as we’re looking to do?

Thanks, Todd


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.