Create OutboxTable and enum types.
This commit is contained in:
16
infrastructure/outbox/pom.xml
Normal file
16
infrastructure/outbox/pom.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>infrastructure</artifactId>
|
||||
<groupId>com.food.order</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>outbox</artifactId>
|
||||
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.food.order.system.outbox;
|
||||
|
||||
public enum OutboxStatus {
|
||||
STARTED,COMPLETED,FAILED
|
||||
}
|
||||
@@ -13,6 +13,7 @@
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>saga</module>
|
||||
<module>outbox</module>
|
||||
</modules>
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.food.order.system.saga;
|
||||
|
||||
public enum SagaStatus {
|
||||
STARTED,FAILED,SUCCEEDED,PROCESSING, COMPENSATING,COMPENSATED
|
||||
}
|
||||
@@ -9,6 +9,8 @@ order-service:
|
||||
payment-response-topic-name: payment-response-value
|
||||
restaurant-approval-request-topic-name: restaurant-approval-request-value
|
||||
restaurant-approval-response-topic-name: restaurant-approval-response-value
|
||||
outbox-scheduler-fixed-rate: 10000
|
||||
outbox-scheduler-initial-delay: 10000
|
||||
|
||||
spring:
|
||||
jpa:
|
||||
|
||||
@@ -58,4 +58,62 @@ ALTER TABLE "order".order_address
|
||||
REFERENCES "order".orders (id) MATCH SIMPLE
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE CASCADE
|
||||
NOT VALID;
|
||||
NOT VALID;
|
||||
|
||||
DROP TYPE IF EXISTS saga_status;
|
||||
CREATE TYPE saga_status AS ENUM ('STARTED','FAILED','SUCCEEDED','PROCESSING', 'COMPENSATING','COMPENSATED');
|
||||
|
||||
DROP TYPE IF EXISTS outbox_status;
|
||||
CREATE TYPE outbox_status AS ENUM ('STARTED','COMPLETED','FAILED');
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS "order".payment_outbox CASCADE;
|
||||
|
||||
CREATE TABLE "order".payment_outbox
|
||||
(
|
||||
id uuid NOT NULL,
|
||||
saga_id uuid NOT NULL,
|
||||
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
processed_at TIMESTAMP WITH TIME ZONE,
|
||||
type character varying COLLATE pg_catalog."default" NOT NULL,
|
||||
payload jsonb NOT NULL,
|
||||
outbox_status outbox_status NOT NULL,
|
||||
saga_status saga_status NOT NULL,
|
||||
order_status order_status NOT NULL,
|
||||
version integer NOT NULL,
|
||||
CONSTRAINT payment_outbox_pkey PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE INDEX "payment_outbox_saga_status"
|
||||
ON "order".payment_outbox
|
||||
(type, outbox_status, saga_status);
|
||||
|
||||
CREATE UNIQUE INDEX "payment_outbox_saga_id"
|
||||
ON "order".payment_outbox
|
||||
(type, saga_id, saga_status);
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS "order".restaurant_approval_outbox CASCADE;
|
||||
|
||||
CREATE TABLE "order".restaurant_approval_outbox
|
||||
(
|
||||
id uuid NOT NULL,
|
||||
saga_id uuid NOT NULL,
|
||||
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
processed_at TIMESTAMP WITH TIME ZONE,
|
||||
type character varying COLLATE pg_catalog."default" NOT NULL,
|
||||
payload jsonb NOT NULL,
|
||||
outbox_status outbox_status NOT NULL,
|
||||
saga_status saga_status NOT NULL,
|
||||
order_status order_status NOT NULL,
|
||||
version integer NOT NULL,
|
||||
CONSTRAINT restaurant_approval_outbox_pkey PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE INDEX "restaurant_approval_outbox_saga_status"
|
||||
ON "order".restaurant_approval_outbox
|
||||
(type, outbox_status, saga_status);
|
||||
|
||||
CREATE UNIQUE INDEX "restaurant_approval_outbox_saga_id"
|
||||
ON "order".restaurant_approval_outbox
|
||||
(type, saga_id, saga_status);
|
||||
|
||||
6
pom.xml
6
pom.xml
@@ -43,6 +43,12 @@
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.food.order</groupId>
|
||||
<artifactId>outbox</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.food.order</groupId>
|
||||
<artifactId>payment-domain</artifactId>
|
||||
|
||||
Reference in New Issue
Block a user