What i want to do:
- Save and update facet data repeatedly through WebApi
- Read the facet data through WebApi
Everything works fine, until the contact stops being updated. It seems as if, once the inital flush to xDB has happened I will forever retrieve old data and it wont update either.
Saving the data, i'm doing this.
public IHttpActionResult SaveContact([FromBody] dataFromView)
{
if (Sitecore.Analytics.Tracker.Current != null && data != null)
{
var contact = Sitecore.Analytics.Tracker.Current.Contact;
if (contact != null)
{
ICalculatorData customfacet = Tracker.Current.Contact.GetFacet<ICustomFacet>("NameOfCustomFacet");
if (customfacet != null)
{
customfacet.someproperty = dataFromView.updatedproperty;
};
}
return Ok();
}
return BadRequest();
}
The facet:
[Serializable]
public class CustomFacet: Facet, ICustomFacet
{
private const string SOMENUMBER= "SomeNumber";
public decimal SomeNumber
{
get { return base.GetAttribute<decimal>(SOMENUMBER); }
set { base.SetAttribute<decimal>(SOMENUMBER, value); }
}
public CustomFacet()
{
base.EnsureAttribute<decimal>(SOMENUMBER);
}
}
ICustomFacet
public interface ICustomFacet : IFacet
{
decimal SomeNumber { get; set; }
}
I take the same approach when reading the data, only i'm just returning the customFacet instead.
If I clear my cookies and retrieve a new SC_ANALYTICS_GLOBAL_COOKIE id, i'll be able to again save and update the data. Until it keeps returning old data.
Edit: Log Exception: Sitecore.Analytics.Exceptions.ContactLockException Message: Failed to extend contact lease for contact 5d3ad09a-76af-4a3d-98b9-b448d4e3be14
This is happening on my development environment, working as both CM and CD
Anyone who can shed some light onto this issue?