Objective

The main objective is to trigger external events so that the users can consume the events as per the requirements.
External events can be triggered to either AWS (Event Bridge), Azure (Event Grid), or GCP (Event Arc). By default, it is Event Bridge.

In this document, you can see:

How to Customize APIs

You can customize the APIs at:

Customizing APIs at the Microservices Level

Add the below annotation in the implementation class if any customization APIs are built by implementing any of the microservices.

Syntax:

@SendEvent(eventType={Name of the event}, identifier={Identifier to fetch from request / response Object})

Note: The naming pattern of the event type should be in the pattern of “/{serviceName}/{entityName}/{actionName}

For example:

@SendEvent(eventType = “accountservice/account/create”, identifier = “response_account.id”) public AccountResponse process (AccountRequest request) { }
In this example, the event type accountservice/account/create denotes the create action in the Accounts service. Also, the identifier response_account.id denotes the account.id has to be fetched from the response object.

Customizing APIs at the SFO and AO Services Level

  1. Create a custom class CamelEventConfiguration for interception to specific route that implement the CamelContextConfiguration interface which contains two methods.
    For example:

    public class CamelEventConfiguration implements CamelContextConfiguration { @Override private void beforeApplicationStart(CamelContext camelContext) { camelContext.getRouteDefinition(“routeAddCustomerAddressRest”).adviceWith(camelContext, new AdviceWithRouteBuilder() { @Override public void configure() throws Exception { onCompletion().toProcess(“resetPasswordExternalEvent”); } }); } private void afterApplicationStart(CamelContext camelContext) {} }
  2. Create a custom process class CreateCustomerEvent and auto wire EventUtil in the class inside the process class. You need to call gePayload() and sendEventPayload() methods.
    • getPayload() –  to convert payload from the body of the route.
    • sendEventPayload() – to send event payload to event bridge with the above payload.
    public class CreateCustomerEvent implements Processor { @Autowired private EventUtil eventUtil; @Override public void process(Exchange exchange) throws JsonParseException, JsonMappingException, IOException { EventPayload<?> event= eventUtil.getPayload(exchange, CustomerLoginResponse.class); //You can change the id, eventType, and payload information from the event and send it to below mentioned send event function. eventUtil.sendEventPayload(event); }

Orchestration Support

public class EventUtil { public void sendEventPayload(EventPayload<?> payloadobject) {} public Object getPayload(Exchange exchange, Class<?> responseModel){} }

Portal Configurations

Event Bridge

 In Event Bridge, you need to:

  1. Go to the Amazon Event Bridge console.
    The console looks as given below.

  2. Select Event buses from the left menu.

  3. Click the Create event bus button available at the right bottom.

    The Event Bus Detail page is shown.

  4. Provide a unique name on the Event bus detail page.

  5. Click Create.
Creating a Rule

To create a rule,

  1. Define Rule Detail.
  2. Build event pattern.
    Sample Event:

    {
    “version”: “0”,
    “id”: “0948ba87-d3b8-c6d4-f2da-732a1example”,
    “detail-type”: “Macie Finding”,
    “source”: “catalog”,
    “account”: “123456789012”,
    “time”: “2021-04-29T23:12:15Z”,
    “region”: “us-east-1”,
    “resources”: [],
    “detail”: {
    “messageType”: null,
    “sender”: null,
    “id”: “3”,
    “payload”: {
    “responseCode”: “ACACCRE0000”,
    “responseMessage”: “Collection Create Success”,
    “timeStamp”: null,
    “account”: {
    “id”: 3,
    “collectionId”: 1,
    “name”: “Account 1”,
    “size”: “<500”,
    “phoneNumber”: “+919876543210”,
    “dunsNumber”: “skava123”,
    “taxNumber”: “skava123”,
    “typeId”: 1,
    “accountType”: “Hardware”,
    “status”: “active”,
    “parentAccountId”: 1,
    “createdTime”: 1655816483884,
    “updatedTime”: 1655816483884,
    “properties”: [],
    “createdBy”: 1,
    “updatedBy”: 1,
    “costCentre”: [
    {
    “id”: 4,
    “accountId”: 3,
    “name”: “Default Cost Centre”,
    “status”: “active”,
    “createdTime”: 1655816483910,
    “updatedTime”: 1655816483910,
    “createdBy”: 1,
    “updatedBy”: 1,
    “budgets”: null
    }
    ],
    “team”: [
    {
    “id”: 2,
    “accountId”: 3,
    “costCentreId”: 4,
    “name”: “Default Team”,
    “description”: null,
    “status”: “active”,
    “createdTime”: 1655816483925,
    “updatedTime”: 1655816483925,
    “createdBy”: 1,
    “updatedBy”: 1,
    “teamBuyer”: null
    }
    ]
    }
    },
    “correlationId”: null,
    “collectionId”: null,
    “version”: null,
    “authToken”: null,
    “publisherId”: null,
    “msgProps”: null,
    “eventType”: “Create Account”,
    “userId”: “1”,
    “actOnBehalfOfUser”: 0,
    “roles”: [
    “ROLE_SUPER_ADMIN”
    ]
    }
    }

  3. Select Custom pattern JSON editor and provide values as given below:

    {
    "detail": {
    "eventType": [
    {
    "prefix": "omsservices/orders/create"
    }
    ]
    }
    }

    Note: The prefix key denotes the service name.

  4.  Select Target. In that, you need to:

    • Select a target type as AWS service
    • Select a target as CloudWatch log group
    • Select a log group, for example, aws/events/eventbridge.log

  5. Review and Update.
    After doing all the above configurations, review and submit the rule.

Event Grid

In Event Bridge, you need to:

Creating a Custom Topic
  1. On Azure Portal, search for Event Grid.

  2. Under Custom events, click Manage Topics.

  3. On the Event Grid Topics page, select Create available at the toolbar.

  4. On the Create Topic page, follow these steps:

    1. Select your required subscription.

    2. Select an existing resource group.

    3. Provide a unique name for the custom topic.

    4. Select a Region.

    5. Select Review + create at the bottom of the page.

  5. Once the topic is successfully created, navigate to the particular topic to get the topic details such as the topic endpoint to enter the Zookeeper properties.

Subscribe to Custom Topic

Subscription is required to receive an event.

To create an event subscription,

  1. On the Event Grid Topic page of your custom topic, select Event Subscription on the toolbar.
    You are navigated to the Create Event Subscription page.

  2. On the Create Event Subscription page, follow these steps:
    1. Enter a unique subscription name.

    2. Select Event Schema.

    3. Select Storage Queues as the Endpoint type.
      Note: The endpoint type can be chosen as per the requirement, the below step is to receive events through storage queues.

    4. Click Select an endpoint.
      Note
      : Select the storage account and select an existing queue if the queue is created already; otherwise, create a new queue.

    5. Select Create at the bottom of the page.

Sample Event

You have triggered the event, and Event Grid sends the message to the endpoint you configured when subscribing. The message is in the JSON format and it contains an array with one or more events. For example,

{ “id”: “4b9dfe97-2a2c-4a85-bbf3-a543cbb943c2”, “subject”: “catalogservice”, “data”: { “id”: “2”, “timestamp”: “2023-02-20T10:36:25.932+00:00”, “payload”: { “identifier”: “2”, “collectionId”: 1, “type”: “MASTER”, “status”: “ACTIVE”, “subType”: “DEFAULT”, “sfFilter”: “string”, “adminFilter”: “string”, “startTime”: “2016-11-09T11:44:44.797+05:30”, “endTime”: “2025-11-09T11:44:44.797+05:30”, “createdOn”: “2023-02-20T16:06:25.9235963+05:30”, “createdBy”: 1, “updatedOn”: “2023-02-20T16:06:25.9235963+05:30”, “updatedBy”: 1, “properties”: [ { “createdBy”: 0, “updatedBy”: 0, “value”: “string”, “name”: “string”, “locale”: “en_US” } ] }, “eventType”: “catalogservice/catalog/create”, “userId”: “1”, “actOnBehalfOfUser”: 0, “roles”: [ “ROLE_SUPER_ADMIN” ], “subject”: “catalogservice” }, “eventType”: “catalogservice/catalog/create”, “dataVersion”: “2”, “metadataVersion”: “1”, “eventTime”: “2023-02-20T10:36:27.0768392Z”, “topic”: “/subscriptions/7d19369d-a8d9-425e-9415-8c856593ff8c/resourceGroups/EQ_<<ClientName>>_Platform/providers/Microsoft.EventGrid/topics/<<ClientName>>-event-grid-topic” }

Note: You need to replace <<ClientName>> with the client name.

Event Arc

In Event Arc, you need to Create and Subscribe to Topic

Create and Subscribe to Topic
  1. Enter Project Name and Location.

  2. On the Event Arc Topics page, select Create Topic on the toolbar.

  3. On the Create Topic page, follow these steps:

    1. Provide a unique Topic ID for the custom topic.

    2. Select Add a default subscription to create a default subscription.

    3. For Encryption, select Google-manage encryption key.

    4. Select CREATE at the bottom of the page.

  4. Once a topic is successfully created, navigate to the particular topic list page to get the topic details such as the topic name.
  5. Select a particular Topic ID in the Topics page.
  6. Navigate to the particular topic page to get the topic details such as topic name and default subscription in the below topic page:
  7. Click the Default Subscription ID button available at the bottom left on the topic page or create a new custom subscription.
  8. Navigate to the subscription page to get subscription details such as subscription name, subscription state, topic name, and event massages.
  9. To get event messages, follow these steps:
    1. Select the MESSAGES tab available below the subscription details.

    2. Click PULL to get all the published messages.

    3. Select a particular message to get the event payload.

Sample Event Payload

{ “timestamp”: 1679292149957, “payload”: { “createdUsers”: [ { “guest”: false, “id”: 4, “collectionId”: 1, “status”: “ACTIVE”, “type”: 1, “dateOfBirth”: “08-10-1990”, “gender”: “male”, “firstName”: “john”, “lastName”: “smith”, “phoneNumber”: “1234567890”, “userName”: “testusername”, “referenceAttribute”: “string”, “referenceAttribute1”: “string”, “referenceAttribute2”: 1, “email”: “dev@skava.com”, “photo”: “string_url”, “preferences”: “email”, “createdDate”: 1679292149000, “updatedDate”: 1679292149000, “identities”: [ { “id”: 7, “identity”: “1234567890”, “type”: 1, “identityType”: “DEFAULT”, “status”: “ACTIVE” }, { “id”: 8, “identity”: “dev@skava.com”, “type”: 1, “identityType”: “DEFAULT”, “status”: “ACTIVE” }, { “id”: 9, “identity”: “testusername”, “type”: 1, “identityType”: “DEFAULT”, “status”: “ACTIVE” } ], “customProperties”: { “bearerToken”: “378c0d560299e06b8bb182a47c31c897”, “segment”: “gold” }, “addresses”: [ { “id”: 4, “type”: “BillingAddreess”, “firstName”: “John”, “middleName”: “John”, “lastName”: “Smith”, “phone”: “9876543210”, “email”: “abc@skava.com”, “street1”: “E MAIN ST”, “street2”: “SUITE 5A-1235”, “street3”: “PHONEIX”, “city”: “LOS ANGELES”, “country”: “USA”, “county”: null, “state”: “CALIFORNIA”, “zipCode”: “90001”, “validated”: false, “createdDate”: 1679292149000, “updatedDate”: 1679292149000, “overridden”: false, “validationType”: “testvalidationtype”, “validatedOn”: 100000, “createdBy”: 0, “updatedBy”: 0, “properties”: { “deliveryInstruction”: “Call me from gate.” }, “default”: true } ], “credentials”: { “password”: “<Password>;”, “securityQuestions”: [ { “question”: “What is your company name ?”, “answer”: “Company name is skava” } ] } } ], “existingUsers”: [ ] }, “eventType”: “userservice/user/create”, “userId”: “1”, “actOnBehalfOfUser”: 0, “roles”: [ “ROLE_SUPER_ADMIN” ] }

ZooKeeper Properties

The ZooKeeper properties to be configured are:

CLOUDKEYVALUEALLOWED VALUESDESCRIPTION
AWS,AZURE,GCPskava.event.enableExternalEventZK_ENABLE_EVENT_BRIDGETrue/FalseThis is to enable/disable External Events.
AWS,AZURE,GCPskava.event.enableFatEventFALSETrue/FalseThis is to enable/disable Fat Events.
AWS,AZURE,GCPskava.event.externalFatEventClassStringThis will be used to send events from the custom implementation class.
AWS,AZURE,GCPskava.event.externalClassNameStringThis will contain external Event component class name(GCP/Azure). By default, it is take as AwsEventComponent class.
AWSskava.event.eventbridge.regionZK_EVENT_BRIDGE_REGIONStringThis will contain AWS EventBridge region.
AWSskava.event.eventbridge.eventBusNameZK_EVENT_BRIDGE_EVENT_BUS_NAMEStringThis will contain AWS bus name of EventBridge.
AZUREskava.event.eventgrid.topicEndPointZK_EVENT_GRID_TOPIC_ENDPOINTStringThis will contain Topic EndPoint url of Azure EventGrid.
AZUREskava.event.eventgrid.endPointKeyZK_EVENT_GRID_ENDPOINT_KEYStringThis will contain EndPoint Key of Azure EventGrid.
GCPskava.event.eventarc.projectIdZK_EVENT_ARC_PROJECT_IDStringThis will contain Project Id of GCP EventArc.
GCPskava.event.eventarc.topicIdZK_EVENT_ARC_TOPIC_IDStringThis will contain Topic Id of GCP EventArc.

Extension to Fat Events

To send fat events on top of thin events, the following method from the abstract class is to be overridden in the extension plugin of the particular microservice.

abstract class EventProcess {
public void updateEventPayload(InputModel input, OutputModel output, EventPayload<Object> event) {
}
}

Note: The parameters:

  • input – denotes request object is sent
  • output – denotes response object is sent
  • event – denotes thin event object is sent to update fat events

Example:

public class OrderEventProcessImpl extends EventProcess {
@Override
public void updateEventPayload(InputModel input, OutputModel output, EventPayload<Object> event) {
// Add stuff to override event payload
}
}

Event Details for Services

Here are the links to the event details of all microservices:

 

Revision History

2023-11-15| AN, SD – Updated the page.
2023-10-16| AN, SD – Created the page and updated for release 8.15.0.