Skip to main content

Working with Microservices

Causal is designed to work well with a microservices architecture.

We expect that in such a system, the impression content may be created inside one microservice, and various API calls regarding that impression may occur in other microservices. Causal's impression servers will collect all that information and integrate it in your data warehouse using your existing identifiers.

Getting the Session

Once a session is created, you can get a handle onto it using the persistent key or any of the session keys that you specify in your session block.

We anticipate that these keys will be what your current microservices use to coordinate a user's session. So, if we are in a microservice and would like to interact with a user's session, we just use the identifier that we have on hand with the session key class methods:

SessionRequest s = SessionRequest.fromArrivalId("testArrivalId");

Distributed Events

Once you have the SessionRequest object, you may signal session events and change mutable values as normal.

If you'd like to signal events on an impression or fill in some external outputs, we also provide static methods to do that using an impression id instead of the impressions request object.

For example, to signal an impression click in a microservice other than the one that created the impression:

SessionRequest s = SessionRequest.fromArrivalId("testArrivalId");
SimpleRequest.signalClick(s, impressionID, 10);

Where impressionID is the impression identifier that the original microservice used to create the impression.