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) { } |
Customizing APIs at the SFO and AO Services Level
- 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) {} } - 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:
Creating a Rule
To create a rule,
- Define Rule Detail.
- 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”
]
}
} -
Select Custom pattern JSON editor and provide values as given below:
<span class="token punctuation">{</span>
<span class="token property">"detail"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"eventType"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span>
<span class="token property">"prefix"</span><span class="token operator">:</span> <span class="token string">"omsservices/orders/create"</span>
<span class="token punctuation">}</span>
<span class="token punctuation">]</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>Note: The prefix key denotes the service name.
- 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
- 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
-
On Azure Portal, search for Event Grid.
-
Under Custom events, click Manage Topics.
-
On the Event Grid Topics page, select Create available at the toolbar.
-
On the Create Topic page, follow these steps:
-
Select your required subscription.
-
Select an existing resource group.
-
Provide a unique name for the custom topic.
-
Select a Region.
-
Select Review + create at the bottom of the page.
-
-
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,
-
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.
- On the Create Event Subscription page, follow these steps:
-
-
Enter a unique subscription name.
-
Select Event Schema.
-
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. -
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.
-
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
-
Enter Project Name and Location.
-
On the Event Arc Topics page, select Create Topic on the toolbar.
-
On the Create Topic page, follow these steps:
-
Provide a unique Topic ID for the custom topic.
-
Select Add a default subscription to create a default subscription.
-
For Encryption, select Google-manage encryption key.
-
Select CREATE at the bottom of the page.
-
- Once a topic is successfully created, navigate to the particular topic list page to get the topic details such as the topic name.
- Select a particular Topic ID in the Topics page.
- Navigate to the particular topic page to get the topic details such as topic name and default subscription in the below topic page:
- Click the Default Subscription ID button available at the bottom left on the topic page or create a new custom subscription.
- Navigate to the subscription page to get subscription details such as subscription name, subscription state, topic name, and event massages.
- To get event messages, follow these steps:
-
-
Select the MESSAGES tab available below the subscription details.
-
Click PULL to get all the published messages.
-
Select a particular message to get the 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:
CLOUD | KEY | VALUE | ALLOWED VALUES | DESCRIPTION |
---|---|---|---|---|
AWS,AZURE,GCP | skava.event.enableExternalEvent | ZK_ENABLE_EVENT_BRIDGE | True/False | This is to enable/disable External Events. |
AWS,AZURE,GCP | skava.event.enableFatEvent | FALSE | True/False | This is to enable/disable Fat Events. |
AWS,AZURE,GCP | skava.event.externalFatEventClass | String | This will be used to send events from the custom implementation class. | |
AWS,AZURE,GCP | skava.event.externalClassName | String | This will contain external Event component class name(GCP/Azure). By default, it is take as AwsEventComponent class. | |
AWS | skava.event.eventbridge.region | ZK_EVENT_BRIDGE_REGION | String | This will contain AWS EventBridge region. |
AWS | skava.event.eventbridge.eventBusName | ZK_EVENT_BRIDGE_EVENT_BUS_NAME | String | This will contain AWS bus name of EventBridge. |
AZURE | skava.event.eventgrid.topicEndPoint | ZK_EVENT_GRID_TOPIC_ENDPOINT | String | This will contain Topic EndPoint url of Azure EventGrid. |
AZURE | skava.event.eventgrid.endPointKey | ZK_EVENT_GRID_ENDPOINT_KEY | String | This will contain EndPoint Key of Azure EventGrid. |
GCP | skava.event.eventarc.projectId | ZK_EVENT_ARC_PROJECT_ID | String | This will contain Project Id of GCP EventArc. |
GCP | skava.event.eventarc.topicId | ZK_EVENT_ARC_TOPIC_ID | String | This 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:
- Accounts
- Address
- Admin Orchestrataion
- Authorization
- Cart
- Catalog
- Feeds
- Feed Job
- Foundation
- Inventory
- Lists
- Location
- Loyalty
- Merchandising
- Notification
- Order
- Payment
- Pricing
- Promotions
- Ratings and Reviews
- Reporting
- Search
- Shipping
- Subscription
- Storefront Orchestration
- Tax
- User
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.