Accessing facets and services
This topic describes how to access contact facets, interaction facets, and services such as the xConnect Client API in the context of an interaction aggregation processor.
Load facets
The interaction aggregation processing pipeline uses the xConnect Client API to retrieve contacts and interactions. You must specify which contact and interaction facets to retrieve by decorating your processor with one or both of the following attributes:
UsesInteractionFacetsUsesContactFacets
Facets are requested from xConnect when the aggregation pipeline is executed. Only request the facet that a processor requires in order to reduce the impact on performance.
In the following example, the processor loads one interaction facet and one contact facet:
If you do not explicitly request a particular facet, it will not be available during processing. To understand why, read more about the role of expand options when getting contacts and interactions.
Accessing the contact and interaction
The contact and interaction are available on the args.Context property:
If you requested any interaction or contact facets, they can be accessed via the .GetFacet<T> extension method:
Accessing other services
Every processor has access to the following APIs via args.Context.Sources:
- xConnect Client API
- Reference Data Service
- Definition managers
- Taxonomy managers
In the context of an aggregation processor, all service end points - xConnect, definitions, taxonomy, and the reference data service - are read-only.
Accessing xConnect
A read-only instance of the xConnect Client API is accessed via args.Context.Sources.Collection. You can search or get contact and interaction data:
Remember that the contact and interaction are available via args.Context.Contact and args.Context.Interaction respectively.
Accessing definition managers
There is no generic definition manager, which means that you must know which type of event you are looking for and use the appropriate definition manager.
Accessing taxonomy managers
There is no generic taxonomy manager, which means that you must know which type of taxonomy you are looking for and use the appropriate taxonomy manager.
Accessing the reference data service
The aggregation pipeline uses a read only version of the Reference Data Service API that connects directly to the Reference Data Service database.