Fluent Commerce Logo
Docs
Sign In

commercetools Customer Sync

Feature

Changed on:

31 Jan 2024

Overview

Customer Sync is responsible for synchronizing customers from commercetools to Fluent.

Key features

  • Automatic detection and synchronization of customers Created/Modified.

Detailed Technical Description

Sync Type

Automatically by the system

Customers are added to the external message queue, and a dedicated message connect-sdk consumer will handle the message and export the data to Fluent.

No alt provided

CT Queue: Any customer creation/modification will be pushed to ct-queue using commercetools subscriptions. Out-of-the-box(OOTB) connector uses AWS Event Bridge, and it is possible to implement with other queues/subscriptions supported by Commercetools. More details on commercetools subscription.

CT Queue Listener: This class reads the message from CT-Queue and pushes it to the Event queue.

Event Queue: The event queue is responsible for holding the event message to be processed further.

Message Router: It will read the message name from the Event queue and pass it to the appropriate handler.
i.e. in case of customer changes, the message

`typeId`
will be  “customer“  , and the route will be “
`commercetools.connect.customer.upsert`
“.

Customer Updates Handler: This will be a class that reads message data from the internal queue and, based on the customer identifier, fetches more information from Commercetools-SDK ( The core commercetools SDK, which interacts with commercetools APIs ) and maps them with Fluent data model and pushes it to Fluent OMS.

The message handlers are fully extensible. Partners can make the changes as per their requirements. The connect-sdk allows message routing with flexible message handlers to process and transform data moving from a source to a destination. Partners can change the message names and override the classes.

Example to extend the functionality

Partners can override existing handlers using application-connector.yml and Handler class. To change the logic of the Category Upsert handler first go to

`commercetools-connector/src/main/resources/application-connector.yml`
 and replace the “handler” under routes > name > handler node.

1- route: "commercetools.connect.customer.upsert"
2     props:
3       name: "customer"
4       inclusion-filter:
5          - "ResourceUpdated"
6          - "ResourceCreated"

Language: json

Name: application-connector.yml

Description:

[Warning: empty required content area]

we can also add new handlers as well by just adding them in 

`application-connector.yml`

Create a new Handler that extends 

`MessageHandler`
 and ensure that your package is under the main SDK package 
`com.fluentcommerce.connect`
, for example: 
`com.fluentcommerce.connect.custom.commercetools.handler.message.<your-handler>.java`
. For more details on how to extend please refer to the extend guidelines.

1@Slf4j
2@Component
3@HandlerInfo(name = "FluentCustomerUpsert")
4public class FluentCustomerCreateHandler extends MessageHandler {
5    private static final String CUSTOMER_ATTRIBUTE = "customer";
6    // write your logic
7}

Language: json

Name: <your-handler>.java

Description:

[Warning: empty required content area]
Automatic Delta Sync

This is an automated synchronization that runs in the background to keep Fluent up to date. This synchronization is based on subscriptions. Out of the box, we are supporting 

`ResourceCreated`
 and 
`ResourceUpdated`
 messages. Please refer commercetools Customer Messages for more information on supported messages.

Customer APIs and Payloads
CT CUSTOMER API
  • GET : {{host}}/{{project-key}}/customers
  • GET : {{host}}/{{project-key}}/customers/{{Customer-id}}
CUSTOMER MESSAGE PAYLOAD

The Message Payload in CT-queue

1{
2  "notificationType": "Message",
3  "projectKey": "fluent-ct-dev",
4  "id": "85c1c53e-75c8-413a-b8f5-08701292486e",
5  "version": 1,
6  "sequenceNumber": 3,
7  "resource": {
8    "typeId": "customer",
9    "id": "14a4ef54-957d-4148-b0be-de8d0fbc411d"
10  },
11  "resourceVersion": 3,
12  "resourceUserProvidedIdentifiers": {},
13  "type": "CustomerDeleted",
14  "createdAt": "2022-07-27T06:11:11.021Z",
15  "lastModifiedAt": "2022-07-27T06:11:11.021Z"
16}

Language: json

Name: The Message Payload in CT-queue

Description:

[Warning: empty required content area]

Copyright © 2024 Fluent Retail Pty Ltd (trading as Fluent Commerce). All rights reserved. No materials on this docs.fluentcommerce.com site may be used in any way and/or for any purpose without prior written authorisation from Fluent Commerce. Current customers and partners shall use these materials strictly in accordance with the terms and conditions of their written agreements with Fluent Commerce or its affiliates.

Fluent Logo