Salesforce uses JKS files to store information about the valid certificates used for API communication. The challenge is that JKS is not a format very common in the .net applications – we more often use certs in PKCS12 format.
How to convert JKS file to PKCS12 file?
Before you start conversion it is good to verify if JKS file contains only one certificate – the one you need. To verify what is inside the JKS file you can use “KeyStore Explorer” application that you can download here.
When you open the JKS file with KeyStore Explorer you will see something like this:
In my case the keytool is available in the path: C:\Program Files\ojdkbuild\java-1.8.0-openjdk-1.8.0.232-1\bin\keytool.exe
When you find the keytool you can run the following command to convert jks into pkcs12 file:
One of the customers had Sitecore 10 initial release installed on Production – everything was working fine till they started adding many new languages and visibility rules to the content they create – in other words they have started to use Sitecore XP in full scale, with personalization etc.
At the beginning everything was working fast and smothly but after few more languages and few more rules added, everything slowed down and editors had to wait aroud 30-60 seconds to load Sitecore Experience Editor and sometimes more complex pages were even able to stop the IIS.
I had an ‘opportunity’ to found another case that later was identified by Sitecore Support as known issue with fix number: SC Hotfix 530937-1 (please contact Sitecore Support to get code of it).
Explanation of the issue
Sitecore has very advanced mechanisms checking what exactly should be shown to the visitor and when. Some of the checks are:
check of the date and time when component should be shown
check of the personalization rules when component should be shown
check of user permissions to display/change every component
As you see I emphasize ‘component’ in every aboves point – I do that because complex pages with many components have to run those checks so many more times to show you the page that it significantly increase time of page loading in the experience editor – where you do not have cache enabled.
I was debugging for a while and found this tool as the source of low performance:
It allows to change the date and verify how the website would looks like for certain date – with all applied rules/filters.
The tool seems to use Sitecore.Pipelines.FilterItem.GetPublishedVersionOfItem, Sitecore Kernel processor to prepare data to display it in the experience editor.
I replaced this processor with my one to verify how many times it is called and what operations are being made there and I was shocked with hundreds of requests and checks that are triggered by this processor.
I decided to remove it from the pipeline with code:
And after the patch was applied I immediately noticed that Experience Editor has started to load quickly again (I mean as fast as it is possible for Experience Editor – around 5s).
So, if you also experience very low Experience Editor performance you can try to apply that change and check if it helped – if yes, then I would suggest to contact Sitecore Support and get the official patch.
Based on the title – the topic seems to be pretty simple as Sitecore has prepared really great documentation about the shards but in this article I will try to describe scenario when we want to get the data from shards with direct connection to the database instead of using Sitecore’s libraries like xConnect etc.
As an example I will show you how to get the latests interactions saved into database. Usually to do that you need to know the contact id and query for the data via xConnect but not this time. I will explain everything very soon.
Documetation
Sitecore team has prepared few documetation pages describing how the data from shards is consumed.
Now, imagine that you do not have contact id or you just do not care about the contact data because you want to get the latest interactions that happened with the website – like goals or page visits. How to get that data without having contact’s reference?
The solution
To start we must use database connection – in our case it will be connection to the xdb collection database.
Then to work with the shards we are going to use two libraries:
When we have loaded shard map we can start query for the data – to connect to shard we must use sql connection string builder and then with that builder we can connect to the ‘part’s of the shard’.
var builder = new SqlConnectionStringBuilder(...your connection string...);
using (var conn = new MultiShardConnection(myShardMap.GetShards(), $"User ID={builder.UserID};Password={builder.Password};"))
{
using (MultiShardCommand cmd = conn.CreateCommand())
{
cmd.CommandText = "SELECT * FROM [xdb_collection].[Interactions]";
cmd.CommandType = CommandType.Text;
cmd.ExecutionOptions = MultiShardExecutionOptions.IncludeShardNameColumn;
cmd.ExecutionPolicy = MultiShardExecutionPolicy.PartialResults;
using (MultiShardDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
var interactionId = sdr.GetGuid(0);
var lastModified = sdr.GetDateTime(1);
.........
var campaignId = (sdr[10] as Guid?).Equals(null) ? null sdr.GetFieldValue<Guid?>(10);
.....
}
}
}
}
Why did I write about the parts of the shard when there is no loop iterating through the shards? Well, all that happens inside the Azure’s library. It means that depends on the number of the parts we will call the same query as many times as many shards we have. Because of that it will be much harder to maintain the number of results that we want to receive.
If we want to limit our results to 100 in fact the final result can be 200 because limit of 100 will be applied for every query called to every shard part. Despite that – it is just like a normal SQL query and it can be very helpful from time to time.
Summary
In general it is worth to member that this solution belongs to the ‘hacks’ category and if it is not required it is much better to use Sitecore’s library to work with xConnect models in the safe and well documented way. If you already tried to use it and it is not something that solves your issues then I hope that the concept of accessing database shards will save your life like it saved my – at least once so far. Good luck!
This website uses cookies to improve your experience. Ok
Privacy & Cookies Policy
Privacy Overview
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.