Skip to content

Commit

Permalink
Merge pull request #159 from Ashi1993/event
Browse files Browse the repository at this point in the history
[Accelerator 4] Adding Event creation, polling and subscription implementation
  • Loading branch information
imesh94 authored Dec 4, 2024
2 parents e0fc714 + 4e3160f commit 08f9dfd
Show file tree
Hide file tree
Showing 57 changed files with 5,298 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
-- Since the database systems does not support adding default unix time to the database columns, the default data
-- storing is handled within the database querieS.

CREATE TABLE OB_NOTIFICATION (
CREATE TABLE FS_NOTIFICATION (
NOTIFICATION_ID varchar(36) NOT NULL,
CLIENT_ID varchar(255) NOT NULL,
RESOURCE_ID varchar(255) NOT NULL,
Expand All @@ -30,24 +30,24 @@ CREATE TABLE OB_NOTIFICATION (
PRIMARY KEY (NOTIFICATION_ID)
);

CREATE TABLE OB_NOTIFICATION_EVENT (
CREATE TABLE FS_NOTIFICATION_EVENT (
EVENT_ID int NOT NULL IDENTITY,
NOTIFICATION_ID varchar(36) NOT NULL,
EVENT_TYPE varchar(200) NOT NULL,
EVENT_INFO varchar(1000) NOT NULL,
PRIMARY KEY (EVENT_ID),
CONSTRAINT FK_NotificationEvent FOREIGN KEY (NOTIFICATION_ID) REFERENCES OB_NOTIFICATION(NOTIFICATION_ID)
CONSTRAINT FK_NotificationEvent FOREIGN KEY (NOTIFICATION_ID) REFERENCES FS_NOTIFICATION(NOTIFICATION_ID)
);

CREATE TABLE OB_NOTIFICATION_ERROR (
CREATE TABLE FS_NOTIFICATION_ERROR (
NOTIFICATION_ID varchar(36) NOT NULL,
ERROR_CODE varchar(255) NOT NULL,
DESCRIPTION varchar(255) NOT NULL,
PRIMARY KEY (NOTIFICATION_ID),
CONSTRAINT FK_NotificationError FOREIGN KEY (NOTIFICATION_ID) REFERENCES OB_NOTIFICATION(NOTIFICATION_ID)
CONSTRAINT FK_NotificationError FOREIGN KEY (NOTIFICATION_ID) REFERENCES FS_NOTIFICATION(NOTIFICATION_ID)
);

CREATE TABLE OB_NOTIFICATION_SUBSCRIPTION (
CREATE TABLE FS_NOTIFICATION_SUBSCRIPTION (
SUBSCRIPTION_ID varchar(36) NOT NULL,
CLIENT_ID varchar(255) NOT NULL,
REQUEST JSON NOT NULL,
Expand All @@ -58,9 +58,9 @@ CREATE TABLE OB_NOTIFICATION_SUBSCRIPTION (
PRIMARY KEY (SUBSCRIPTION_ID)
);

CREATE TABLE OB_NOTIFICATION_SUBSCRIBED_EVENTS (
CREATE TABLE FS_NOTIFICATION_SUBSCRIBED_EVENTS (
SUBSCRIPTION_ID varchar(36) NOT NULL,
EVENT_TYPE varchar(255) NOT NULL,
PRIMARY KEY (SUBSCRIPTION_ID, EVENT_TYPE),
CONSTRAINT FK_NotificationSubEvents FOREIGN KEY (SUBSCRIPTION_ID) REFERENCES OB_NOTIFICATION_SUBSCRIPTION(SUBSCRIPTION_ID)
CONSTRAINT FK_NotificationSubEvents FOREIGN KEY (SUBSCRIPTION_ID) REFERENCES FS_NOTIFICATION_SUBSCRIPTION(SUBSCRIPTION_ID)
);
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

-- For event notifications feature run the following queries against the openbank_openbankingdb--

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION (
CREATE TABLE IF NOT EXISTS FS_NOTIFICATION (
NOTIFICATION_ID varchar(36) NOT NULL,
CLIENT_ID varchar(255) NOT NULL,
RESOURCE_ID varchar(255) NOT NULL,
Expand All @@ -33,26 +33,26 @@ CREATE TABLE IF NOT EXISTS OB_NOTIFICATION (
)
ENGINE=InnoDB;

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_EVENT (
CREATE TABLE IF NOT EXISTS FS_NOTIFICATION_EVENT (
EVENT_ID int(11) NOT NULL AUTO_INCREMENT,
NOTIFICATION_ID varchar(36) NOT NULL,
EVENT_TYPE varchar(200) NOT NULL,
EVENT_INFO varchar(1000) NOT NULL,
PRIMARY KEY (EVENT_ID),
CONSTRAINT FK_NotificationEvent FOREIGN KEY (NOTIFICATION_ID) REFERENCES OB_NOTIFICATION(NOTIFICATION_ID)
CONSTRAINT FK_NotificationEvent FOREIGN KEY (NOTIFICATION_ID) REFERENCES FS_NOTIFICATION(NOTIFICATION_ID)
)
ENGINE=InnoDB;

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_ERROR (
CREATE TABLE IF NOT EXISTS FS_NOTIFICATION_ERROR (
NOTIFICATION_ID varchar(36) NOT NULL,
ERROR_CODE varchar(255) NOT NULL,
DESCRIPTION varchar(255) NOT NULL,
PRIMARY KEY (NOTIFICATION_ID),
CONSTRAINT FK_NotificationError FOREIGN KEY (NOTIFICATION_ID) REFERENCES OB_NOTIFICATION(NOTIFICATION_ID)
CONSTRAINT FK_NotificationError FOREIGN KEY (NOTIFICATION_ID) REFERENCES FS_NOTIFICATION(NOTIFICATION_ID)
)
ENGINE=InnoDB;

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_SUBSCRIPTION (
CREATE TABLE IF NOT EXISTS FS_NOTIFICATION_SUBSCRIPTION (
SUBSCRIPTION_ID varchar(36) NOT NULL,
CLIENT_ID varchar(255) NOT NULL,
REQUEST JSON NOT NULL,
Expand All @@ -64,10 +64,10 @@ CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_SUBSCRIPTION (
)
ENGINE=InnoDB;

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_SUBSCRIBED_EVENTS (
CREATE TABLE IF NOT EXISTS FS_NOTIFICATION_SUBSCRIBED_EVENTS (
SUBSCRIPTION_ID varchar(36) NOT NULL,
EVENT_TYPE varchar(255) NOT NULL,
PRIMARY KEY (SUBSCRIPTION_ID, EVENT_TYPE),
CONSTRAINT FK_NotificationSubEvents FOREIGN KEY (SUBSCRIPTION_ID) REFERENCES OB_NOTIFICATION_SUBSCRIPTION(SUBSCRIPTION_ID)
CONSTRAINT FK_NotificationSubEvents FOREIGN KEY (SUBSCRIPTION_ID) REFERENCES FS_NOTIFICATION_SUBSCRIPTION(SUBSCRIPTION_ID)
)
ENGINE=InnoDB;
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
-- All the data related to time are stored in unix time stamp and therefore, the data types for the time related data
-- are represented in BIGINT.
-- Since the database systems does not support adding default unix time to the database columns, the default data
-- storing is handled within the database querieS.
-- storing is handled within the database queries.

CREATE TABLE OB_NOTIFICATION (
CREATE TABLE FS_NOTIFICATION (
NOTIFICATION_ID varchar2(36) NOT NULL,
CLIENT_ID varchar2(255) NOT NULL,
RESOURCE_ID varchar2(255) NOT NULL,
Expand All @@ -30,34 +30,34 @@ CREATE TABLE OB_NOTIFICATION (
PRIMARY KEY (NOTIFICATION_ID)
);

CREATE TABLE OB_NOTIFICATION_EVENT (
CREATE TABLE FS_NOTIFICATION_EVENT (
EVENT_ID number(10) NOT NULL,
NOTIFICATION_ID varchar2(36) NOT NULL,
EVENT_TYPE varchar2(200) NOT NULL,
EVENT_INFO varchar2(1000) NOT NULL,
PRIMARY KEY (EVENT_ID),
CONSTRAINT FK_NotificationEvent FOREIGN KEY (NOTIFICATION_ID) REFERENCES OB_NOTIFICATION(NOTIFICATION_ID)
CONSTRAINT FK_NotificationEvent FOREIGN KEY (NOTIFICATION_ID) REFERENCES FS_NOTIFICATION(NOTIFICATION_ID)
);

-- Generate ID using sequence and trigger
CREATE SEQUENCE OB_NOTIFICATION_EVENT_seq START WITH 1 INCREMENT BY 1;
CREATE SEQUENCE FS_NOTIFICATION_EVENT_seq START WITH 1 INCREMENT BY 1;

CREATE OR REPLACE TRIGGER OB_NOTIFICATION_EVENT_seq_tr
BEFORE INSERT ON OB_NOTIFICATION_EVENT FOR EACH ROW
CREATE OR REPLACE TRIGGER FS_NOTIFICATION_EVENT_seq_tr
BEFORE INSERT ON FS_NOTIFICATION_EVENT FOR EACH ROW
WHEN (NEW.EVENT_ID IS NULL)
BEGIN
SELECT OB_NOTIFICATION_EVENT_seq.NEXTVAL INTO :NEW.EVENT_ID FROM DUAL;
SELECT FS_NOTIFICATION_EVENT_seq.NEXTVAL INTO :NEW.EVENT_ID FROM DUAL;
END;

CREATE TABLE OB_NOTIFICATION_ERROR (
CREATE TABLE FS_NOTIFICATION_ERROR (
NOTIFICATION_ID varchar2(36) NOT NULL,
ERROR_CODE varchar2(255) NOT NULL,
DESCRIPTION varchar2(255) NOT NULL,
PRIMARY KEY (NOTIFICATION_ID),
CONSTRAINT FK_NotificationError FOREIGN KEY (NOTIFICATION_ID) REFERENCES OB_NOTIFICATION(NOTIFICATION_ID)
CONSTRAINT FK_NotificationError FOREIGN KEY (NOTIFICATION_ID) REFERENCES FS_NOTIFICATION(NOTIFICATION_ID)
)

CREATE TABLE OB_NOTIFICATION_SUBSCRIPTION (
CREATE TABLE FS_NOTIFICATION_SUBSCRIPTION (
SUBSCRIPTION_ID varchar(36) NOT NULL,
CLIENT_ID varchar(255) NOT NULL,
REQUEST JSON NOT NULL,
Expand All @@ -68,9 +68,9 @@ CREATE TABLE OB_NOTIFICATION_SUBSCRIPTION (
PRIMARY KEY (SUBSCRIPTION_ID)
);

CREATE TABLE OB_NOTIFICATION_SUBSCRIBED_EVENTS (
CREATE TABLE FS_NOTIFICATION_SUBSCRIBED_EVENTS (
SUBSCRIPTION_ID varchar(36) NOT NULL,
EVENT_TYPE varchar(255) NOT NULL,
PRIMARY KEY (SUBSCRIPTION_ID, EVENT_TYPE),
CONSTRAINT FK_NotificationSubEvents FOREIGN KEY (SUBSCRIPTION_ID) REFERENCES OB_NOTIFICATION_SUBSCRIPTION(SUBSCRIPTION_ID)
CONSTRAINT FK_NotificationSubEvents FOREIGN KEY (SUBSCRIPTION_ID) REFERENCES FS_NOTIFICATION_SUBSCRIPTION(SUBSCRIPTION_ID)
);
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

-- For event notifications feature run the following queries against the openbank_openbankingdb--

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION (
CREATE TABLE IF NOT EXISTS FS_NOTIFICATION (
NOTIFICATION_ID varchar(36) NOT NULL,
CLIENT_ID varchar(255) NOT NULL,
RESOURCE_ID varchar(255) NOT NULL,
Expand All @@ -32,23 +32,23 @@ CREATE TABLE IF NOT EXISTS OB_NOTIFICATION (
PRIMARY KEY (NOTIFICATION_ID)
);

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_EVENT (
CREATE TABLE IF NOT EXISTS FS_NOTIFICATION_EVENT (
EVENT_ID SERIAL PRIMARY KEY,
NOTIFICATION_ID varchar(36) NOT NULL,
EVENT_TYPE varchar(200) NOT NULL,
EVENT_INFO varchar(1000) NOT NULL,
CONSTRAINT FK_NotificationEvent FOREIGN KEY (NOTIFICATION_ID) REFERENCES OB_NOTIFICATION(NOTIFICATION_ID)
CONSTRAINT FK_NotificationEvent FOREIGN KEY (NOTIFICATION_ID) REFERENCES FS_NOTIFICATION(NOTIFICATION_ID)
);

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_ERROR (
CREATE TABLE IF NOT EXISTS FS_NOTIFICATION_ERROR (
NOTIFICATION_ID varchar(36) NOT NULL,
ERROR_CODE varchar(255) NOT NULL,
DESCRIPTION varchar(255) NOT NULL,
PRIMARY KEY (NOTIFICATION_ID),
CONSTRAINT FK_NotificationError FOREIGN KEY (NOTIFICATION_ID) REFERENCES OB_NOTIFICATION(NOTIFICATION_ID)
CONSTRAINT FK_NotificationError FOREIGN KEY (NOTIFICATION_ID) REFERENCES FS_NOTIFICATION(NOTIFICATION_ID)
);

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_SUBSCRIPTION (
CREATE TABLE IF NOT EXISTS FS_NOTIFICATION_SUBSCRIPTION (
SUBSCRIPTION_ID varchar(36) NOT NULL,
CLIENT_ID varchar(255) NOT NULL,
REQUEST JSON NOT NULL,
Expand All @@ -59,9 +59,9 @@ CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_SUBSCRIPTION (
PRIMARY KEY (SUBSCRIPTION_ID)
);

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_SUBSCRIBED_EVENTS (
CREATE TABLE IF NOT EXISTS FS_NOTIFICATION_SUBSCRIBED_EVENTS (
SUBSCRIPTION_ID varchar(36) NOT NULL,
EVENT_TYPE varchar(255) NOT NULL,
PRIMARY KEY (SUBSCRIPTION_ID, EVENT_TYPE),
CONSTRAINT FK_NotificationSubEvents FOREIGN KEY (SUBSCRIPTION_ID) REFERENCES OB_NOTIFICATION_SUBSCRIPTION(SUBSCRIPTION_ID)
CONSTRAINT FK_NotificationSubEvents FOREIGN KEY (SUBSCRIPTION_ID) REFERENCES FS_NOTIFICATION_SUBSCRIPTION(SUBSCRIPTION_ID)
);
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,31 @@
<MaxConnections>2000</MaxConnections>
<MaxConnectionsPerRoute>1500</MaxConnectionsPerRoute>
</HTTPConnectionPool>
<EventNotifications>
<NotificationGeneration>
<NotificationGenerator>org.wso2.financial.services.accelerator.event.notifications.service.DefaultEventNotificationGenerator</NotificationGenerator>
<TokenIssuer>www.wso2.com</TokenIssuer>
<NumberOfSetsToReturn>5</NumberOfSetsToReturn>
</NotificationGeneration>
<EventCreationHandler>org.wso2.financial.services.accelerator.event.notifications.service.handler.DefaultEventCreationServiceHandler</EventCreationHandler>
<EventPollingHandler>org.wso2.financial.services.accelerator.event.notifications.service.handler.DefaultEventPollingServiceHandler</EventPollingHandler>
<EventSubscriptionHandler>org.wso2.financial.services.accelerator.event.notifications.service.handler.DefaultEventSubscriptionServiceHandler</EventSubscriptionHandler>
<PollingResponseParams>
<IsSubClaimAvailable>true</IsSubClaimAvailable>
<IsTxnClaimAvailable>true</IsTxnClaimAvailable>
<IsTxnClaimAvailable>true</IsTxnClaimAvailable>
<IsToeClaimAvailable>true</IsToeClaimAvailable>
</PollingResponseParams>
<Realtime>
<Enable>false</Enable>
<PeriodicCronExpression>0 0/1 0 ? * * *</PeriodicCronExpression>
<TimeoutInSeconds>60</TimeoutInSeconds>
<MaxRetries>5</MaxRetries>
<InitialBackoffTimeInSeconds>60</InitialBackoffTimeInSeconds>
<BackoffFunction>EX</BackoffFunction>
<CircuitBreakerOpenTimeoutInSeconds>600</CircuitBreakerOpenTimeoutInSeconds>
<EventNotificationThreadPoolSize>20</EventNotificationThreadPoolSize>
<RequestGenerator>org.wso2.financial.services.accelerator.event.notifications.service.realtime.service.DefaultRealtimeEventNotificationRequestGenerator</RequestGenerator>
</Realtime>
</EventNotifications>
</Server>
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,102 @@
<MaxConnectionsPerRoute>1000</MaxConnectionsPerRoute>
{% endif %}
</HTTPConnectionPool>
<EventNotifications>
<NotificationGeneration>
{% if financial_services.event.notifications.event_notification_generator is defined %}
<NotificationGenerator>{{financial_services.event.notifications.event_notification_generator}}</NotificationGenerator>
{% else %}
<NotificationGenerator>org.wso2.financial.services.accelerator.event.notifications.service.DefaultEventNotificationGenerator</NotificationGenerator>
{% endif %}
{% if financial_services.event.notifications.token_issuer is defined %}
<TokenIssuer>{{financial_services.event.notifications.token_issuer}}</TokenIssuer>
{% else %}
<TokenIssuer>www.wso2.com</TokenIssuer>
{% endif %}
{% if financial_services.event.notifications.number_of_sets_to_return %}
<NumberOfSetsToReturn>{{financial_services.event.notifications.number_of_sets_to_return}}</NumberOfSetsToReturn>
{% else %}
<NumberOfSetsToReturn>5</NumberOfSetsToReturn>
{% endif %}
</NotificationGeneration>
{% if financial_services.event.notifications.event_creation_handler is defined %}
<EventCreationHandler>{{financial_services.event.notifications.event_creation_handler}}</EventCreationHandler>
{% else %}
<EventCreationHandler>org.wso2.financial.services.accelerator.event.notifications.service.handler.DefaultEventCreationServiceHandler</EventCreationHandler>
{% endif %}
{% if financial_services.event.notifications.event_polling_handler is defined %}
<EventPollingHandler>{{financial_services.event.notifications.event_polling_handler}}</EventPollingHandler>
{% else %}
<EventPollingHandler>org.wso2.financial.services.accelerator.event.notifications.service.handler.DefaultEventPollingServiceHandler</EventPollingHandler>
{% endif %}
{% if financial_services.event.notifications.event_subscription_handler is defined %}
<EventSubscriptionHandler>{{financial_services.event.notifications.event_subscription_handler}}</EventSubscriptionHandler>
{% else %}
<EventSubscriptionHandler>org.wso2.financial.services.accelerator.event.notifications.service.handler.DefaultEventSubscriptionServiceHandler</EventSubscriptionHandler>
{% endif %}
<PollingResponseParams>
{% if financial_services.event.notifications.set_sub_claim_included is defined%}
<IsSubClaimAvailable>{{financial_services.event.notifications.set_sub_claim_included}}</IsSubClaimAvailable>
{% else %}
<IsSubClaimAvailable>true</IsSubClaimAvailable>
{% endif %}
{% if financial_services.event.notifications.set_txn_claim_included is defined %}
<IsTxnClaimAvailable>{{financial_services.event.notifications.set_txn_claim_included}}</IsTxnClaimAvailable>
{% else %}
<IsTxnClaimAvailable>true</IsTxnClaimAvailable>
{% endif %}
{% if financial_services.event.notifications.set_toe_cliam_included is defined %}
<IsToeClaimAvailable>{{financial_services.event.notifications.set_toe_cliam_included}}</IsToeClaimAvailable>
{% else %}
<IsToeClaimAvailable>true</IsToeClaimAvailable>
{% endif %}
</PollingResponseParams>
<Realtime>
{% if financial_services.event.notifications.realtime.enable is defined %}
<Enable>{{financial_services.event.notifications.realtime.enable}}</Enable>
{% else %}
<Enable>false</Enable>
{% endif %}
{% if financial_services.event.notifications.realtime.periodic_cron_expression is defined %}
<PeriodicCronExpression>{{financial_services.event.notifications.realtime.periodic_cron_expression}}</PeriodicCronExpression>
{% else %}
<PeriodicCronExpression>0 0/1 0 ? * * *</PeriodicCronExpression>
{% endif %}
{% if financial_services.event.notifications.realtime.request_timeout is defined %}
<TimeoutInSeconds>{{financial_services.event.notifications.realtime.request_timeout}}</TimeoutInSeconds>
{% else %}
<TimeoutInSeconds>60</TimeoutInSeconds>
{% endif %}
{% if financial_services.event.notifications.realtime.maximum_retry_count is defined %}
<MaxRetries>{{financial_services.event.notifications.realtime.maximum_retry_count}}</MaxRetries>
{% else %}
<MaxRetries>5</MaxRetries>
{% endif %}
{% if financial_services.event.notifications.realtime.initial_retry_waiting_time is defined %}
<InitialBackoffTimeInSeconds>{{financial_services.event.notifications.realtime.initial_retry_waiting_time}}</InitialBackoffTimeInSeconds>
{% else %}
<InitialBackoffTimeInSeconds>60</InitialBackoffTimeInSeconds>
{% endif %}
{% if financial_services.event.notifications.realtime.retry_function is defined %}
<BackoffFunction>{{financial_services.event.notifications.realtime.retry_function}}</BackoffFunction>
{% else %}
<BackoffFunction>EX</BackoffFunction>
{% endif %}
{% if financial_services.event.notifications.realtime.circuit_breaker_open_timeout is defined %}
<CircuitBreakerOpenTimeoutInSeconds>{{financial_services.event.notifications.realtime.circuit_breaker_open_timeout}}</CircuitBreakerOpenTimeoutInSeconds>
{% else %}
<CircuitBreakerOpenTimeoutInSeconds>600</CircuitBreakerOpenTimeoutInSeconds>
{% endif %}
{% if financial_services.event.notifications.realtime.thread_pool_size is defined %}
<EventNotificationThreadPoolSize>{{financial_services.event.notifications.realtime.thread_pool_size}}</EventNotificationThreadPoolSize>
{% else %}
<EventNotificationThreadPoolSize>20</EventNotificationThreadPoolSize>
{% endif %}
{% if financial_services.event.notifications.realtime.event_notification_request_generator is defined %}
<RequestGenerator>{{financial_services.event.notifications.realtime.event_notification_request_generator}}</RequestGenerator>
{% else %}
<RequestGenerator>org.wso2.financial.services.accelerator.event.notifications.service.realtime.service.DefaultRealtimeEventNotificationRequestGenerator</RequestGenerator>
{% endif %}
</RealtimeEventNotification>
</EventNotifications>
</Server>
Loading

0 comments on commit 08f9dfd

Please sign in to comment.