I am trying to update the contact facet properties using next code (trimmed example)...
var contactManager = Factory.CreateObject("tracking/contactManager", true) as ContactManager;
Contact contact = null;
var lockResult = contactManager.TryLoadContact(contactId);
switch (lockResult.Status)
{
case LockAttemptStatus.Success:
contact = lockResult.Object;
contact.ContactSaveMode = ContactSaveMode.AlwaysSave;
default:
contact = null;
}
if (contact != null)
{
// update contact properties.
contactManager.SaveAndReleaseContact(contact);
}
While I am doing this, the contact is in active engagement flow.
After I updated the contact and the method contactManager.SaveAndReleaseContact(contact)
was called, I am trying to execute a trigger in the engagement flow for this contact.
And it does not work because the contact is still locked.
I can see log message:
ERROR Sitecore.Analytics.Automation.AutomationContactManager: Cannot obtain lock on contact: 64dec422-f08d-4932-8369-7313d60b530f. Status: AlreadyLocked
So the question is.. how to make sure the contact is successfully released?
I can also see there are overloads for TryLoadContact
method:
contactManager.TryLoadContact(Guid contactId);
contactManager.TryLoadContact(Guid contactId, bool exclusive);
contactManager.TryLoadContact(Guid contactId, int lockDurationMinutes);
contactManager.TryLoadContact(Guid contactId, int lockDurationMinutes, bool exclusive);
Does anyone know what the bool exclusive
means and the int lockDurationMinutes
?
that int lockDurationMinutes
- will it release the lock once the specified minutes passed?
how and when we can use the bool exclusive
option?
Is there a way to release the contact on demand?