41 Commits

Author SHA1 Message Date
Ali CANLI
7f9eae22ef Add Google k8n engine files and finish project... 2022-07-18 14:28:43 +03:00
Ali CANLI
c1fda2654f Merge pull request #16 from alicanli1995/cqrs-pattern
Cqrs pattern
2022-07-17 15:03:51 +03:00
Ali CANLI
ba432017f3 CQRS Pattern - > implemented completed. 2022-07-17 15:03:15 +03:00
Ali CANLI
b8c4cc6e83 CQRS Pattern - > first implement Customer module end to end. 2022-07-17 13:34:14 +03:00
Ali CANLI
cc489863ac Merge pull request #15 from alicanli1995/outbox-pattern
Outbox pattern
2022-07-17 12:51:34 +03:00
Ali CANLI
fb9fb739f4 Outbox Message and Scheduler class bug fixed. 2022-07-17 12:51:17 +03:00
Ali CANLI
e1c2a8312b Outbox Message and Scheduler class bug fixed. 2022-07-17 12:33:35 +03:00
Ali CANLI
4ec77f8f9f Merge pull request #14 from alicanli1995/outbox-pattern
Outbox pattern
2022-07-16 22:57:47 +03:00
Ali CANLI
3626ed70de Outbox Message and Scheduler class implemented part - 6 and finish. 2022-07-16 22:55:17 +03:00
Ali CANLI
2ff4b7b3d5 Outbox Message and Scheduler class implemented part - 5. 2022-07-16 22:20:20 +03:00
Ali CANLI
68e7f14dca Outbox Message and Scheduler class implemented part - 4. 2022-07-16 20:40:52 +03:00
Ali CANLI
9ff94746f6 Outbox Message and Scheduler class implemented part - 3. 2022-07-16 14:01:49 +03:00
Ali CANLI
0cd56d22ee Merge pull request #13 from alicanli1995/outbox-pattern
Outbox pattern
2022-07-15 21:46:18 +03:00
Ali CANLI
3affe7ccdd Outbox Message and Scheduler class implemented part - 2. 2022-07-15 21:45:48 +03:00
Ali CANLI
d49b533f7e Outbox Message and Scheduler class implemented part - 1. 2022-07-15 20:37:22 +03:00
Ali CANLI
d7939edd0a Create OutboxTable and enum types. 2022-07-15 12:01:28 +03:00
Ali CANLI
5796de7de3 Merge pull request #12 from alicanli1995/dev-branch
Dev branch
2022-07-14 23:49:47 +03:00
Ali CANLI
efbeeacb39 Bug fixed and preparing for OutBox Pattern For Transaction Management. 2022-07-14 23:49:23 +03:00
Ali CANLI
22f85a86d8 Implement SAGA Pattern commit and rollback. 2022-07-14 15:45:32 +03:00
Ali CANLI
cb82db92b8 Merge pull request #11 from alicanli1995/dev-branch
Dev branch
2022-07-14 09:58:41 +03:00
Ali CANLI
1f68e35324 Completed all services and last commit before saga pattern. 2022-07-14 09:57:08 +03:00
Ali CANLI
2282519f69 Add Restaurant-Service domain layer. 2022-07-13 21:16:20 +03:00
Ali CANLI
fedf7cb36b Merge pull request #10 from alicanli1995/dev-branch
Dev branch
2022-07-13 14:59:59 +03:00
Ali CANLI
bed8d4d858 Add Payment-Service 2022-07-13 14:59:27 +03:00
Ali CANLI
ef9c18bfbd Add payment domain and data access modules 2022-07-13 12:49:02 +03:00
Ali CANLI
de1f5574e9 Merge pull request #9 from alicanli1995/dev-branch
Dev branch
2022-07-12 22:57:22 +03:00
Ali CANLI
2071a3dd86 Fix bug 2022-07-12 14:52:41 +03:00
Ali CANLI
473bd30dda Fix bug and delete test for now 2022-07-12 13:00:41 +03:00
Ali CANLI
2377262b64 Add 2022-07-12 12:48:42 +03:00
Ali CANLI
ddd0655895 Merge pull request #8 from alicanli1995/dev-branch
Dev branch
2022-07-11 13:35:43 +03:00
Ali CANLI
f4e7ee19cf Implements to data access layer for all domain 2022-07-11 13:35:05 +03:00
Ali CANLI
9780156ea8 Add Global Exception Handler Classes and OrderGlobalException.java classes 2022-07-11 12:11:27 +03:00
Ali CANLI
e6a515961a Merge pull request #7 from alicanli1995/dev-branch
Dev branch
2022-07-11 00:38:18 +03:00
Ali CANLI
80bc6c6de7 Add Kafka Generic Consumer And Producer Classes 2022-07-11 00:37:34 +03:00
Ali CANLI
a3918a8cef Add Kafka Config And Kafka Init Docker-Compose files. 2022-07-10 22:08:14 +03:00
Ali CANLI
1238b3ae6b Add Domain Test Classes 2022-07-10 18:11:53 +03:00
Ali CANLI
82ccf5b1a8 Merge pull request #6 from alicanli1995/dev-branch
Add Application Publish Event Layer
2022-07-10 13:44:37 +03:00
Ali CANLI
21d91abe62 Merge pull request #5 from alicanli1995/dev-branch
Add application service classes.
2022-07-10 13:05:46 +03:00
Ali CANLI
d79962723f Merge pull request #4 from alicanli1995/dev-branch
Dev branch
2022-07-09 22:11:07 +03:00
Ali CANLI
dcd07eda36 Merge pull request #3 from alicanli1995/dev-branch
Add Domain Core Classes And Common Domain Module.
2022-07-09 20:34:28 +03:00
Ali CANLI
e930046e4e Merge pull request #2 from alicanli1995/dev-branch
Hell0
2022-07-08 23:43:54 +03:00
359 changed files with 15012 additions and 405 deletions

3
.gitignore vendored
View File

@@ -30,4 +30,5 @@ build/
!**/src/test/**/build/
### VS Code ###
.vscode/
.vscode/
/infrastructure/docker-compose/volumes/

45
.idea/compiler.xml generated
View File

@@ -11,8 +11,27 @@
<module name="order-application-service" />
<module name="common-domain" />
<module name="order-core-domain" />
<module name="customer-container" />
<module name="customer-service-application" />
<module name="restaurant-core-domain" />
<module name="payment-domain-core" />
<module name="saga" />
<module name="restaurant-application-service" />
<module name="customer-messaging" />
<module name="order-application-service" />
<module name="kafka-producer" />
<module name="customer-data-access" />
<module name="order-data-access" />
<module name="payment-dataaccess" />
<module name="common-data-access" />
<module name="outbox" />
<module name="order-container" />
<module name="order-app" />
<module name="restaurant-dataaccess" />
<module name="payment-container" />
<module name="customer-application" />
<module name="customer-domain-core" />
<module name="restaurant-messaging" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
@@ -21,9 +40,26 @@
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="common" options="-parameters" />
<module name="clean-hexagonal-architecture-kafka-saga-outbox" options="" />
<module name="common" options="" />
<module name="common-application" options="-parameters" />
<module name="common-data-access" options="-parameters" />
<module name="common-domain" options="-parameters" />
<module name="customer-application" options="-parameters" />
<module name="customer-container" options="-parameters" />
<module name="customer-data-access" options="-parameters" />
<module name="customer-domain" options="" />
<module name="customer-domain-core" options="-parameters" />
<module name="customer-messaging" options="-parameters" />
<module name="customer-service" options="" />
<module name="customer-service-application" options="-parameters" />
<module name="food-ordering-system" options="" />
<module name="infrastructure" options="" />
<module name="kafka" options="" />
<module name="kafka-config" options="-parameters" />
<module name="kafka-consumer" options="-parameters" />
<module name="kafka-model" options="-parameters" />
<module name="kafka-producer" options="-parameters" />
<module name="order-app" options="-parameters" />
<module name="order-application-service" options="-parameters" />
<module name="order-container" options="-parameters" />
@@ -33,6 +69,13 @@
<module name="order-domain-core" options="-parameters" />
<module name="order-messaging" options="-parameters" />
<module name="order-service" options="" />
<module name="payment-application-service" options="-parameters" />
<module name="payment-container" options="-parameters" />
<module name="payment-dataaccess" options="-parameters" />
<module name="payment-domain" options="" />
<module name="payment-domain-core" options="-parameters" />
<module name="payment-messaging" options="-parameters" />
<module name="payment-service" options="-parameters" />
</option>
</component>
</project>

20
.idea/encodings.xml generated
View File

@@ -4,6 +4,26 @@
<file url="file://$PROJECT_DIR$/common/common-domain/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/common/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/common/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/customer-service/customer-application/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/customer-service/customer-container/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/customer-service/customer-data-access/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/customer-service/customer-domain/customer-domain-core/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/customer-service/customer-domain/customer-service-application/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/customer-service/customer-domain/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/customer-service/customer-domain/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/customer-service/customer-messaging/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/customer-service/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/customer-service/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/infrastructure/kafka/kafka-config/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/infrastructure/kafka/kafka-consumer/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/infrastructure/kafka/kafka-model/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/infrastructure/kafka/kafka-producer/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/infrastructure/kafka/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/infrastructure/kafka/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/infrastructure/outbox/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/infrastructure/saga/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/infrastructure/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/infrastructure/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/order-service/order-app/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/order-service/order-app/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/order-service/order-container/src/main/java" charset="UTF-8" />

View File

@@ -7,27 +7,322 @@ U
%order-service/order-container/pom.xml,5\e\5edc4f773e0205d9c5812143cbbd1132b3c3de4c
O
order-service/order-app/pom.xml,2\5\255f6fd0140e765f25a0c5ea7d6c33af3bb1ecec
U
%order-service/order-messaging/pom.xml,c\1\c19aa6db8e37c3805307311ca17ddea372646d36
R
"order-service/order-domain/pom.xml,6\c\6c488d4235eb8af9fe6c7a0dcd6d396f5fb3b9db
L
common/common-domain/pom.xml,3\e\3ebe72cff67b25b3f376cc963b57146cc5d43487
>
common/pom.xml,4\8\488bdbea7e8b73c44bd2a54e63f6012f10969196
7
pom.xml,4\4\442292b8a7efeabbe4cc176709b833b1792140ec
<EFBFBD>
vorder-service/order-domain/order-core-domain/src/main/java/com/food/order/system/domain/valueobject/StreetAddress.java,f\7\f74133100119166e8b876daa424b93e0d64b9b80
<EFBFBD>
sorder-service/order-data-access/src/main/java/com/food/order/system/data/access/customer/entity/CustomerEntity.java,a\3\a3d0249dc9ec483df31a5f520a586bcdbe6f777c
<EFBFBD>
~order-service/order-data-access/src/main/java/com/food/order/system/data/access/customer/repository/CustomerJPARepository.java,5\4\548371b5e6ebbbbe24b839de042f70fc2f764316
<EFBFBD>
xorder-service/order-data-access/src/main/java/com/food/order/system/data/access/order/repository/OrderJpaRepository.java,4\0\40da9fb64727cbca8732bf490a71748e13ad2197
E
order-service/pom.xml,d\3\d3bf53ecc442740843266a635cbfe9807b992566
<EFBFBD>
Qcommon/common-domain/src/main/java/com/food/order/domain/valueobject/OrderId.java,7\3\73533e03c456839a625223f6070a82fe26a051d1
<EFBFBD>
Rcommon/common-domain/src/main/java/com/food/order/sysyem/entity/AggregateRoot.java,c\c\cc687f6a595bab80c5e573f18747043940db2e05

Ocommon/common-domain/src/main/java/com/food/order/domain/valueobject/Money.java,1\9\19055dd2bdebc31a1868d96dadab8510f24e71ee
<EFBFBD>
Ucommon/common-domain/src/main/java/com/food/order/domain/valueobject/OrderStatus.java,6\a\6a4ab22cb9f8e43dd5b01a714d3f60035154029f
<EFBFBD>
Scommon/common-domain/src/main/java/com/food/order/domain/valueobject/ProductId.java,9\0\90ca37cd91bd840352dc5fe9846f4b160b829982
<EFBFBD>
Vcommon/common-domain/src/main/java/com/food/order/domain/valueobject/RestaurantId.java,b\d\bd99e8fd918c1d01925143dbc2e08a8064258f70
<EFBFBD>
Tcommon/common-domain/src/main/java/com/food/order/domain/valueobject/CustomerId.java,c\2\c2aadaf5638ecab2404c0c3149e923f596cb777d
Ocommon/common-domain/src/main/java/com/food/order/sysyem/entity/BaseEntity.java,f\b\fbda5fe4b42ac2a311824c02836f11c7d24db0d3
<EFBFBD>
^order-service/order-container/src/main/java/com/food/order/system/order/domain/BeanConfig.java,a\1\a1c09366ca4c2abdfc90bc1beacf797ac2103a3b
<EFBFBD>
{order-service/order-domain/order-application-service/src/main/java/com/food/order/sysyem/dto/create/CreateOrderCommand.java,d\c\dc92bf07b0bed6658fc54cbe0ff01dbeee0c414c
<EFBFBD>
lorder-service/order-domain/order-core-domain/src/main/java/com/food/order/system/domain/entity/Customer.java,7\4\74a68a7e9f08b7fca383a0d424516f5987b099dd
<EFBFBD>
}order-service/order-data-access/src/main/java/com/food/order/system/data/access/customer/mapper/CustomerDataAccessMapper.java,8\6\869ec14f296d908f53b6edd9f087f51238dffec0
<EFBFBD>
Tcommon/common-domain/src/main/java/com/food/order/sysyem/valueobject/CustomerId.java,5\0\500e4021725078024436d6eaddaf3a5ce80f87c3
<EFBFBD>
<EFBFBD>order-service/order-domain/order-application-service/src/main/java/com/food/order/sysyem/ports/output/repository/CustomerRepository.java,2\4\243d2baeb6d671f73acce01d5673f03f03328ae7
<EFBFBD>
|order-service/order-data-access/src/main/java/com/food/order/system/data/access/customer/adapter/CustomerRepositoryImpl.java,8\0\808a4e6022bab0f1bb8e5502a77c933f746cb380
<EFBFBD>
Wcommon/common-domain/src/main/java/com/food/order/sysyem/exception/DomainException.java,b\c\bc831ad083de7cf458fb4a2ebce1d9434a1922ee
<EFBFBD>
uorder-service/order-domain/order-application-service/src/main/java/com/food/order/sysyem/dto/create/OrderAddress.java,5\e\5e090b61d663849123e622ef98bfe4742229191a
<EFBFBD>
morder-service/order-data-access/src/main/java/com/food/order/system/data/access/order/entity/OrderEntity.java,e\d\ede9a92270a067f79a85b238a144b459eca8662b
<EFBFBD>
Qcommon/common-domain/src/main/java/com/food/order/sysyem/valueobject/OrderId.java,c\d\cdff6de4b3446e3efaa50f9d01263053fea2139c
<EFBFBD>
rorder-service/order-domain/order-application-service/src/main/java/com/food/order/sysyem/dto/create/OrderItem.java,f\b\fb43567b0066ced0815bbf02432cd16fed9c608a
<EFBFBD>
torder-service/order-domain/order-core-domain/src/main/java/com/food/order/system/domain/valueobject/OrderItemId.java,3\3\331b29df1b4bc0c1299f8bb1af8f70edf79e923a
<EFBFBD>
}order-service/order-domain/order-core-domain/src/main/java/com/food/order/system/domain/exception/OrderNotFoundException.java,a\3\a31c0821fec53a50af20e3383ba61e44d9dd567d
<EFBFBD>
vorder-service/order-domain/order-application-service/src/main/java/com/food/order/sysyem/OrderTrackCommandHandler.java,f\2\f2d0dd97f438393a8cc6c9859c953f3d005925ed
<EFBFBD>
korder-service/order-domain/order-core-domain/src/main/java/com/food/order/system/domain/entity/Product.java,0\5\05295c0ef124c56014b3b6b04e0808e407995151
<EFBFBD>
Scommon/common-domain/src/main/java/com/food/order/sysyem/valueobject/ProductId.java,b\0\b0d8076babec863faea4aefc2e42755cde57012c
<EFBFBD>
<EFBFBD>order-service/order-domain/order-application-service/src/main/java/com/food/order/sysyem/dto/message/RestaurantApprovalResponse.java,c\b\cb772c96c93d2fc2e4fc760f3d40a29945b2c327
<EFBFBD>
<EFBFBD>order-service/order-domain/order-application-service/src/main/java/com/food/order/sysyem/ports/input/message/listener/restaurantapproval/RestaurantApprovalResponseMessageListener.java,6\9\690a6444f8a326a40054c16acbcb8c4d3e14ebf4
<EFBFBD>
Vcommon/common-domain/src/main/java/com/food/order/sysyem/valueobject/RestaurantId.java,2\b\2b3a056b9b3fde4b15f1d05d7861846d59926dfa
<EFBFBD>
sorder-service/order-domain/order-core-domain/src/main/java/com/food/order/system/domain/valueobject/TrackingId.java,0\c\0c483d5138a4e1e7237a72d7888989bcd840fe2c
<EFBFBD>
worder-service/order-domain/order-application-service/src/main/java/com/food/order/sysyem/dto/track/TrackOrderQuery.java,1\4\149b5ecef8503b928e6b223bb6db52a4a3a6afe5
<EFBFBD>
zorder-service/order-domain/order-application-service/src/main/java/com/food/order/sysyem/dto/track/TrackOrderResponse.java,3\4\34e02ed9f253ce066f33cd48e40346510e7fb7cf
<EFBFBD>
qorder-service/order-data-access/src/main/java/com/food/order/system/data/access/order/entity/OrderItemEntity.java,c\5\c520ec00a75c1b87bc1497a34f1b0acab96aedeb
<EFBFBD>
sorder-service/order-data-access/src/main/java/com/food/order/system/data/access/order/entity/OrderItemEntityId.java,f\2\f20575f9c726daa75f956eb5c320094d8a1b65f8
<EFBFBD>
<EFBFBD>order-service/order-domain/order-application-service/src/main/java/com/food/order/sysyem/ports/input/message/listener/payment/PaymentResponseMessageListener.java,d\7\d7462ec5060343a2ca3aa497ba1550597538e5d5
9
README.md,8\e\8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d
<EFBFBD>
minfrastructure/kafka/kafka-config/src/main/java/com/food/order/kafka/config/data/KafkaProducerConfigData.java,1\4\147bb8ad56bcda10398aa4b9b972f2386b09c40a
<EFBFBD>
oinfrastructure/kafka/kafka-producer/src/main/java/com/food/order/system/kafka/producer/KafkaProducerConfig.java,4\e\4e08bd5115c637166f591a535fffd0ab92a42d18
H
customer-service/pom.xml,5\8\5828c3b58c65a5dabc2340b48a37b3e92462b9b0
L
infrastructure/kafka/pom.xml,5\7\57d8d8349e1f824686cd44fe2200377b17148804
[
+infrastructure/docker-compose/zookeeper.yml,2\5\25078b0f9296433af7750df1603d7c084625fc0f
X
(infrastructure/docker-compose/common.yml,5\9\59e2079c706300654edfdfefb1b0258617f514b7
<EFBFBD>
{order-service/order-domain/order-application-service/src/main/java/com/food/order/sysyem/config/OrderServiceConfigData.java,9\5\954530d266381bab329eaec2c32fb8af09ce6299
_
/infrastructure/docker-compose/kafka_cluster.yml,5\e\5e8bb3a16c76d6344e1b199d9d28ca41c06d612b
<EFBFBD>
Pcommon/common-domain/src/main/java/com/food/order/sysyem/valueobject/BaseId.java,8\f\8f3bd12b2221204ce618b7bdc1917bf908f691b5
<EFBFBD>
Wcommon/common-domain/src/main/java/com/food/order/sysyem/valueobject/PaymentStatus.java,9\d\9d04fc94054bc74c3883af7f460ea23903ce071b
\
,infrastructure/docker-compose/init_kafka.yml,1\2\12c3aaa4a5ab6d91f1d0c2439dd959f1f4446e70
R
"infrastructure/docker-compose/.env,8\4\84825da1de32497b36ece2e7280bf9e7ea2fc807
:
.gitignore,a\5\a5cc2925ca8258af241be7e5b0381edf30266302
<EFBFBD>
<EFBFBD>payment-service/payment-dataaccess/src/main/java/com/food/order/system/payment/data/access/creditentry/exception/CreditEntryDataaccessException.java,9\9\99186cf850e4c3c7b7cead5e8f5e10f4a2990dd7
<EFBFBD>
<EFBFBD>payment-service/payment-dataaccess/src/main/java/com/food/order/system/payment/data/access/creditentry/mapper/CreditEntryDataAccessMapper.java,5\3\5312c112e34b9c3095b953321c14a4abdd5a5c98
<EFBFBD>
<EFBFBD>payment-service/payment-domain/payment-domain-core/src/main/java/com/food/order/system/payment/service/domain/valueobject/CreditEntryId.java,8\b\8bb3443859c229b62ae98e219040b1aacb946386
<EFBFBD>
<EFBFBD>payment-service/payment-dataaccess/src/main/java/com/food/order/system/payment/data/access/creditentry/repository/CreditEntryJpaRepository.java,f\b\fbeba1493b7f71dfd93b47fbff84da00e2007f84
<EFBFBD>
<EFBFBD>payment-service/payment-domain/payment-application-service/src/main/java/com/food/order/system/payment/application/service/ports/output/repository/CreditEntryRepository.java,c\a\caa192dc17f91ee8b749c660717a36184a3c05d6
<EFBFBD>
<EFBFBD>payment-service/payment-dataaccess/src/main/java/com/food/order/system/payment/data/access/creditentry/adapter/CreditEntryRepositoryImpl.java,6\a\6aa6e8ce5f9da7083389c855e733743d921bfba9
<EFBFBD>
<EFBFBD>payment-service/payment-dataaccess/src/main/java/com/food/order/system/payment/data/access/credithistory/exception/CreditHistoryDataaccessException.java,d\3\d3f4a2c48e4ecf8c7e126c04208ec05e507174fb
<EFBFBD>
<EFBFBD>payment-service/payment-dataaccess/src/main/java/com/food/order/system/payment/data/access/credithistory/mapper/CreditHistoryDataAccessMapper.java,9\8\98c57fc875d10886d09efd0ddb7b39a82e37cb78
<EFBFBD>
<EFBFBD>payment-service/payment-dataaccess/src/main/java/com/food/order/system/payment/data/access/credithistory/entity/CreditHistoryEntity.java,6\5\651230dc70c13cbfad780494568f27d0ef9209bd
<EFBFBD>
<EFBFBD>payment-service/payment-domain/payment-domain-core/src/main/java/com/food/order/system/payment/service/domain/valueobject/CreditHistoryId.java,8\0\80c44aeefda382eff76cd9f8c74bd0c670c73e65
}
Mcommon/common-domain/src/main/java/com/food/order/sysyem/DomainConstants.java,e\5\e5b584bef3ba718cae24b87e69ece8ea43c2fb8f

Ocommon/common-domain/src/main/java/com/food/order/sysyem/valueobject/Money.java,f\2\f2f10975dd8765fc764570c28a233a3a9c89cdd0
<EFBFBD>
<EFBFBD>payment-service/payment-domain/payment-domain-core/src/main/java/com/food/order/system/payment/service/domain/exception/PayemntDomainException.java,c\6\c623edfbee9db5cb30319890907999902d4ccae0
<EFBFBD>
<EFBFBD>payment-service/payment-domain/payment-application-service/src/main/java/com/food/order/system/payment/application/service/exception/PaymentApplicationServiceException.java,d\9\d9d957f98d7f0d30a2adea129ac4631b206fc061
<EFBFBD>
<EFBFBD>payment-service/payment-domain/payment-domain-core/src/main/java/com/food/order/system/payment/service/domain/event/PaymentCancelledEvent.java,5\6\560399a9750e4d9dafde7225b7302534c0ed9d4a
<EFBFBD>
<EFBFBD>payment-service/payment-domain/payment-application-service/src/main/java/com/food/order/system/payment/application/service/ports/output/message/publisher/PaymentCancelledMessagePublisher.java,0\b\0ba58cf064e11f82c83aa840d4af085fe0cc0c0d
<EFBFBD>
<EFBFBD>payment-service/payment-domain/payment-domain-core/src/main/java/com/food/order/system/payment/service/domain/event/PaymentCompletedEvent.java,5\0\509a6d6aab18102a92a942a4dd736bd4110afb6c
<EFBFBD>
<EFBFBD>payment-service/payment-domain/payment-application-service/src/main/java/com/food/order/system/payment/application/service/ports/output/message/publisher/PaymentCompletedMessagePublisher.java,4\b\4b8f46ac54964317cd5f358f1a462e6b73fba663
<EFBFBD>
<EFBFBD>payment-service/payment-dataaccess/src/main/java/com/food/order/system/payment/data/access/payment/exception/PaymentDataaccessException.java,a\5\a5ece490bea2fd2276a3bf51703a92fffd10a2fd
<EFBFBD>
<EFBFBD>payment-service/payment-domain/payment-domain-core/src/main/java/com/food/order/system/payment/service/domain/event/PaymentEvent.java,1\5\1596dfb82cc42ada4d77f57e2707ef856a3c491d
<EFBFBD>
<EFBFBD>payment-service/payment-domain/payment-domain-core/src/main/java/com/food/order/system/payment/service/domain/event/PaymentFailedEvent.java,3\a\3af8e86e31391041e86e161d3eec0e009faa038e
<EFBFBD>
<EFBFBD>payment-service/payment-domain/payment-application-service/src/main/java/com/food/order/system/payment/application/service/ports/output/message/publisher/PaymentFailedMessagePublisher.java,5\f\5fe51c223681307c2b7b97965c69c53d8e3ee085
<EFBFBD>
<EFBFBD>payment-service/payment-domain/payment-domain-core/src/main/java/com/food/order/system/payment/service/domain/valueobject/PaymentId.java,8\5\8517e077559b83db762f2451a5dabe31961fb8b7
<EFBFBD>
<EFBFBD>payment-service/payment-dataaccess/src/main/java/com/food/order/system/payment/data/access/payment/repository/PaymentJpaRepository.java,d\0\d08709acd3c6ce0ea804ce4d7b2272e450c9c58b
<EFBFBD>
<EFBFBD>payment-service/payment-domain/payment-domain-core/src/main/java/com/food/order/system/payment/service/domain/exception/PaymentNotFoundException.java,d\5\d578afe6988eefbb0bc312beb1538ca09b3d016d
<EFBFBD>
\common/common-domain/src/main/java/com/food/order/sysyem/valueobject/PaymentOrderStatus.java,8\c\8cfc34311283c9ce79c84a4bda4eec7d30ed49f8
<EFBFBD>
<EFBFBD>payment-service/payment-domain/payment-application-service/src/main/java/com/food/order/system/payment/application/service/ports/output/repository/PaymentRepository.java,f\9\f9261dfed13ff6ca5d1ea0b592251a98717ade8a
<EFBFBD>
<EFBFBD>payment-service/payment-domain/payment-application-service/src/main/java/com/food/order/system/payment/application/service/dto/PaymentRequest.java,5\4\5491134569866d37cf17fafc904a9cc411b03901
Z
*payment-service/payment-dataaccess/pom.xml,e\1\e111ed261baa772cb4d6e08c563771132311486d
G
payment-service/pom.xml,2\5\25baee198b18cf264e9c0dcfc72630a226ed792c
<EFBFBD>
<EFBFBD>payment-service/payment-dataaccess/src/main/java/com/food/order/system/payment/data/access/credithistory/repository/CreditHistoryJpaRepository.java,b\4\b49bb07e3985f218ed2efad0cefe57332bd4048b
<EFBFBD>
<EFBFBD>payment-service/payment-dataaccess/src/main/java/com/food/order/system/payment/data/access/creditentry/entity/CreditEntryEntity.java,a\7\a79105dd255d06e1d0efa727796643bd3386bf96
U
%order-service/order-messaging/pom.xml,c\1\c19aa6db8e37c3805307311ca17ddea372646d36
[
+infrastructure/kafka/kafka-producer/pom.xml,c\7\c7d5ce453d66546bb66d7c5bfe5df1f88d0c5862
<EFBFBD>
<EFBFBD>payment-service/payment-domain/payment-application-service/src/main/java/com/food/order/system/payment/application/service/config/PaymentServiceConfigData.java,e\b\eb7f9fbb0b2cace2df92dc9d5819ed6a5456d638
X
(infrastructure/kafka/kafka-model/pom.xml,b\5\b5ebdc449af44ac439d81aad072e585df2d63cc3
<EFBFBD>
lpayment-service/payment-container/src/main/java/com/food/order/system/payment/service/domain/BeanConfig.java,0\e\0e2f043af840a6f0c4c5f494dfa373e6a3287249
<EFBFBD>
ninfrastructure/kafka/kafka-producer/src/main/java/com/food/order/system/kafka/producer/KafkaMessageHelper.java,a\5\a5b1ed3b934da0d7bc46e6247f017849d828fa02
<EFBFBD>
tinfrastructure/kafka/kafka-model/src/main/java/com/food/order/system/kafka/order/avro/model/OrderApprovalStatus.java,b\7\b7f6ce9c30dde5a5d9eb8055e83a4d3ee604e570
<EFBFBD>
<EFBFBD>payment-service/payment-messaging/src/main/java/com/food/order/system/payment/messaging/publisher/kafka/PaymentCancelledKafkaMessagePublisher.java,4\2\42f2413f9746aa30ed7d496b9575ecff8f20a2d5
<EFBFBD>
<EFBFBD>payment-service/payment-messaging/src/main/java/com/food/order/system/payment/messaging/publisher/kafka/PaymentCompletedKafkaMessagePublisher.java,f\4\f429e4c46229dca472857e4323ab89434a74ee69
<EFBFBD>
<EFBFBD>payment-service/payment-messaging/src/main/java/com/food/order/system/payment/messaging/publisher/kafka/PaymentFailedKafkaMessagePublisher.java,1\a\1a308906df5384e6c40641fda8a58d0a640d3f03
<EFBFBD>
sinfrastructure/kafka/kafka-model/src/main/java/com/food/order/system/kafka/order/avro/model/PaymentOrderStatus.java,2\9\290b3da55c67b50389607e38ae95a4cb6cba4d71
<EFBFBD>
xinfrastructure/kafka/kafka-model/src/main/java/com/food/order/system/kafka/order/avro/model/PaymentRequestAvroModel.java,f\7\f77456f16799869df9c5c5715d2f8ed3497c2519
<EFBFBD>
yinfrastructure/kafka/kafka-model/src/main/java/com/food/order/system/kafka/order/avro/model/PaymentResponseAvroModel.java,1\e\1e0c9165eec9a3a8770a07d72e38f1137af3eb60
<EFBFBD>
ninfrastructure/kafka/kafka-model/src/main/java/com/food/order/system/kafka/order/avro/model/PaymentStatus.java,3\6\3672be2bd188cd93638a2a699d7fee6459eed2b4
Y
)payment-service/payment-messaging/pom.xml,5\6\56ed16c723f2655c00ae8a35fc001c9d1a71de99
<EFBFBD>
hinfrastructure/kafka/kafka-model/src/main/java/com/food/order/system/kafka/order/avro/model/Product.java,e\9\e91d1d55ba1a38aca2893c014a5b2ff03826ac50
<EFBFBD>
<EFBFBD>infrastructure/kafka/kafka-model/src/main/java/com/food/order/system/kafka/order/avro/model/RestaurantApprovalResponseAvroModel.java,1\a\1a8cdd6c032310eea6aa5e9eea4a4f44064cf6c4
<EFBFBD>
vinfrastructure/kafka/kafka-model/src/main/java/com/food/order/system/kafka/order/avro/model/RestaurantOrderStatus.java,5\0\50e4cb633ca3265d27ba402a4fa00cfe3710ab77
<EFBFBD>
_common/common-domain/src/main/java/com/food/order/sysyem/valueobject/RestaurantOrderStatus.java,d\e\de5a9499cfd1de9312944b07ebf035e6f38db482
Y
)payment-service/payment-container/pom.xml,d\3\d319507d8930e27b35fa7ea166ac3b4a66d68640
U
%order-service/order-container/pom.xml,5\e\5edc4f773e0205d9c5812143cbbd1132b3c3de4c
j
:payment-service/payment-domain/payment-domain-core/pom.xml,8\0\8064d0f20ca168afe879cc5b60a151cdacfb6d52
<EFBFBD>
<EFBFBD>payment-service/payment-domain/payment-application-service/src/main/java/com/food/order/system/payment/application/service/mapper/PaymentDataMapper.java,f\1\f1792c5c7fb68c718b5d80fa1ba2e668f2890e6a
V
&payment-service/payment-domain/pom.xml,f\d\fdf4fe8ba7be6f4753e22faf477b9766890d753d
R
"order-service/order-domain/pom.xml,6\c\6c488d4235eb8af9fe6c7a0dcd6d396f5fb3b9db
<EFBFBD>
<EFBFBD>restaurant-service/restaurant-domain/restaurant-core-domain/src/main/java/com/food/order/system/restaurant/domain/core/entity/OrderApproval.java,4\8\489b3cdfab8fecd434040344d80ecad6ceee200c
<EFBFBD>
<EFBFBD>restaurant-service/restaurant-domain/restaurant-core-domain/src/main/java/com/food/order/system/restaurant/domain/core/event/OrderApprovalEvent.java,c\4\c418505b723576c31849d8c877c81542930f66f8
<EFBFBD>
<EFBFBD>restaurant-service/restaurant-domain/restaurant-core-domain/src/main/java/com/food/order/system/restaurant/domain/core/valueobject/OrderApprovalId.java,9\e\9e982695e9dc9b623937a3d13ac8887af6084c33
<EFBFBD>
<EFBFBD>restaurant-service/restaurant-dataaccess/src/main/java/com/food/order/system/data/access/restaurant/repository/OrderApprovalJpaRepository.java,4\c\4c30cce37540f6fb9aceb3833e8dc5ea4ba8e977
<EFBFBD>
<EFBFBD>restaurant-service/restaurant-domain/restaurant-core-domain/src/main/java/com/food/order/system/restaurant/domain/core/event/OrderApprovedEvent.java,3\b\3b201270232a1a2c94a8188804153294f38e3c38
<EFBFBD>
<EFBFBD>restaurant-service/restaurant-domain/restaurant-core-domain/src/main/java/com/food/order/system/restaurant/domain/core/event/OrderRejectedEvent.java,5\d\5dd879e29cd62beb97a50b23474d24e68deabe86
Q
!common/common-data-access/pom.xml,3\2\32df6d070f4ffc683364c978efd79428b5d050d1
W
'order-service/order-data-access/pom.xml,f\2\f258deaeb6ebc953857cf7cb5342c2c6d7f03934
r
Bpayment-service/payment-domain/payment-application-service/pom.xml,6\d\6d756c3c984cf48b9a51e07334cc94cf28ea1fe5
_
/restaurant-service/restaurant-container/pom.xml,0\4\04c5d73b814c0fa8d99213001aba2ffead7cf2e2
`
0restaurant-service/restaurant-dataaccess/pom.xml,4\9\49d0c1c1fb43880d1807f9fed48d285c58a50d73
{
Krestaurant-service/restaurant-domain/restaurant-application-service/pom.xml,6\1\6117ad0ec12432616d07d621911c1bc4f02f80d6
s
Crestaurant-service/restaurant-domain/restaurant-core-domain/pom.xml,f\4\f4182ab70945af3ada6221f0e18bf8f1fac7e2eb
\
,restaurant-service/restaurant-domain/pom.xml,5\2\528286e8455474a164649915961cfe43c36d78f2
_
/restaurant-service/restaurant-messaging/pom.xml,e\3\e3c0a92269005ce0f801ef2dc06d6aa1a00e1a16
J
restaurant-service/pom.xml,f\1\f1a73488b9e5d5fe78f637b81387a1a03077be0d
<EFBFBD>
}common/common-data-access/src/main/java/com/food/order/system/common/data/access/exception/RestaurantDataAccessException.java,2\9\29f5af9e9b97dd442e3b2762d7206f3cdd3d44fc
<EFBFBD>
<EFBFBD>order-service/order-data-access/src/main/java/com/food/order/system/data/access/restaurant/mapper/RestaurantDataAccessMapper.java,d\f\df56aea6e7cca961acdfb2d7e0845d7c11affe80
<EFBFBD>
<EFBFBD>restaurant-service/restaurant-domain/restaurant-core-domain/src/main/java/com/food/order/system/restaurant/domain/core/exception/RestaurantDomainException.java,0\1\01f10855589a69717b3d534bc555c4b4ebf71011
<EFBFBD>
ocommon/common-data-access/src/main/java/com/food/order/system/common/data/access/entity/RestaurantEntityId.java,f\9\f9caeadd0ffb8d25d2a99850208b70c1a8784f2f
<EFBFBD>
<EFBFBD>restaurant-service/restaurant-domain/restaurant-core-domain/src/main/java/com/food/order/system/restaurant/domain/core/exception/RestaurantNotFoundException.java,2\7\271e8c6599a9b47753cdb7561d54460059472bd6
<EFBFBD>
ecustomer-service/src/main/java/com/food/order/system/customer/service/CustomerServiceApplication.java,3\9\393f6fa7c918c4529954de3370ff366d10d7a212
<EFBFBD>
<EFBFBD>restaurant-service/restaurant-domain/restaurant-core-domain/src/main/java/com/food/order/system/restaurant/domain/core/entity/Restaurant.java,6\a\6a9d2207b0d9ce51a7359468f7a04bcca116f635
<EFBFBD>
<EFBFBD>restaurant-service/restaurant-domain/restaurant-core-domain/src/main/java/com/food/order/system/restaurant/domain/core/RestaurantDomainServiceImpl.java,4\d\4d877c39a261599f8c4a8c4a790ff3143fedcb26
<EFBFBD>
<EFBFBD>restaurant-service/restaurant-domain/restaurant-application-service/src/main/java/com/food/order/system/restaurant/domain/service/ports/output/repository/RestaurantRepository.java,a\0\a09c218d21582858a2e9072e9616706d9bbca56c
<EFBFBD>
zinfrastructure/kafka/kafka-producer/src/main/java/com/food/order/system/kafka/producer/service/impl/KafkaProducerImpl.java,3\6\360e8906e84c982c90c5204b896ff036da101c21
<EFBFBD>
mcommon/common-data-access/src/main/java/com/food/order/system/common/data/access/entity/RestaurantEntity.java,f\6\f6d6367160c5a21258ddb22c3d6e6016faf5ce07
<EFBFBD>
morder-service/order-domain/order-core-domain/src/main/java/com/food/order/system/domain/entity/OrderItem.java,4\1\41efbf587fa2c3edceea298959ed919f554f5ec6
<EFBFBD>
|order-service/order-domain/order-application-service/src/main/java/com/food/order/sysyem/dto/create/CreateOrderResponse.java,d\e\defb0c01f5710b54b1cb7fcf9550f2a8df2d65c9
<EFBFBD>
`order-service/order-app/src/main/java/com/food/order/system/service/app/api/OrderController.java,b\b\bb92862728c8d04eaf070a4132867fd23ba8b073
<EFBFBD>
<EFBFBD>order-service/order-domain/order-application-service/src/main/java/com/food/order/sysyem/ports/input/service/OrderApplicationService.java,a\d\ad40314bdf019aafa5a9fa840f32dfc101f16bea
<EFBFBD>
vorder-service/order-messaging/src/main/java/com/food/order/system/order/messaging/mapper/OrderMessagingDataMapper.java,1\c\1c7014ddd3deb73cf65c929b0b924af0cff53ddc
<EFBFBD>
yorder-service/order-domain/order-application-service/src/main/java/com/food/order/sysyem/OrderApplicationServiceImpl.java,5\7\57bd77f4a2092ee1117f6cac595ab47398708c81
<EFBFBD>
|payment-service/payment-dataaccess/src/main/java/com/food/order/system/payment/data/access/payment/entity/PaymentEntity.java,7\7\77ecb63f035d722547f8055c99803d5a146c0c32
<EFBFBD>
<EFBFBD>payment-service/payment-dataaccess/src/main/java/com/food/order/system/payment/data/access/payment/mapper/PaymentDataAccessMapper.java,7\2\72f54cc6a6946cf708c67d75e842373fb9f5fc16
<EFBFBD>
<EFBFBD>payment-service/payment-dataaccess/src/main/java/com/food/order/system/payment/data/access/payment/adapter/PaymentRepositoryImpl.java,1\0\10d78edd523b7510aa2d72821d4312c8f7f63f55
<EFBFBD>
<EFBFBD>payment-service/payment-domain/payment-application-service/src/main/java/com/food/order/system/payment/application/service/PaymentRequestHelper.java,6\1\61be9c5145d9055f5954e0566c9a1e8d6fc9fd4e
<EFBFBD>
<EFBFBD>payment-service/payment-domain/payment-domain-core/src/main/java/com/food/order/system/payment/service/domain/PaymentDomainService.java,0\a\0ae006e1f47e9ff41c947eda574122a2af37bb76
<EFBFBD>
<EFBFBD>payment-service/payment-domain/payment-domain-core/src/main/java/com/food/order/system/payment/service/domain/entity/Payment.java,5\c\5ce3e056edb971712e013f1d85f106545fa82a6b
<EFBFBD>
]common/common-domain/src/main/java/com/food/order/sysyem/valueobject/OrderApprovalStatus.java,d\a\da94b4a105d8767dc1a7d3703a0cf9f5aa4a3c8a
<EFBFBD>
<EFBFBD>restaurant-service/restaurant-dataaccess/src/main/java/com/food/order/system/data/access/restaurant/adapter/RestaurantRepositoryImpl.java,5\2\52a371fa8697b7ce536579a6fb3247c963594327
<EFBFBD>
<EFBFBD>restaurant-service/restaurant-dataaccess/src/main/java/com/food/order/system/data/access/restaurant/mapper/RestaurantDataAccessMapper.java,5\c\5cd6a081874366e6d0447efa61720201818dcab1
<EFBFBD>
<EFBFBD>restaurant-service/restaurant-domain/restaurant-application-service/src/main/java/com/food/order/system/restaurant/domain/service/RestaurantApprovalRequestHelper.java,8\f\8f0b95d00176e23105986f415113f7143b8c9757
<EFBFBD>
iinfrastructure/kafka/kafka-consumer/src/main/java/com/food/order/system/kafka/consumer/KafkaConsumer.java,6\d\6dd91c904a2e322d48824e8e24b38786ed35276b
<EFBFBD>
<EFBFBD>payment-service/payment-domain/payment-domain-core/src/main/java/com/food/order/system/payment/service/domain/PaymentDomainServiceImpl.java,d\9\d923a60dc4b36941e851edf5b3a65ecf71ec9538
<EFBFBD>
<EFBFBD>order-service/order-messaging/src/main/java/com/food/order/system/order/messaging/listener/kafka/PaymentResponseKafkaListener.java,1\a\1ad0cd701ade8de2f4f99bb72f8885f29aef60f5
<EFBFBD>
vorder-service/order-data-access/src/main/java/com/food/order/system/data/access/order/adapter/OrderRepositoryImpl.java,4\8\48b82a9ce4c6810a73182eb48772eea8c92090ad
<EFBFBD>
<EFBFBD>order-service/order-domain/order-application-service/src/main/java/com/food/order/sysyem/ports/output/repository/OrderRepository.java,e\2\e24c8eecc55733b12167b6a7cc830d109996200a
<EFBFBD>
<EFBFBD>order-service/order-messaging/src/main/java/com/food/order/system/order/messaging/listener/kafka/RestaurantApprovalResponseKafkaListener.java,c\c\cc02e68832a991aa60651a755e207a12f99a2008
<EFBFBD>
{order-service/order-domain/order-core-domain/src/main/java/com/food/order/system/domain/exception/OrderDomainException.java,9\0\904804e65376aea729261c26d93b5f48afa2e558
<EFBFBD>
<EFBFBD>restaurant-service/restaurant-container/src/main/java/com/food/order/system/restaurant/container/RestaurantServiceApplication.java,c\1\c133c0387dc7d1323f8f5f81d35cccc39c9f77d3
<EFBFBD>
{payment-service/payment-container/src/main/java/com/food/order/system/payment/service/domain/PaymentServiceApplication.java,7\8\78ff547c94bb4c2bb4c10b68b3a21b7473ca6982
<EFBFBD>
korder-service/order-container/src/main/java/com/food/order/system/order/domain/OrderServiceApplication.java,e\c\ec346e351516b2accd95acebd4dd0f74ca1556d6
<EFBFBD>
worder-service/order-data-access/src/main/java/com/food/order/system/data/access/order/mapper/OrderDataAccessMapper.java,5\3\538c34b412bb29a862b242c09fc827eca5109504
F
infrastructure/pom.xml,2\b\2bb83dd43ff74bd2017133cd9dea6897cfe43de3

View File

@@ -0,0 +1,26 @@
<?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>common</artifactId>
<groupId>com.food.order</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>common-application</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,7 @@
package com.food.order.system.application.handler;
import lombok.Builder;
@Builder
public record ErrorDTO(String code, String message) {
}

View File

@@ -0,0 +1,59 @@
package com.food.order.system.application.handler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import javax.validation.ValidationException;
import java.util.stream.Collectors;
@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(value = {Exception.class})
@ResponseBody
public ErrorDTO handleOrderDomainException(Exception e) {
log.error("Error occurred: {}", e.getMessage());
return ErrorDTO.builder()
.code(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase())
.message("Unknown error occurred")
.build();
}
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(value = {ValidationException.class})
@ResponseBody
public ErrorDTO handleOrderDomainException(ValidationException e) {
ErrorDTO errorDTO;
if (e instanceof ConstraintViolationException) {
String violations = extractViolationsFromException((ConstraintViolationException) e);
log.error("Error occurred: {}", violations);
errorDTO = ErrorDTO.builder()
.code(HttpStatus.BAD_REQUEST.getReasonPhrase())
.message(violations)
.build();
}
else {
log.error("Error occurred: {}", e.getMessage());
errorDTO = ErrorDTO.builder()
.code(HttpStatus.BAD_REQUEST.getReasonPhrase())
.message(e.getMessage())
.build();
}
return errorDTO;
}
private String extractViolationsFromException(ConstraintViolationException e) {
return e.getConstraintViolations()
.stream()
.map(ConstraintViolation::getMessage)
.collect(Collectors.joining("->"));
}
}

View File

@@ -0,0 +1,27 @@
<?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>common</artifactId>
<groupId>com.food.order</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>common-data-access</artifactId>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,53 @@
package com.food.order.system.common.data.access.entity;
import lombok.*;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.util.UUID;
@Entity
@Table(name = "order_restaurant_m_view",schema = "restaurant")
@Getter
@Setter
@Builder
@IdClass(RestaurantEntityId.class)
@NoArgsConstructor
@AllArgsConstructor
public class RestaurantEntity {
@Id
private UUID restaurantId;
@Id
private UUID productId;
private String restaurantName;
private Boolean restaurantActive;
private String productName;
private BigDecimal productPrice;
private Boolean productAvailable;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof RestaurantEntity that)) return false;
if (!restaurantId.equals(that.restaurantId)) return false;
return productId.equals(that.productId);
}
@Override
public int hashCode() {
int result = restaurantId.hashCode();
result = 31 * result + productId.hashCode();
return result;
}
}

View File

@@ -0,0 +1,32 @@
package com.food.order.system.common.data.access.entity;
import lombok.*;
import java.io.Serializable;
import java.util.UUID;
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class RestaurantEntityId implements Serializable {
private UUID restaurantId;
private UUID productId;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof RestaurantEntityId that)) return false;
if (!restaurantId.equals(that.restaurantId)) return false;
return productId.equals(that.productId);
}
@Override
public int hashCode() {
int result = restaurantId.hashCode();
result = 31 * result + productId.hashCode();
return result;
}
}

View File

@@ -0,0 +1,7 @@
package com.food.order.system.common.data.access.exception;
public class RestaurantDataAccessException extends RuntimeException{
public RestaurantDataAccessException(String s) {
super(s);
}
}

View File

@@ -0,0 +1,14 @@
package com.food.order.system.common.data.access.repository;
import com.food.order.system.common.data.access.entity.RestaurantEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
@Repository
public interface RestaurantJpaRepository extends JpaRepository<RestaurantEntity, UUID> {
Optional<List<RestaurantEntity>> findByRestaurantIdAndProductIdIn(UUID restaurantId, List<UUID> productIds);
}

View File

@@ -0,0 +1,10 @@
package com.food.order.system;
public class DomainConstants {
private DomainConstants() {
}
public static final String UTC = "UTC";
}

View File

@@ -1,4 +1,4 @@
package com.food.order.domain.entity;
package com.food.order.system.entity;
public abstract class AggregateRoot<ID> extends BaseEntity<ID> {

View File

@@ -1,4 +1,4 @@
package com.food.order.domain.entity;
package com.food.order.system.entity;
public abstract class BaseEntity<ID> {
private ID id;

View File

@@ -1,8 +1,7 @@
package com.food.order.domain.event;
package com.food.order.system.event;
// Base Domain Event Generic Class
public interface DomainEvent<T> {
}

View File

@@ -1,6 +1,6 @@
package com.food.order.domain.event.publisher;
package com.food.order.system.event.publisher;
import com.food.order.domain.event.DomainEvent;
import com.food.order.system.event.DomainEvent;
public interface DomainEventPublisher <T extends DomainEvent> {
void publish(T event);

View File

@@ -1,4 +1,4 @@
package com.food.order.domain.exception;
package com.food.order.system.exception;
public class DomainException extends RuntimeException {

View File

@@ -1,4 +1,4 @@
package com.food.order.domain.valueobject;
package com.food.order.system.valueobject;
public abstract class BaseId<T> {

View File

@@ -1,4 +1,4 @@
package com.food.order.domain.valueobject;
package com.food.order.system.valueobject;
import java.util.UUID;

View File

@@ -1,4 +1,4 @@
package com.food.order.domain.valueobject;
package com.food.order.system.valueobject;
import java.math.BigDecimal;
import java.math.RoundingMode;
@@ -28,7 +28,7 @@ public class Money {
this.amount.compareTo(other.amount) > 0;
}
public Money substract(Money other) {
public Money subtract(Money other) {
return new Money(setScale(this.amount.subtract(other.getAmount())));
}
@@ -47,12 +47,13 @@ public class Money {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Money money)) return false;
if (o == null || getClass() != o.getClass()) return false;
Money money = (Money) o;
return amount.equals(money.amount);
}
@Override
public int hashCode() {
return amount.hashCode();
return Objects.hash(amount);
}
}

View File

@@ -1,4 +1,4 @@
package com.food.order.domain.valueobject;
package com.food.order.system.valueobject;
public enum OrderApprovalStatus {
APPROVED,

View File

@@ -1,4 +1,4 @@
package com.food.order.domain.valueobject;
package com.food.order.system.valueobject;
import java.util.UUID;

View File

@@ -1,4 +1,4 @@
package com.food.order.domain.valueobject;
package com.food.order.system.valueobject;
public enum OrderStatus {
PENDING,

View File

@@ -0,0 +1,6 @@
package com.food.order.system.valueobject;
public enum PaymentOrderStatus {
PENDING,
CANCELLED
}

View File

@@ -1,4 +1,4 @@
package com.food.order.domain.valueobject;
package com.food.order.system.valueobject;
public enum PaymentStatus {
COMPLETED,CANCELED,FAILED

View File

@@ -1,4 +1,4 @@
package com.food.order.domain.valueobject;
package com.food.order.system.valueobject;
import java.util.UUID;

View File

@@ -1,4 +1,4 @@
package com.food.order.domain.valueobject;
package com.food.order.system.valueobject;
import java.util.UUID;

View File

@@ -0,0 +1,5 @@
package com.food.order.system.valueobject;
public enum RestaurantOrderStatus {
PAID
}

View File

@@ -13,6 +13,8 @@
<packaging>pom</packaging>
<modules>
<module>common-domain</module>
<module>common-application</module>
<module>common-data-access</module>
</modules>
<properties>

View File

@@ -0,0 +1,33 @@
<?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>customer-service</artifactId>
<groupId>com.food.order</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>customer-application</artifactId>
<dependencies>
<dependency>
<groupId>com.food.order</groupId>
<artifactId>customer-service-application</artifactId>
</dependency>
<dependency>
<groupId>com.food.order</groupId>
<artifactId>common-application</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,26 @@
package com.food.order.system.customer.rest.application.handler;
import com.food.order.system.application.handler.ErrorDTO;
import com.food.order.system.application.handler.GlobalExceptionHandler;
import com.food.order.system.customer.domain.exception.CustomerDomainException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
@Slf4j
@ControllerAdvice
public class CustomerGlobalExceptionHandler extends GlobalExceptionHandler {
@ResponseBody
@ExceptionHandler(value = {CustomerDomainException.class})
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ErrorDTO handleException(CustomerDomainException exception) {
log.error(exception.getMessage(), exception);
return ErrorDTO.builder().code(HttpStatus.BAD_REQUEST.getReasonPhrase())
.message(exception.getMessage()).build();
}
}

View File

@@ -0,0 +1,31 @@
package com.food.order.system.customer.rest.application.rest;
import com.food.order.system.customer.service.create.CreateCustomerCommand;
import com.food.order.system.customer.service.create.CreateCustomerResponse;
import com.food.order.system.customer.service.ports.input.service.CustomerApplicationService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping(value = "/customers", produces = "application/vnd.api.v1+json")
public class CustomerController {
private final CustomerApplicationService customerApplicationService;
@PostMapping
public ResponseEntity<CreateCustomerResponse> createCustomer(@RequestBody CreateCustomerCommand
createCustomerCommand) {
log.info("Creating customer with username: {}", createCustomerCommand.username());
CreateCustomerResponse response = customerApplicationService.createCustomer(createCustomerCommand);
return ResponseEntity.ok(response);
}
}

View File

@@ -0,0 +1,63 @@
<?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>customer-service</artifactId>
<groupId>com.food.order</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>customer-container</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.food.order</groupId>
<artifactId>customer-service-application</artifactId>
</dependency>
<dependency>
<groupId>com.food.order</groupId>
<artifactId>customer-domain-core</artifactId>
</dependency>
<dependency>
<groupId>com.food.order</groupId>
<artifactId>customer-data-access</artifactId>
</dependency>
<dependency>
<groupId>com.food.order</groupId>
<artifactId>customer-messaging</artifactId>
</dependency>
<dependency>
<groupId>com.food.order</groupId>
<artifactId>customer-application</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<name>${project.groupId}/customer.service:${project.version}</name>
</image>
</configuration>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>build-image</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,15 @@
package com.food.order.system.customer.service;
import com.food.order.system.customer.domain.CustomerDomainService;
import com.food.order.system.customer.domain.CustomerDomainServiceImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class BeanConfiguration {
@Bean
public CustomerDomainService customerDomainService() {
return new CustomerDomainServiceImpl();
}
}

View File

@@ -0,0 +1,19 @@
package com.food.order.system.customer.service;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
@EnableJpaRepositories(basePackages = {"com.food.order.system.customer.dataaccess",
"com.food.order.system.common.data.access"})
@EntityScan(basePackages = {"com.food.order.system.customer.dataaccess",
"com.food.order.system.common.data.access"})
@SpringBootApplication(scanBasePackages = "com.food.order")
public class CustomerServiceApplication {
public static void main(String[] args) {
SpringApplication.run(CustomerServiceApplication.class, args);
}
}

View File

@@ -0,0 +1,41 @@
server:
port: 8184
customer-service:
customer-topic-name: customer
spring:
jpa:
open-in-view: false
show-sql: false
database-platform: org.hibernate.dialect.PostgreSQL9Dialect
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQL9Dialect
datasource:
url: jdbc:postgresql://localhost:5432/postgres?currentSchema=customer&binaryTransfer=true&reWriteBatchedInserts=true
username: postgres
password: admin
driver-class-name: org.postgresql.Driver
platform: postgres
schema: classpath:init-schema.sql
initialization-mode: always
kafka-config:
bootstrap-servers: localhost:19092, localhost:29092, localhost:39092
schema-registry-url-key: schema.registry.url
schema-registry-url: http://localhost:8081
num-of-partitions: 3
replication-factor: 3
kafka-producer-config:
key-serializer-class: org.apache.kafka.common.serialization.StringSerializer
value-serializer-class: io.confluent.kafka.serializers.KafkaAvroSerializer
compression-type: snappy
acks: all
batch-size: 16384
batch-size-boost-factor: 100
linger-ms: 5
request-timeout-ms: 60000
retry-count: 5

View File

@@ -0,0 +1,46 @@
DROP SCHEMA IF EXISTS customer CASCADE;
CREATE SCHEMA customer;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE TABLE customer.customers
(
id uuid NOT NULL,
username character varying COLLATE pg_catalog."default" NOT NULL,
first_name character varying COLLATE pg_catalog."default" NOT NULL,
last_name character varying COLLATE pg_catalog."default" NOT NULL,
CONSTRAINT customers_pkey PRIMARY KEY (id)
);
DROP MATERIALIZED VIEW IF EXISTS customer.order_customer_m_view;
CREATE MATERIALIZED VIEW customer.order_customer_m_view
TABLESPACE pg_default
AS
SELECT id,
username,
first_name,
last_name
FROM customer.customers
WITH DATA;
refresh materialized VIEW customer.order_customer_m_view;
DROP function IF EXISTS customer.refresh_order_customer_m_view;
CREATE OR replace function customer.refresh_order_customer_m_view()
returns trigger
AS '
BEGIN
refresh materialized VIEW customer.order_customer_m_view;
return null;
END;
' LANGUAGE plpgsql;
DROP trigger IF EXISTS refresh_order_customer_m_view ON customer.customers;
CREATE trigger refresh_order_customer_m_view
after INSERT OR UPDATE OR DELETE OR truncate
ON customer.customers FOR each statement
EXECUTE PROCEDURE customer.refresh_order_customer_m_view();

View File

@@ -0,0 +1,33 @@
<?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>customer-service</artifactId>
<groupId>com.food.order</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>customer-data-access</artifactId>
<dependencies>
<dependency>
<groupId>com.food.order</groupId>
<artifactId>customer-service-application</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>com.food.order</groupId>
<artifactId>common-data-access</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,27 @@
package com.food.order.system.customer.dataaccess.adapter;
import com.food.order.system.customer.dataaccess.mapper.CustomerDataAccessMapper;
import com.food.order.system.customer.dataaccess.repository.CustomerJpaRepository;
import com.food.order.system.customer.domain.entity.Customer;
import com.food.order.system.customer.service.ports.output.repository.CustomerRepository;
import org.springframework.stereotype.Component;
@Component
public class CustomerRepositoryImpl implements CustomerRepository {
private final CustomerJpaRepository customerJpaRepository;
private final CustomerDataAccessMapper customerDataAccessMapper;
public CustomerRepositoryImpl(CustomerJpaRepository customerJpaRepository,
CustomerDataAccessMapper customerDataAccessMapper) {
this.customerJpaRepository = customerJpaRepository;
this.customerDataAccessMapper = customerDataAccessMapper;
}
@Override
public Customer createCustomer(Customer customer) {
return customerDataAccessMapper.customerEntityToCustomer(
customerJpaRepository.save(customerDataAccessMapper.customerToCustomerEntity(customer)));
}
}

View File

@@ -0,0 +1,24 @@
package com.food.order.system.customer.dataaccess.entity;
import lombok.*;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.UUID;
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "customers")
@Entity
public class CustomerEntity {
@Id
private UUID id;
private String username;
private String firstName;
private String lastName;
}

View File

@@ -0,0 +1,8 @@
package com.food.order.system.customer.dataaccess.exception;
public class CustomerDataaccessException extends RuntimeException {
public CustomerDataaccessException(String message) {
super(message);
}
}

View File

@@ -0,0 +1,27 @@
package com.food.order.system.customer.dataaccess.mapper;
import com.food.order.system.customer.dataaccess.entity.CustomerEntity;
import com.food.order.system.customer.domain.entity.Customer;
import com.food.order.system.valueobject.CustomerId;
import org.springframework.stereotype.Component;
@Component
public class CustomerDataAccessMapper {
public Customer customerEntityToCustomer(CustomerEntity customerEntity) {
return new Customer(new CustomerId(customerEntity.getId()),
customerEntity.getUsername(),
customerEntity.getFirstName(),
customerEntity.getLastName());
}
public CustomerEntity customerToCustomerEntity(Customer customer) {
return CustomerEntity.builder()
.id(customer.getId().getValue())
.username(customer.getUsername())
.firstName(customer.getFirstName())
.lastName(customer.getLastName())
.build();
}
}

View File

@@ -0,0 +1,13 @@
package com.food.order.system.customer.dataaccess.repository;
import com.food.order.system.customer.dataaccess.entity.CustomerEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.UUID;
@Repository
public interface CustomerJpaRepository extends JpaRepository<CustomerEntity, UUID> {
}

View File

@@ -0,0 +1,22 @@
<?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>customer-domain</artifactId>
<groupId>com.food.order</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>customer-domain-core</artifactId>
<dependencies>
<dependency>
<groupId>com.food.order</groupId>
<artifactId>common-domain</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,11 @@
package com.food.order.system.customer.domain;
import com.food.order.system.customer.domain.entity.Customer;
import com.food.order.system.customer.domain.event.CustomerCreatedEvent;
public interface CustomerDomainService {
CustomerCreatedEvent validateAndInitiateCustomer(Customer customer);
}

View File

@@ -0,0 +1,19 @@
package com.food.order.system.customer.domain;
import com.food.order.system.customer.domain.entity.Customer;
import com.food.order.system.customer.domain.event.CustomerCreatedEvent;
import lombok.extern.slf4j.Slf4j;
import java.time.ZoneId;
import java.time.ZonedDateTime;
@Slf4j
public class CustomerDomainServiceImpl implements CustomerDomainService {
public CustomerCreatedEvent validateAndInitiateCustomer(Customer customer) {
//Any Business logic required to run for a customer creation
log.info("Customer with id: {} is initiated", customer.getId().getValue());
return new CustomerCreatedEvent(customer, ZonedDateTime.now(ZoneId.of("UTC")));
}
}

View File

@@ -0,0 +1,32 @@
package com.food.order.system.customer.domain.entity;
import com.food.order.system.entity.AggregateRoot;
import com.food.order.system.valueobject.CustomerId;
public class Customer extends AggregateRoot<CustomerId> {
private final String username;
private final String firstName;
private final String lastName;
public Customer(CustomerId customerId, String username, String firstName, String lastName) {
super.setId(customerId);
this.username = username;
this.firstName = firstName;
this.lastName = lastName;
}
public String getUsername() {
return username;
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
}

View File

@@ -0,0 +1,23 @@
package com.food.order.system.customer.domain.event;
import com.food.order.system.customer.domain.entity.Customer;
import com.food.order.system.event.DomainEvent;
import java.time.ZonedDateTime;
public class CustomerCreatedEvent implements DomainEvent<Customer> {
private final Customer customer;
private final ZonedDateTime createdAt;
public CustomerCreatedEvent(Customer customer, ZonedDateTime createdAt) {
this.customer = customer;
this.createdAt = createdAt;
}
public Customer getCustomer() {
return customer;
}
}

View File

@@ -0,0 +1,11 @@
package com.food.order.system.customer.domain.exception;
import com.food.order.system.exception.DomainException;
public class CustomerDomainException extends DomainException {
public CustomerDomainException(String message) {
super(message);
}
}

View File

@@ -0,0 +1,35 @@
<?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>customer-domain</artifactId>
<groupId>com.food.order</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>customer-service-application</artifactId>
<dependencies>
<dependency>
<groupId>com.food.order</groupId>
<artifactId>customer-domain-core</artifactId>
</dependency>
<dependency>
<groupId>com.food.order</groupId>
<artifactId>common-domain</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,36 @@
package com.food.order.system.customer.service;
import com.food.order.system.customer.domain.event.CustomerCreatedEvent;
import com.food.order.system.customer.service.create.CreateCustomerCommand;
import com.food.order.system.customer.service.create.CreateCustomerResponse;
import com.food.order.system.customer.service.mapper.CustomerDataMapper;
import com.food.order.system.customer.service.ports.input.service.CustomerApplicationService;
import com.food.order.system.customer.service.ports.output.message.publisher.CustomerMessagePublisher;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@Slf4j
@Validated
@Service
@RequiredArgsConstructor
class CustomerApplicationServiceImpl implements CustomerApplicationService {
private final CustomerCreateCommandHandler customerCreateCommandHandler;
private final CustomerDataMapper customerDataMapper;
private final CustomerMessagePublisher customerMessagePublisher;
@Override
public CreateCustomerResponse createCustomer(CreateCustomerCommand createCustomerCommand) {
CustomerCreatedEvent customerCreatedEvent = customerCreateCommandHandler.createCustomer(createCustomerCommand);
customerMessagePublisher.publish(customerCreatedEvent);
return customerDataMapper
.customerToCreateCustomerResponse(customerCreatedEvent.getCustomer(),
"Customer saved successfully!");
}
}

View File

@@ -0,0 +1,42 @@
package com.food.order.system.customer.service;
import com.food.order.system.customer.domain.CustomerDomainService;
import com.food.order.system.customer.domain.entity.Customer;
import com.food.order.system.customer.domain.event.CustomerCreatedEvent;
import com.food.order.system.customer.domain.exception.CustomerDomainException;
import com.food.order.system.customer.service.create.CreateCustomerCommand;
import com.food.order.system.customer.service.mapper.CustomerDataMapper;
import com.food.order.system.customer.service.ports.output.repository.CustomerRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@Slf4j
@Component
@RequiredArgsConstructor
class CustomerCreateCommandHandler {
private final CustomerDomainService customerDomainService;
private final CustomerRepository customerRepository;
private final CustomerDataMapper customerDataMapper;
@Transactional
public CustomerCreatedEvent createCustomer(CreateCustomerCommand createCustomerCommand) {
Customer customer = customerDataMapper.createCustomerCommandToCustomer(createCustomerCommand);
CustomerCreatedEvent customerCreatedEvent = customerDomainService.validateAndInitiateCustomer(customer);
Customer savedCustomer = customerRepository.createCustomer(customer);
if (savedCustomer == null) {
log.error("Could not save customer with id: {}", createCustomerCommand.customerId());
throw new CustomerDomainException("Could not save customer with id " +
createCustomerCommand.customerId());
}
log.info("Returning CustomerCreatedEvent for customer id: {}", createCustomerCommand.customerId());
return customerCreatedEvent;
}
}

View File

@@ -0,0 +1,12 @@
package com.food.order.system.customer.service.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Data
@Configuration
@ConfigurationProperties(prefix = "customer-service")
public class CustomerServiceConfigData {
private String customerTopicName;
}

View File

@@ -0,0 +1,11 @@
package com.food.order.system.customer.service.create;
import lombok.Builder;
import javax.validation.constraints.NotNull;
import java.util.UUID;
@Builder
public record CreateCustomerCommand(@NotNull UUID customerId, @NotNull String username, @NotNull String firstName,
@NotNull String lastName) {
}

View File

@@ -0,0 +1,10 @@
package com.food.order.system.customer.service.create;
import lombok.Builder;
import javax.validation.constraints.NotNull;
import java.util.UUID;
@Builder
public record CreateCustomerResponse(@NotNull UUID customerId, @NotNull String message) {
}

View File

@@ -0,0 +1,22 @@
package com.food.order.system.customer.service.mapper;
import com.food.order.system.customer.domain.entity.Customer;
import com.food.order.system.customer.service.create.CreateCustomerCommand;
import com.food.order.system.customer.service.create.CreateCustomerResponse;
import com.food.order.system.valueobject.CustomerId;
import org.springframework.stereotype.Component;
@Component
public class CustomerDataMapper {
public Customer createCustomerCommandToCustomer(CreateCustomerCommand createCustomerCommand) {
return new Customer(new CustomerId(createCustomerCommand.customerId()),
createCustomerCommand.username(),
createCustomerCommand.firstName(),
createCustomerCommand.lastName());
}
public CreateCustomerResponse customerToCreateCustomerResponse(Customer customer, String message) {
return new CreateCustomerResponse(customer.getId().getValue(), message);
}
}

View File

@@ -0,0 +1,13 @@
package com.food.order.system.customer.service.ports.input.service;
import com.food.order.system.customer.service.create.CreateCustomerCommand;
import com.food.order.system.customer.service.create.CreateCustomerResponse;
import javax.validation.Valid;
public interface CustomerApplicationService {
CreateCustomerResponse createCustomer(@Valid CreateCustomerCommand createCustomerCommand);
}

View File

@@ -0,0 +1,10 @@
package com.food.order.system.customer.service.ports.output.message.publisher;
import com.food.order.system.customer.domain.event.CustomerCreatedEvent;
public interface CustomerMessagePublisher {
void publish(CustomerCreatedEvent customerCreatedEvent);
}

View File

@@ -0,0 +1,9 @@
package com.food.order.system.customer.service.ports.output.repository;
import com.food.order.system.customer.domain.entity.Customer;
public interface CustomerRepository {
Customer createCustomer(Customer customer);
}

View File

@@ -0,0 +1,20 @@
<?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>customer-service</artifactId>
<groupId>com.food.order</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>customer-domain</artifactId>
<packaging>pom</packaging>
<modules>
<module>customer-domain-core</module>
<module>customer-service-application</module>
</modules>
</project>

View File

@@ -0,0 +1,30 @@
<?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>customer-service</artifactId>
<groupId>com.food.order</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>customer-messaging</artifactId>
<dependencies>
<dependency>
<groupId>com.food.order</groupId>
<artifactId>customer-service-application</artifactId>
</dependency>
<dependency>
<groupId>com.food.order</groupId>
<artifactId>kafka-producer</artifactId>
</dependency>
<dependency>
<groupId>com.food.order</groupId>
<artifactId>kafka-model</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,19 @@
package com.food.order.system.customer.messaging.mapper;
import com.food.order.system.customer.domain.event.CustomerCreatedEvent;
import com.food.order.system.kafka.order.avro.model.CustomerAvroModel;
import org.springframework.stereotype.Component;
@Component
public class CustomerMessagingDataMapper {
public CustomerAvroModel paymentResponseAvroModelToPaymentResponse(CustomerCreatedEvent
customerCreatedEvent) {
return CustomerAvroModel.newBuilder()
.setId(customerCreatedEvent.getCustomer().getId().getValue().toString())
.setUsername(customerCreatedEvent.getCustomer().getUsername())
.setFirstName(customerCreatedEvent.getCustomer().getFirstName())
.setLastName(customerCreatedEvent.getCustomer().getLastName())
.build();
}
}

View File

@@ -0,0 +1,68 @@
package com.food.order.system.customer.messaging.publisher.kafka;
import com.food.order.system.customer.domain.event.CustomerCreatedEvent;
import com.food.order.system.customer.messaging.mapper.CustomerMessagingDataMapper;
import com.food.order.system.customer.service.config.CustomerServiceConfigData;
import com.food.order.system.customer.service.ports.output.message.publisher.CustomerMessagePublisher;
import com.food.order.system.kafka.order.avro.model.CustomerAvroModel;
import com.food.order.system.kafka.producer.service.KafkaProducer;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.springframework.kafka.support.SendResult;
import org.springframework.stereotype.Component;
import org.springframework.util.concurrent.ListenableFutureCallback;
@Slf4j
@Component
@RequiredArgsConstructor
public class CustomerCreatedEventKafkaPublisher implements CustomerMessagePublisher {
private final CustomerMessagingDataMapper customerMessagingDataMapper;
private final KafkaProducer<String, CustomerAvroModel> kafkaProducer;
private final CustomerServiceConfigData customerServiceConfigData;
@Override
public void publish(CustomerCreatedEvent customerCreatedEvent) {
log.info("Received CustomerCreatedEvent for customer id: {}",
customerCreatedEvent.getCustomer().getId().getValue());
try {
CustomerAvroModel customerAvroModel = customerMessagingDataMapper
.paymentResponseAvroModelToPaymentResponse(customerCreatedEvent);
kafkaProducer.send(customerServiceConfigData.getCustomerTopicName(), customerAvroModel.getId(),
customerAvroModel,
getCallback(customerServiceConfigData.getCustomerTopicName(), customerAvroModel));
log.info("CustomerCreatedEvent sent to kafka for customer id: {}",
customerAvroModel.getId());
} catch (Exception e) {
log.error("Error while sending CustomerCreatedEvent to kafka for customer id: {}," +
" error: {}", customerCreatedEvent.getCustomer().getId().getValue(), e.getMessage());
}
}
private ListenableFutureCallback<SendResult<String, CustomerAvroModel>>
getCallback(String topicName, CustomerAvroModel message) {
return new ListenableFutureCallback<>() {
@Override
public void onFailure(Throwable throwable) {
log.error("Error while sending message {} to topic {}", message.toString(), topicName, throwable);
}
@Override
public void onSuccess(SendResult<String, CustomerAvroModel> result) {
RecordMetadata metadata = result.getRecordMetadata();
log.info("Received new metadata. Topic: {}; Partition {}; Offset {}; Timestamp {}, at time {}",
metadata.topic(),
metadata.partition(),
metadata.offset(),
metadata.timestamp(),
System.nanoTime());
}
};
}
}

24
customer-service/pom.xml Normal file
View File

@@ -0,0 +1,24 @@
<?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>food-ordering-system</artifactId>
<groupId>com.food.order</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>customer-service</artifactId>
<packaging>pom</packaging>
<modules>
<module>customer-container</module>
<module>customer-application</module>
<module>customer-data-access</module>
<module>customer-messaging</module>
<module>customer-domain</module>
</modules>
</project>

Submodule food-order-system-infra added at 9a47979f37

View File

@@ -0,0 +1,3 @@
KAFKA_VERSION=7.0.1
GLOBAL_NETWORK=food-order-system
GROUP_ID=com.food.order

View File

@@ -0,0 +1,5 @@
version: '3.7'
networks:
food-order-system:
driver: bridge

View File

@@ -0,0 +1,30 @@
version: '3.7'
services:
init-kafka:
image: confluentinc/cp-kafka:${KAFKA_VERSION}
entrypoint: [ '/bin/sh', '-c' ]
command: |
"
# block until kafka is reachable
kafka-topics --bootstrap-server kafka-broker-1:9092 --list
echo -e 'Deleting kafka topics'
kafka-topics --bootstrap-server kafka-broker-1:9092 --topic payment-request-value --delete --if-exists
kafka-topics --bootstrap-server kafka-broker-1:9092 --topic payment-response-value --delete --if-exists
kafka-topics --bootstrap-server kafka-broker-1:9092 --topic restaurant-approval-request-value --delete --if-exists
kafka-topics --bootstrap-server kafka-broker-1:9092 --topic restaurant-approval-response-value --delete --if-exists
kafka-topics --bootstrap-server kafka-broker-1:9092 --topic customer-value --delete --if-exists
echo -e 'Creating kafka topics'
kafka-topics --bootstrap-server kafka-broker-1:9092 --create --if-not-exists --topic payment-request-value --replication-factor 3 --partitions 3
kafka-topics --bootstrap-server kafka-broker-1:9092 --create --if-not-exists --topic payment-response-value --replication-factor 3 --partitions 3
kafka-topics --bootstrap-server kafka-broker-1:9092 --create --if-not-exists --topic restaurant-approval-request-value --replication-factor 3 --partitions 3
kafka-topics --bootstrap-server kafka-broker-1:9092 --create --if-not-exists --topic restaurant-approval-response-value --replication-factor 3 --partitions 3
kafka-topics --bootstrap-server kafka-broker-1:9092 --create --if-not-exists --topic customer-value --replication-factor 3 --partitions 3
echo -e 'Successfully created the following topics:'
kafka-topics --bootstrap-server kafka-broker-1:9092 --list
"
networks:
- ${GLOBAL_NETWORK:-kafka}

View File

@@ -0,0 +1,79 @@
version: '3.7'
services:
schema-registry:
image: confluentinc/cp-schema-registry:${KAFKA_VERSION}
hostname: schema-registry
depends_on:
- kafka-broker-1
- kafka-broker-2
- kafka-broker-3
ports:
- "8081:8081"
environment:
SCHEMA_REGISTRY_HOST_NAME: schema-registry
SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL: 'zookeeper:2181'
SCHEMA_REGISTRY_LISTENERS: http://schema-registry:8081
SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: PLAINTEXT://kafka-broker-1:9092,LISTENER_LOCAL://localhost:19092,PLAINTEXT://kafka-broker-2:9092,LISTENER_LOCAL://localhost:29092,PLAINTEXT://kafka-broker-3:9092,LISTENER_LOCAL://localhost:39092
SCHEMA_REGISTRY_DEBUG: 'true'
networks:
- ${GLOBAL_NETWORK:-kafka}
kafka-broker-1:
image: confluentinc/cp-kafka:${KAFKA_VERSION}
hostname: kafka-broker-1
ports:
- "19092:19092"
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka-broker-1:9092,LISTENER_LOCAL://localhost:19092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,LISTENER_LOCAL:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 3
KAFKA_COMPRESSION_TYPE: producer
volumes:
- "./volumes/kafka/broker-1:/var/lib/kafka/data"
networks:
- ${GLOBAL_NETWORK:-kafka}
kafka-broker-2:
image: confluentinc/cp-kafka:${KAFKA_VERSION}
hostname: kafka-broker-2
ports:
- "29092:29092"
environment:
KAFKA_BROKER_ID: 2
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka-broker-2:9092,LISTENER_LOCAL://localhost:29092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,LISTENER_LOCAL:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 3
KAFKA_COMPRESSION_TYPE: producer
volumes:
- "./volumes/kafka/broker-2:/var/lib/kafka/data"
networks:
- ${GLOBAL_NETWORK:-kafka}
kafka-broker-3:
image: confluentinc/cp-kafka:${KAFKA_VERSION}
hostname: kafka-broker-3
ports:
- "39092:39092"
environment:
KAFKA_BROKER_ID: 3
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka-broker-3:9092,LISTENER_LOCAL://localhost:39092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,LISTENER_LOCAL:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 3
KAFKA_COMPRESSION_TYPE: producer
volumes:
- "./volumes/kafka/broker-3:/var/lib/kafka/data"
networks:
- ${GLOBAL_NETWORK:-kafka}
kafka-manager:
image: hlebalbau/kafka-manager:stable
restart: always
ports:
- "9000:9000"
environment:
ZK_HOSTS: "zookeeper:2181"
networks:
- ${GLOBAL_NETWORK:-kafka}

View File

@@ -0,0 +1,20 @@
version: '3.7'
services:
zookeeper:
image: confluentinc/cp-zookeeper:${KAFKA_VERSION:-latest}
hostname: zookeeper
ports:
- "2181:2181"
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
ZOOKEEPER_INIT_LIMIT: 5
ZOOKEEPER_SYNC_LIMIT: 2
ZOOKEEPER_SERVER_ID: 1
ZOOKEEPER_SERVERS: zookeeper:2181:3888
KAFKA_OPTS: "-Dzookeeper.4lw.commands.whitelist=ruok"
volumes:
- "./volumes/zookeeper/data:/var/lib/zookeeper/data"
- "./volumes/zookeeper/transactions:/var/lib/zookeeper/log"
networks:
- ${GLOBAL_NETWORK:-kafka}

View File

@@ -0,0 +1,21 @@
<?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>kafka</artifactId>
<groupId>com.food.order</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>kafka-config</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,16 @@
package com.food.order.kafka.config.data;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Data
@Configuration
@ConfigurationProperties(prefix = "kafka-config")
public class KafkaConfigData {
private String bootstrapServers;
private String schemaRegistryUrlKey;
private String schemaRegistryUrl;
private Integer numOfPartitions;
private Short replicationFactor;
}

View File

@@ -0,0 +1,27 @@
package com.food.order.kafka.config.data;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Data
@Configuration
@ConfigurationProperties(prefix = "kafka-consumer-config")
public class KafkaConsumerConfigData {
private String keyDeserializer;
private String valueDeserializer;
private String autoOffsetReset;
private String specificAvroReaderKey;
private String specificAvroReader;
private Boolean batchListener;
private Boolean autoStartup;
private Integer concurrencyLevel;
private Integer sessionTimeoutMs;
private Integer heartbeatIntervalMs;
private Integer maxPollIntervalMs;
private Long pollTimeoutMs;
private Integer maxPollRecords;
private Integer maxPartitionFetchBytesDefault;
private Integer maxPartitionFetchBytesBoostFactor;
}

View File

@@ -0,0 +1,20 @@
package com.food.order.kafka.config.data;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Data
@Configuration
@ConfigurationProperties(prefix = "kafka-producer-config")
public class KafkaProducerConfigData {
private String keySerializerClass;
private String valueSerializerClass;
private String compressionType;
private String acks;
private Integer batchSize;
private Integer batchSizeBoostFactor;
private Integer lingerMs;
private Integer requestTimeoutMs;
private Integer retryCount;
}

View File

@@ -0,0 +1,33 @@
<?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>kafka</artifactId>
<groupId>com.food.order</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>kafka-consumer</artifactId>
<dependencies>
<dependency>
<groupId>com.food.order</groupId>
<artifactId>kafka-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,9 @@
package com.food.order.system.kafka.consumer;
import org.apache.avro.specific.SpecificRecordBase;
import java.util.List;
public interface KafkaConsumer<T extends SpecificRecordBase> {
void receive(List<T> messages , List<String> keys , List<Integer> partitions , List<Long> offSets);
}

View File

@@ -0,0 +1,60 @@
package com.food.order.system.kafka.consumer.config;
import com.food.order.kafka.config.data.KafkaConfigData;
import com.food.order.kafka.config.data.KafkaConsumerConfigData;
import lombok.RequiredArgsConstructor;
import org.apache.avro.specific.SpecificRecordBase;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
import org.springframework.kafka.config.KafkaListenerContainerFactory;
import org.springframework.kafka.core.ConsumerFactory;
import org.springframework.kafka.core.DefaultKafkaConsumerFactory;
import org.springframework.kafka.listener.ConcurrentMessageListenerContainer;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
@Configuration
@RequiredArgsConstructor
public class KafkaConsumerConfig<K extends Serializable, V extends SpecificRecordBase> {
private final KafkaConfigData kafkaConfigData;
private final KafkaConsumerConfigData kafkaConsumerConfigData;
@Bean
public Map<String, Object> consumerConfigs() {
Map<String, Object> props = new HashMap<>();
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaConfigData.getBootstrapServers());
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, kafkaConsumerConfigData.getKeyDeserializer());
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, kafkaConsumerConfigData.getValueDeserializer());
props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, kafkaConsumerConfigData.getAutoOffsetReset());
props.put(kafkaConfigData.getSchemaRegistryUrlKey(), kafkaConfigData.getSchemaRegistryUrl());
props.put(kafkaConsumerConfigData.getSpecificAvroReaderKey(), kafkaConsumerConfigData.getSpecificAvroReader());
props.put(ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, kafkaConsumerConfigData.getSessionTimeoutMs());
props.put(ConsumerConfig.HEARTBEAT_INTERVAL_MS_CONFIG, kafkaConsumerConfigData.getHeartbeatIntervalMs());
props.put(ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG, kafkaConsumerConfigData.getMaxPollIntervalMs());
props.put(ConsumerConfig.MAX_PARTITION_FETCH_BYTES_CONFIG,
kafkaConsumerConfigData.getMaxPartitionFetchBytesDefault() *
kafkaConsumerConfigData.getMaxPartitionFetchBytesBoostFactor());
props.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, kafkaConsumerConfigData.getMaxPollRecords());
return props;
}
@Bean
public ConsumerFactory<K, V> consumerFactory() {
return new DefaultKafkaConsumerFactory<>(consumerConfigs());
}
@Bean
public KafkaListenerContainerFactory<ConcurrentMessageListenerContainer<K, V>> kafkaListenerContainerFactory() {
ConcurrentKafkaListenerContainerFactory<K, V> factory = new ConcurrentKafkaListenerContainerFactory<>();
factory.setConsumerFactory(consumerFactory());
factory.setBatchListener(kafkaConsumerConfigData.getBatchListener());
factory.setConcurrency(kafkaConsumerConfigData.getConcurrencyLevel());
factory.setAutoStartup(kafkaConsumerConfigData.getAutoStartup());
factory.getContainerProperties().setPollTimeout(kafkaConsumerConfigData.getPollTimeoutMs());
return factory;
}
}

View File

@@ -0,0 +1,50 @@
<?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>kafka</artifactId>
<groupId>com.food.order</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>kafka-model</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>${avro.version}</version>
<configuration>
<stringType>String</stringType>
<enableDecimalLogicalType>true</enableDecimalLogicalType>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>schema</goal>
</goals>
<configuration>
<sourceDirectory>src/main/resources/avro</sourceDirectory>
<outputDirectory>src/main/java</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,512 @@
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.food.order.system.kafka.order.avro.model;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.message.BinaryMessageEncoder;
import org.apache.avro.message.SchemaStore;
import org.apache.avro.specific.SpecificData;
@org.apache.avro.specific.AvroGenerated
public class CustomerAvroModel extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
private static final long serialVersionUID = 7953499667909084838L;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"CustomerAvroModel\",\"namespace\":\"com.food.order.system.kafka.order.avro.model\",\"fields\":[{\"name\":\"id\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"username\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"firstName\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"lastName\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}}]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
private static final SpecificData MODEL$ = new SpecificData();
private static final BinaryMessageEncoder<CustomerAvroModel> ENCODER =
new BinaryMessageEncoder<CustomerAvroModel>(MODEL$, SCHEMA$);
private static final BinaryMessageDecoder<CustomerAvroModel> DECODER =
new BinaryMessageDecoder<CustomerAvroModel>(MODEL$, SCHEMA$);
/**
* Return the BinaryMessageEncoder instance used by this class.
* @return the message encoder used by this class
*/
public static BinaryMessageEncoder<CustomerAvroModel> getEncoder() {
return ENCODER;
}
/**
* Return the BinaryMessageDecoder instance used by this class.
* @return the message decoder used by this class
*/
public static BinaryMessageDecoder<CustomerAvroModel> getDecoder() {
return DECODER;
}
/**
* Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
* @param resolver a {@link SchemaStore} used to find schemas by fingerprint
* @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore
*/
public static BinaryMessageDecoder<CustomerAvroModel> createDecoder(SchemaStore resolver) {
return new BinaryMessageDecoder<CustomerAvroModel>(MODEL$, SCHEMA$, resolver);
}
/**
* Serializes this CustomerAvroModel to a ByteBuffer.
* @return a buffer holding the serialized data for this instance
* @throws java.io.IOException if this instance could not be serialized
*/
public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
return ENCODER.encode(this);
}
/**
* Deserializes a CustomerAvroModel from a ByteBuffer.
* @param b a byte buffer holding serialized data for an instance of this class
* @return a CustomerAvroModel instance decoded from the given buffer
* @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class
*/
public static CustomerAvroModel fromByteBuffer(
java.nio.ByteBuffer b) throws java.io.IOException {
return DECODER.decode(b);
}
private java.lang.String id;
private java.lang.String username;
private java.lang.String firstName;
private java.lang.String lastName;
/**
* Default constructor. Note that this does not initialize fields
* to their default values from the schema. If that is desired then
* one should use <code>newBuilder()</code>.
*/
public CustomerAvroModel() {}
/**
* All-args constructor.
* @param id The new value for id
* @param username The new value for username
* @param firstName The new value for firstName
* @param lastName The new value for lastName
*/
public CustomerAvroModel(java.lang.String id, java.lang.String username, java.lang.String firstName, java.lang.String lastName) {
this.id = id;
this.username = username;
this.firstName = firstName;
this.lastName = lastName;
}
public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; }
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return id;
case 1: return username;
case 2: return firstName;
case 3: return lastName;
default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
}
}
private static final org.apache.avro.Conversion<?>[] conversions =
new org.apache.avro.Conversion<?>[] {
null,
null,
null,
null,
null
};
@Override
public org.apache.avro.Conversion<?> getConversion(int field) {
return conversions[field];
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value$) {
switch (field$) {
case 0: id = value$ != null ? value$.toString() : null; break;
case 1: username = value$ != null ? value$.toString() : null; break;
case 2: firstName = value$ != null ? value$.toString() : null; break;
case 3: lastName = value$ != null ? value$.toString() : null; break;
default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
}
}
/**
* Gets the value of the 'id' field.
* @return The value of the 'id' field.
*/
public java.lang.String getId() {
return id;
}
/**
* Sets the value of the 'id' field.
* @param value the value to set.
*/
public void setId(java.lang.String value) {
this.id = value;
}
/**
* Gets the value of the 'username' field.
* @return The value of the 'username' field.
*/
public java.lang.String getUsername() {
return username;
}
/**
* Sets the value of the 'username' field.
* @param value the value to set.
*/
public void setUsername(java.lang.String value) {
this.username = value;
}
/**
* Gets the value of the 'firstName' field.
* @return The value of the 'firstName' field.
*/
public java.lang.String getFirstName() {
return firstName;
}
/**
* Sets the value of the 'firstName' field.
* @param value the value to set.
*/
public void setFirstName(java.lang.String value) {
this.firstName = value;
}
/**
* Gets the value of the 'lastName' field.
* @return The value of the 'lastName' field.
*/
public java.lang.String getLastName() {
return lastName;
}
/**
* Sets the value of the 'lastName' field.
* @param value the value to set.
*/
public void setLastName(java.lang.String value) {
this.lastName = value;
}
/**
* Creates a new CustomerAvroModel RecordBuilder.
* @return A new CustomerAvroModel RecordBuilder
*/
public static com.food.order.system.kafka.order.avro.model.CustomerAvroModel.Builder newBuilder() {
return new com.food.order.system.kafka.order.avro.model.CustomerAvroModel.Builder();
}
/**
* Creates a new CustomerAvroModel RecordBuilder by copying an existing Builder.
* @param other The existing builder to copy.
* @return A new CustomerAvroModel RecordBuilder
*/
public static com.food.order.system.kafka.order.avro.model.CustomerAvroModel.Builder newBuilder(com.food.order.system.kafka.order.avro.model.CustomerAvroModel.Builder other) {
if (other == null) {
return new com.food.order.system.kafka.order.avro.model.CustomerAvroModel.Builder();
} else {
return new com.food.order.system.kafka.order.avro.model.CustomerAvroModel.Builder(other);
}
}
/**
* Creates a new CustomerAvroModel RecordBuilder by copying an existing CustomerAvroModel instance.
* @param other The existing instance to copy.
* @return A new CustomerAvroModel RecordBuilder
*/
public static com.food.order.system.kafka.order.avro.model.CustomerAvroModel.Builder newBuilder(com.food.order.system.kafka.order.avro.model.CustomerAvroModel other) {
if (other == null) {
return new com.food.order.system.kafka.order.avro.model.CustomerAvroModel.Builder();
} else {
return new com.food.order.system.kafka.order.avro.model.CustomerAvroModel.Builder(other);
}
}
/**
* RecordBuilder for CustomerAvroModel instances.
*/
@org.apache.avro.specific.AvroGenerated
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<CustomerAvroModel>
implements org.apache.avro.data.RecordBuilder<CustomerAvroModel> {
private java.lang.String id;
private java.lang.String username;
private java.lang.String firstName;
private java.lang.String lastName;
/** Creates a new Builder */
private Builder() {
super(SCHEMA$, MODEL$);
}
/**
* Creates a Builder by copying an existing Builder.
* @param other The existing Builder to copy.
*/
private Builder(com.food.order.system.kafka.order.avro.model.CustomerAvroModel.Builder other) {
super(other);
if (isValidValue(fields()[0], other.id)) {
this.id = data().deepCopy(fields()[0].schema(), other.id);
fieldSetFlags()[0] = other.fieldSetFlags()[0];
}
if (isValidValue(fields()[1], other.username)) {
this.username = data().deepCopy(fields()[1].schema(), other.username);
fieldSetFlags()[1] = other.fieldSetFlags()[1];
}
if (isValidValue(fields()[2], other.firstName)) {
this.firstName = data().deepCopy(fields()[2].schema(), other.firstName);
fieldSetFlags()[2] = other.fieldSetFlags()[2];
}
if (isValidValue(fields()[3], other.lastName)) {
this.lastName = data().deepCopy(fields()[3].schema(), other.lastName);
fieldSetFlags()[3] = other.fieldSetFlags()[3];
}
}
/**
* Creates a Builder by copying an existing CustomerAvroModel instance
* @param other The existing instance to copy.
*/
private Builder(com.food.order.system.kafka.order.avro.model.CustomerAvroModel other) {
super(SCHEMA$, MODEL$);
if (isValidValue(fields()[0], other.id)) {
this.id = data().deepCopy(fields()[0].schema(), other.id);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.username)) {
this.username = data().deepCopy(fields()[1].schema(), other.username);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.firstName)) {
this.firstName = data().deepCopy(fields()[2].schema(), other.firstName);
fieldSetFlags()[2] = true;
}
if (isValidValue(fields()[3], other.lastName)) {
this.lastName = data().deepCopy(fields()[3].schema(), other.lastName);
fieldSetFlags()[3] = true;
}
}
/**
* Gets the value of the 'id' field.
* @return The value.
*/
public java.lang.String getId() {
return id;
}
/**
* Sets the value of the 'id' field.
* @param value The value of 'id'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.CustomerAvroModel.Builder setId(java.lang.String value) {
validate(fields()[0], value);
this.id = value;
fieldSetFlags()[0] = true;
return this;
}
/**
* Checks whether the 'id' field has been set.
* @return True if the 'id' field has been set, false otherwise.
*/
public boolean hasId() {
return fieldSetFlags()[0];
}
/**
* Clears the value of the 'id' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.CustomerAvroModel.Builder clearId() {
id = null;
fieldSetFlags()[0] = false;
return this;
}
/**
* Gets the value of the 'username' field.
* @return The value.
*/
public java.lang.String getUsername() {
return username;
}
/**
* Sets the value of the 'username' field.
* @param value The value of 'username'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.CustomerAvroModel.Builder setUsername(java.lang.String value) {
validate(fields()[1], value);
this.username = value;
fieldSetFlags()[1] = true;
return this;
}
/**
* Checks whether the 'username' field has been set.
* @return True if the 'username' field has been set, false otherwise.
*/
public boolean hasUsername() {
return fieldSetFlags()[1];
}
/**
* Clears the value of the 'username' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.CustomerAvroModel.Builder clearUsername() {
username = null;
fieldSetFlags()[1] = false;
return this;
}
/**
* Gets the value of the 'firstName' field.
* @return The value.
*/
public java.lang.String getFirstName() {
return firstName;
}
/**
* Sets the value of the 'firstName' field.
* @param value The value of 'firstName'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.CustomerAvroModel.Builder setFirstName(java.lang.String value) {
validate(fields()[2], value);
this.firstName = value;
fieldSetFlags()[2] = true;
return this;
}
/**
* Checks whether the 'firstName' field has been set.
* @return True if the 'firstName' field has been set, false otherwise.
*/
public boolean hasFirstName() {
return fieldSetFlags()[2];
}
/**
* Clears the value of the 'firstName' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.CustomerAvroModel.Builder clearFirstName() {
firstName = null;
fieldSetFlags()[2] = false;
return this;
}
/**
* Gets the value of the 'lastName' field.
* @return The value.
*/
public java.lang.String getLastName() {
return lastName;
}
/**
* Sets the value of the 'lastName' field.
* @param value The value of 'lastName'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.CustomerAvroModel.Builder setLastName(java.lang.String value) {
validate(fields()[3], value);
this.lastName = value;
fieldSetFlags()[3] = true;
return this;
}
/**
* Checks whether the 'lastName' field has been set.
* @return True if the 'lastName' field has been set, false otherwise.
*/
public boolean hasLastName() {
return fieldSetFlags()[3];
}
/**
* Clears the value of the 'lastName' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.CustomerAvroModel.Builder clearLastName() {
lastName = null;
fieldSetFlags()[3] = false;
return this;
}
@Override
@SuppressWarnings("unchecked")
public CustomerAvroModel build() {
try {
CustomerAvroModel record = new CustomerAvroModel();
record.id = fieldSetFlags()[0] ? this.id : (java.lang.String) defaultValue(fields()[0]);
record.username = fieldSetFlags()[1] ? this.username : (java.lang.String) defaultValue(fields()[1]);
record.firstName = fieldSetFlags()[2] ? this.firstName : (java.lang.String) defaultValue(fields()[2]);
record.lastName = fieldSetFlags()[3] ? this.lastName : (java.lang.String) defaultValue(fields()[3]);
return record;
} catch (org.apache.avro.AvroMissingFieldException e) {
throw e;
} catch (java.lang.Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumWriter<CustomerAvroModel>
WRITER$ = (org.apache.avro.io.DatumWriter<CustomerAvroModel>)MODEL$.createDatumWriter(SCHEMA$);
@Override public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
WRITER$.write(this, SpecificData.getEncoder(out));
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumReader<CustomerAvroModel>
READER$ = (org.apache.avro.io.DatumReader<CustomerAvroModel>)MODEL$.createDatumReader(SCHEMA$);
@Override public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
READER$.read(this, SpecificData.getDecoder(in));
}
}

View File

@@ -0,0 +1,13 @@
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.food.order.system.kafka.order.avro.model;
@org.apache.avro.specific.AvroGenerated
public enum OrderApprovalStatus implements org.apache.avro.generic.GenericEnumSymbol<OrderApprovalStatus> {
APPROVED, REJECTED ;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"enum\",\"name\":\"OrderApprovalStatus\",\"namespace\":\"com.food.order.system.kafka.order.avro.model\",\"symbols\":[\"APPROVED\",\"REJECTED\"]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
}

View File

@@ -0,0 +1,13 @@
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.food.order.system.kafka.order.avro.model;
@org.apache.avro.specific.AvroGenerated
public enum PaymentOrderStatus implements org.apache.avro.generic.GenericEnumSymbol<PaymentOrderStatus> {
PENDING, CANCELLED ;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"enum\",\"name\":\"PaymentOrderStatus\",\"namespace\":\"com.food.order.system.kafka.order.avro.model\",\"symbols\":[\"PENDING\",\"CANCELLED\"]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
}

View File

@@ -0,0 +1,734 @@
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.food.order.system.kafka.order.avro.model;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.message.BinaryMessageEncoder;
import org.apache.avro.message.SchemaStore;
import org.apache.avro.specific.SpecificData;
@org.apache.avro.specific.AvroGenerated
public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
private static final long serialVersionUID = 2928240305434837410L;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"PaymentRequestAvroModel\",\"namespace\":\"com.food.order.system.kafka.order.avro.model\",\"fields\":[{\"name\":\"id\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"sagaId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"customerId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"orderId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"price\",\"type\":{\"type\":\"bytes\",\"logicalType\":\"decimal\",\"precision\":10,\"scale\":2}},{\"name\":\"createdAt\",\"type\":{\"type\":\"long\",\"logicalType\":\"timestamp-millis\"}},{\"name\":\"paymentOrderStatus\",\"type\":{\"type\":\"enum\",\"name\":\"PaymentOrderStatus\",\"symbols\":[\"PENDING\",\"CANCELLED\"]}}]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
private static final SpecificData MODEL$ = new SpecificData();
static {
MODEL$.addLogicalTypeConversion(new org.apache.avro.data.TimeConversions.TimestampMillisConversion());
MODEL$.addLogicalTypeConversion(new org.apache.avro.Conversions.DecimalConversion());
}
private static final BinaryMessageEncoder<PaymentRequestAvroModel> ENCODER =
new BinaryMessageEncoder<PaymentRequestAvroModel>(MODEL$, SCHEMA$);
private static final BinaryMessageDecoder<PaymentRequestAvroModel> DECODER =
new BinaryMessageDecoder<PaymentRequestAvroModel>(MODEL$, SCHEMA$);
/**
* Return the BinaryMessageEncoder instance used by this class.
* @return the message encoder used by this class
*/
public static BinaryMessageEncoder<PaymentRequestAvroModel> getEncoder() {
return ENCODER;
}
/**
* Return the BinaryMessageDecoder instance used by this class.
* @return the message decoder used by this class
*/
public static BinaryMessageDecoder<PaymentRequestAvroModel> getDecoder() {
return DECODER;
}
/**
* Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
* @param resolver a {@link SchemaStore} used to find schemas by fingerprint
* @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore
*/
public static BinaryMessageDecoder<PaymentRequestAvroModel> createDecoder(SchemaStore resolver) {
return new BinaryMessageDecoder<PaymentRequestAvroModel>(MODEL$, SCHEMA$, resolver);
}
/**
* Serializes this PaymentRequestAvroModel to a ByteBuffer.
* @return a buffer holding the serialized data for this instance
* @throws java.io.IOException if this instance could not be serialized
*/
public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
return ENCODER.encode(this);
}
/**
* Deserializes a PaymentRequestAvroModel from a ByteBuffer.
* @param b a byte buffer holding serialized data for an instance of this class
* @return a PaymentRequestAvroModel instance decoded from the given buffer
* @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class
*/
public static PaymentRequestAvroModel fromByteBuffer(
java.nio.ByteBuffer b) throws java.io.IOException {
return DECODER.decode(b);
}
private java.lang.String id;
private java.lang.String sagaId;
private java.lang.String customerId;
private java.lang.String orderId;
private java.math.BigDecimal price;
private java.time.Instant createdAt;
private com.food.order.system.kafka.order.avro.model.PaymentOrderStatus paymentOrderStatus;
/**
* Default constructor. Note that this does not initialize fields
* to their default values from the schema. If that is desired then
* one should use <code>newBuilder()</code>.
*/
public PaymentRequestAvroModel() {}
/**
* All-args constructor.
* @param id The new value for id
* @param sagaId The new value for sagaId
* @param customerId The new value for customerId
* @param orderId The new value for orderId
* @param price The new value for price
* @param createdAt The new value for createdAt
* @param paymentOrderStatus The new value for paymentOrderStatus
*/
public PaymentRequestAvroModel(java.lang.String id, java.lang.String sagaId, java.lang.String customerId, java.lang.String orderId, java.math.BigDecimal price, java.time.Instant createdAt, com.food.order.system.kafka.order.avro.model.PaymentOrderStatus paymentOrderStatus) {
this.id = id;
this.sagaId = sagaId;
this.customerId = customerId;
this.orderId = orderId;
this.price = price;
this.createdAt = createdAt.truncatedTo(java.time.temporal.ChronoUnit.MILLIS);
this.paymentOrderStatus = paymentOrderStatus;
}
public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; }
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return id;
case 1: return sagaId;
case 2: return customerId;
case 3: return orderId;
case 4: return price;
case 5: return createdAt;
case 6: return paymentOrderStatus;
default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
}
}
private static final org.apache.avro.Conversion<?>[] conversions =
new org.apache.avro.Conversion<?>[] {
null,
null,
null,
null,
new org.apache.avro.Conversions.DecimalConversion(),
new org.apache.avro.data.TimeConversions.TimestampMillisConversion(),
null,
null
};
@Override
public org.apache.avro.Conversion<?> getConversion(int field) {
return conversions[field];
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value$) {
switch (field$) {
case 0: id = value$ != null ? value$.toString() : null; break;
case 1: sagaId = value$ != null ? value$.toString() : null; break;
case 2: customerId = value$ != null ? value$.toString() : null; break;
case 3: orderId = value$ != null ? value$.toString() : null; break;
case 4: price = (java.math.BigDecimal)value$; break;
case 5: createdAt = (java.time.Instant)value$; break;
case 6: paymentOrderStatus = (com.food.order.system.kafka.order.avro.model.PaymentOrderStatus)value$; break;
default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
}
}
/**
* Gets the value of the 'id' field.
* @return The value of the 'id' field.
*/
public java.lang.String getId() {
return id;
}
/**
* Sets the value of the 'id' field.
* @param value the value to set.
*/
public void setId(java.lang.String value) {
this.id = value;
}
/**
* Gets the value of the 'sagaId' field.
* @return The value of the 'sagaId' field.
*/
public java.lang.String getSagaId() {
return sagaId;
}
/**
* Sets the value of the 'sagaId' field.
* @param value the value to set.
*/
public void setSagaId(java.lang.String value) {
this.sagaId = value;
}
/**
* Gets the value of the 'customerId' field.
* @return The value of the 'customerId' field.
*/
public java.lang.String getCustomerId() {
return customerId;
}
/**
* Sets the value of the 'customerId' field.
* @param value the value to set.
*/
public void setCustomerId(java.lang.String value) {
this.customerId = value;
}
/**
* Gets the value of the 'orderId' field.
* @return The value of the 'orderId' field.
*/
public java.lang.String getOrderId() {
return orderId;
}
/**
* Sets the value of the 'orderId' field.
* @param value the value to set.
*/
public void setOrderId(java.lang.String value) {
this.orderId = value;
}
/**
* Gets the value of the 'price' field.
* @return The value of the 'price' field.
*/
public java.math.BigDecimal getPrice() {
return price;
}
/**
* Sets the value of the 'price' field.
* @param value the value to set.
*/
public void setPrice(java.math.BigDecimal value) {
this.price = value;
}
/**
* Gets the value of the 'createdAt' field.
* @return The value of the 'createdAt' field.
*/
public java.time.Instant getCreatedAt() {
return createdAt;
}
/**
* Sets the value of the 'createdAt' field.
* @param value the value to set.
*/
public void setCreatedAt(java.time.Instant value) {
this.createdAt = value.truncatedTo(java.time.temporal.ChronoUnit.MILLIS);
}
/**
* Gets the value of the 'paymentOrderStatus' field.
* @return The value of the 'paymentOrderStatus' field.
*/
public com.food.order.system.kafka.order.avro.model.PaymentOrderStatus getPaymentOrderStatus() {
return paymentOrderStatus;
}
/**
* Sets the value of the 'paymentOrderStatus' field.
* @param value the value to set.
*/
public void setPaymentOrderStatus(com.food.order.system.kafka.order.avro.model.PaymentOrderStatus value) {
this.paymentOrderStatus = value;
}
/**
* Creates a new PaymentRequestAvroModel RecordBuilder.
* @return A new PaymentRequestAvroModel RecordBuilder
*/
public static com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder newBuilder() {
return new com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder();
}
/**
* Creates a new PaymentRequestAvroModel RecordBuilder by copying an existing Builder.
* @param other The existing builder to copy.
* @return A new PaymentRequestAvroModel RecordBuilder
*/
public static com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder newBuilder(com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder other) {
if (other == null) {
return new com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder();
} else {
return new com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder(other);
}
}
/**
* Creates a new PaymentRequestAvroModel RecordBuilder by copying an existing PaymentRequestAvroModel instance.
* @param other The existing instance to copy.
* @return A new PaymentRequestAvroModel RecordBuilder
*/
public static com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder newBuilder(com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel other) {
if (other == null) {
return new com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder();
} else {
return new com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder(other);
}
}
/**
* RecordBuilder for PaymentRequestAvroModel instances.
*/
@org.apache.avro.specific.AvroGenerated
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<PaymentRequestAvroModel>
implements org.apache.avro.data.RecordBuilder<PaymentRequestAvroModel> {
private java.lang.String id;
private java.lang.String sagaId;
private java.lang.String customerId;
private java.lang.String orderId;
private java.math.BigDecimal price;
private java.time.Instant createdAt;
private com.food.order.system.kafka.order.avro.model.PaymentOrderStatus paymentOrderStatus;
/** Creates a new Builder */
private Builder() {
super(SCHEMA$, MODEL$);
}
/**
* Creates a Builder by copying an existing Builder.
* @param other The existing Builder to copy.
*/
private Builder(com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder other) {
super(other);
if (isValidValue(fields()[0], other.id)) {
this.id = data().deepCopy(fields()[0].schema(), other.id);
fieldSetFlags()[0] = other.fieldSetFlags()[0];
}
if (isValidValue(fields()[1], other.sagaId)) {
this.sagaId = data().deepCopy(fields()[1].schema(), other.sagaId);
fieldSetFlags()[1] = other.fieldSetFlags()[1];
}
if (isValidValue(fields()[2], other.customerId)) {
this.customerId = data().deepCopy(fields()[2].schema(), other.customerId);
fieldSetFlags()[2] = other.fieldSetFlags()[2];
}
if (isValidValue(fields()[3], other.orderId)) {
this.orderId = data().deepCopy(fields()[3].schema(), other.orderId);
fieldSetFlags()[3] = other.fieldSetFlags()[3];
}
if (isValidValue(fields()[4], other.price)) {
this.price = data().deepCopy(fields()[4].schema(), other.price);
fieldSetFlags()[4] = other.fieldSetFlags()[4];
}
if (isValidValue(fields()[5], other.createdAt)) {
this.createdAt = data().deepCopy(fields()[5].schema(), other.createdAt);
fieldSetFlags()[5] = other.fieldSetFlags()[5];
}
if (isValidValue(fields()[6], other.paymentOrderStatus)) {
this.paymentOrderStatus = data().deepCopy(fields()[6].schema(), other.paymentOrderStatus);
fieldSetFlags()[6] = other.fieldSetFlags()[6];
}
}
/**
* Creates a Builder by copying an existing PaymentRequestAvroModel instance
* @param other The existing instance to copy.
*/
private Builder(com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel other) {
super(SCHEMA$, MODEL$);
if (isValidValue(fields()[0], other.id)) {
this.id = data().deepCopy(fields()[0].schema(), other.id);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.sagaId)) {
this.sagaId = data().deepCopy(fields()[1].schema(), other.sagaId);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.customerId)) {
this.customerId = data().deepCopy(fields()[2].schema(), other.customerId);
fieldSetFlags()[2] = true;
}
if (isValidValue(fields()[3], other.orderId)) {
this.orderId = data().deepCopy(fields()[3].schema(), other.orderId);
fieldSetFlags()[3] = true;
}
if (isValidValue(fields()[4], other.price)) {
this.price = data().deepCopy(fields()[4].schema(), other.price);
fieldSetFlags()[4] = true;
}
if (isValidValue(fields()[5], other.createdAt)) {
this.createdAt = data().deepCopy(fields()[5].schema(), other.createdAt);
fieldSetFlags()[5] = true;
}
if (isValidValue(fields()[6], other.paymentOrderStatus)) {
this.paymentOrderStatus = data().deepCopy(fields()[6].schema(), other.paymentOrderStatus);
fieldSetFlags()[6] = true;
}
}
/**
* Gets the value of the 'id' field.
* @return The value.
*/
public java.lang.String getId() {
return id;
}
/**
* Sets the value of the 'id' field.
* @param value The value of 'id'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder setId(java.lang.String value) {
validate(fields()[0], value);
this.id = value;
fieldSetFlags()[0] = true;
return this;
}
/**
* Checks whether the 'id' field has been set.
* @return True if the 'id' field has been set, false otherwise.
*/
public boolean hasId() {
return fieldSetFlags()[0];
}
/**
* Clears the value of the 'id' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder clearId() {
id = null;
fieldSetFlags()[0] = false;
return this;
}
/**
* Gets the value of the 'sagaId' field.
* @return The value.
*/
public java.lang.String getSagaId() {
return sagaId;
}
/**
* Sets the value of the 'sagaId' field.
* @param value The value of 'sagaId'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder setSagaId(java.lang.String value) {
validate(fields()[1], value);
this.sagaId = value;
fieldSetFlags()[1] = true;
return this;
}
/**
* Checks whether the 'sagaId' field has been set.
* @return True if the 'sagaId' field has been set, false otherwise.
*/
public boolean hasSagaId() {
return fieldSetFlags()[1];
}
/**
* Clears the value of the 'sagaId' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder clearSagaId() {
sagaId = null;
fieldSetFlags()[1] = false;
return this;
}
/**
* Gets the value of the 'customerId' field.
* @return The value.
*/
public java.lang.String getCustomerId() {
return customerId;
}
/**
* Sets the value of the 'customerId' field.
* @param value The value of 'customerId'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder setCustomerId(java.lang.String value) {
validate(fields()[2], value);
this.customerId = value;
fieldSetFlags()[2] = true;
return this;
}
/**
* Checks whether the 'customerId' field has been set.
* @return True if the 'customerId' field has been set, false otherwise.
*/
public boolean hasCustomerId() {
return fieldSetFlags()[2];
}
/**
* Clears the value of the 'customerId' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder clearCustomerId() {
customerId = null;
fieldSetFlags()[2] = false;
return this;
}
/**
* Gets the value of the 'orderId' field.
* @return The value.
*/
public java.lang.String getOrderId() {
return orderId;
}
/**
* Sets the value of the 'orderId' field.
* @param value The value of 'orderId'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder setOrderId(java.lang.String value) {
validate(fields()[3], value);
this.orderId = value;
fieldSetFlags()[3] = true;
return this;
}
/**
* Checks whether the 'orderId' field has been set.
* @return True if the 'orderId' field has been set, false otherwise.
*/
public boolean hasOrderId() {
return fieldSetFlags()[3];
}
/**
* Clears the value of the 'orderId' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder clearOrderId() {
orderId = null;
fieldSetFlags()[3] = false;
return this;
}
/**
* Gets the value of the 'price' field.
* @return The value.
*/
public java.math.BigDecimal getPrice() {
return price;
}
/**
* Sets the value of the 'price' field.
* @param value The value of 'price'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder setPrice(java.math.BigDecimal value) {
validate(fields()[4], value);
this.price = value;
fieldSetFlags()[4] = true;
return this;
}
/**
* Checks whether the 'price' field has been set.
* @return True if the 'price' field has been set, false otherwise.
*/
public boolean hasPrice() {
return fieldSetFlags()[4];
}
/**
* Clears the value of the 'price' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder clearPrice() {
price = null;
fieldSetFlags()[4] = false;
return this;
}
/**
* Gets the value of the 'createdAt' field.
* @return The value.
*/
public java.time.Instant getCreatedAt() {
return createdAt;
}
/**
* Sets the value of the 'createdAt' field.
* @param value The value of 'createdAt'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder setCreatedAt(java.time.Instant value) {
validate(fields()[5], value);
this.createdAt = value.truncatedTo(java.time.temporal.ChronoUnit.MILLIS);
fieldSetFlags()[5] = true;
return this;
}
/**
* Checks whether the 'createdAt' field has been set.
* @return True if the 'createdAt' field has been set, false otherwise.
*/
public boolean hasCreatedAt() {
return fieldSetFlags()[5];
}
/**
* Clears the value of the 'createdAt' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder clearCreatedAt() {
fieldSetFlags()[5] = false;
return this;
}
/**
* Gets the value of the 'paymentOrderStatus' field.
* @return The value.
*/
public com.food.order.system.kafka.order.avro.model.PaymentOrderStatus getPaymentOrderStatus() {
return paymentOrderStatus;
}
/**
* Sets the value of the 'paymentOrderStatus' field.
* @param value The value of 'paymentOrderStatus'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder setPaymentOrderStatus(com.food.order.system.kafka.order.avro.model.PaymentOrderStatus value) {
validate(fields()[6], value);
this.paymentOrderStatus = value;
fieldSetFlags()[6] = true;
return this;
}
/**
* Checks whether the 'paymentOrderStatus' field has been set.
* @return True if the 'paymentOrderStatus' field has been set, false otherwise.
*/
public boolean hasPaymentOrderStatus() {
return fieldSetFlags()[6];
}
/**
* Clears the value of the 'paymentOrderStatus' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder clearPaymentOrderStatus() {
paymentOrderStatus = null;
fieldSetFlags()[6] = false;
return this;
}
@Override
@SuppressWarnings("unchecked")
public PaymentRequestAvroModel build() {
try {
PaymentRequestAvroModel record = new PaymentRequestAvroModel();
record.id = fieldSetFlags()[0] ? this.id : (java.lang.String) defaultValue(fields()[0]);
record.sagaId = fieldSetFlags()[1] ? this.sagaId : (java.lang.String) defaultValue(fields()[1]);
record.customerId = fieldSetFlags()[2] ? this.customerId : (java.lang.String) defaultValue(fields()[2]);
record.orderId = fieldSetFlags()[3] ? this.orderId : (java.lang.String) defaultValue(fields()[3]);
record.price = fieldSetFlags()[4] ? this.price : (java.math.BigDecimal) defaultValue(fields()[4]);
record.createdAt = fieldSetFlags()[5] ? this.createdAt : (java.time.Instant) defaultValue(fields()[5]);
record.paymentOrderStatus = fieldSetFlags()[6] ? this.paymentOrderStatus : (com.food.order.system.kafka.order.avro.model.PaymentOrderStatus) defaultValue(fields()[6]);
return record;
} catch (org.apache.avro.AvroMissingFieldException e) {
throw e;
} catch (java.lang.Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumWriter<PaymentRequestAvroModel>
WRITER$ = (org.apache.avro.io.DatumWriter<PaymentRequestAvroModel>)MODEL$.createDatumWriter(SCHEMA$);
@Override public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
WRITER$.write(this, SpecificData.getEncoder(out));
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumReader<PaymentRequestAvroModel>
READER$ = (org.apache.avro.io.DatumReader<PaymentRequestAvroModel>)MODEL$.createDatumReader(SCHEMA$);
@Override public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
READER$.read(this, SpecificData.getDecoder(in));
}
}

View File

@@ -0,0 +1,882 @@
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.food.order.system.kafka.order.avro.model;
import org.apache.avro.generic.GenericArray;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.util.Utf8;
import org.apache.avro.message.BinaryMessageEncoder;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.message.SchemaStore;
@org.apache.avro.specific.AvroGenerated
public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
private static final long serialVersionUID = -3686686114915224929L;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"PaymentResponseAvroModel\",\"namespace\":\"com.food.order.system.kafka.order.avro.model\",\"fields\":[{\"name\":\"id\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"sagaId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"paymentId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"customerId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"orderId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"price\",\"type\":{\"type\":\"bytes\",\"logicalType\":\"decimal\",\"precision\":10,\"scale\":2}},{\"name\":\"createdAt\",\"type\":{\"type\":\"long\",\"logicalType\":\"timestamp-millis\"}},{\"name\":\"paymentStatus\",\"type\":{\"type\":\"enum\",\"name\":\"PaymentStatus\",\"symbols\":[\"COMPLETED\",\"CANCELLED\",\"FAILED\"]}},{\"name\":\"failureMessages\",\"type\":{\"type\":\"array\",\"items\":{\"type\":\"string\",\"avro.java.string\":\"String\"}}}]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
private static final SpecificData MODEL$ = new SpecificData();
static {
MODEL$.addLogicalTypeConversion(new org.apache.avro.data.TimeConversions.TimestampMillisConversion());
MODEL$.addLogicalTypeConversion(new org.apache.avro.Conversions.DecimalConversion());
}
private static final BinaryMessageEncoder<PaymentResponseAvroModel> ENCODER =
new BinaryMessageEncoder<PaymentResponseAvroModel>(MODEL$, SCHEMA$);
private static final BinaryMessageDecoder<PaymentResponseAvroModel> DECODER =
new BinaryMessageDecoder<PaymentResponseAvroModel>(MODEL$, SCHEMA$);
/**
* Return the BinaryMessageEncoder instance used by this class.
* @return the message encoder used by this class
*/
public static BinaryMessageEncoder<PaymentResponseAvroModel> getEncoder() {
return ENCODER;
}
/**
* Return the BinaryMessageDecoder instance used by this class.
* @return the message decoder used by this class
*/
public static BinaryMessageDecoder<PaymentResponseAvroModel> getDecoder() {
return DECODER;
}
/**
* Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
* @param resolver a {@link SchemaStore} used to find schemas by fingerprint
* @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore
*/
public static BinaryMessageDecoder<PaymentResponseAvroModel> createDecoder(SchemaStore resolver) {
return new BinaryMessageDecoder<PaymentResponseAvroModel>(MODEL$, SCHEMA$, resolver);
}
/**
* Serializes this PaymentResponseAvroModel to a ByteBuffer.
* @return a buffer holding the serialized data for this instance
* @throws java.io.IOException if this instance could not be serialized
*/
public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
return ENCODER.encode(this);
}
/**
* Deserializes a PaymentResponseAvroModel from a ByteBuffer.
* @param b a byte buffer holding serialized data for an instance of this class
* @return a PaymentResponseAvroModel instance decoded from the given buffer
* @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class
*/
public static PaymentResponseAvroModel fromByteBuffer(
java.nio.ByteBuffer b) throws java.io.IOException {
return DECODER.decode(b);
}
private java.lang.String id;
private java.lang.String sagaId;
private java.lang.String paymentId;
private java.lang.String customerId;
private java.lang.String orderId;
private java.math.BigDecimal price;
private java.time.Instant createdAt;
private com.food.order.system.kafka.order.avro.model.PaymentStatus paymentStatus;
private java.util.List<java.lang.String> failureMessages;
/**
* Default constructor. Note that this does not initialize fields
* to their default values from the schema. If that is desired then
* one should use <code>newBuilder()</code>.
*/
public PaymentResponseAvroModel() {}
/**
* All-args constructor.
* @param id The new value for id
* @param sagaId The new value for sagaId
* @param paymentId The new value for paymentId
* @param customerId The new value for customerId
* @param orderId The new value for orderId
* @param price The new value for price
* @param createdAt The new value for createdAt
* @param paymentStatus The new value for paymentStatus
* @param failureMessages The new value for failureMessages
*/
public PaymentResponseAvroModel(java.lang.String id, java.lang.String sagaId, java.lang.String paymentId, java.lang.String customerId, java.lang.String orderId, java.math.BigDecimal price, java.time.Instant createdAt, com.food.order.system.kafka.order.avro.model.PaymentStatus paymentStatus, java.util.List<java.lang.String> failureMessages) {
this.id = id;
this.sagaId = sagaId;
this.paymentId = paymentId;
this.customerId = customerId;
this.orderId = orderId;
this.price = price;
this.createdAt = createdAt.truncatedTo(java.time.temporal.ChronoUnit.MILLIS);
this.paymentStatus = paymentStatus;
this.failureMessages = failureMessages;
}
public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; }
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return id;
case 1: return sagaId;
case 2: return paymentId;
case 3: return customerId;
case 4: return orderId;
case 5: return price;
case 6: return createdAt;
case 7: return paymentStatus;
case 8: return failureMessages;
default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
}
}
private static final org.apache.avro.Conversion<?>[] conversions =
new org.apache.avro.Conversion<?>[] {
null,
null,
null,
null,
null,
new org.apache.avro.Conversions.DecimalConversion(),
new org.apache.avro.data.TimeConversions.TimestampMillisConversion(),
null,
null,
null
};
@Override
public org.apache.avro.Conversion<?> getConversion(int field) {
return conversions[field];
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value$) {
switch (field$) {
case 0: id = value$ != null ? value$.toString() : null; break;
case 1: sagaId = value$ != null ? value$.toString() : null; break;
case 2: paymentId = value$ != null ? value$.toString() : null; break;
case 3: customerId = value$ != null ? value$.toString() : null; break;
case 4: orderId = value$ != null ? value$.toString() : null; break;
case 5: price = (java.math.BigDecimal)value$; break;
case 6: createdAt = (java.time.Instant)value$; break;
case 7: paymentStatus = (com.food.order.system.kafka.order.avro.model.PaymentStatus)value$; break;
case 8: failureMessages = (java.util.List<java.lang.String>)value$; break;
default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
}
}
/**
* Gets the value of the 'id' field.
* @return The value of the 'id' field.
*/
public java.lang.String getId() {
return id;
}
/**
* Sets the value of the 'id' field.
* @param value the value to set.
*/
public void setId(java.lang.String value) {
this.id = value;
}
/**
* Gets the value of the 'sagaId' field.
* @return The value of the 'sagaId' field.
*/
public java.lang.String getSagaId() {
return sagaId;
}
/**
* Sets the value of the 'sagaId' field.
* @param value the value to set.
*/
public void setSagaId(java.lang.String value) {
this.sagaId = value;
}
/**
* Gets the value of the 'paymentId' field.
* @return The value of the 'paymentId' field.
*/
public java.lang.String getPaymentId() {
return paymentId;
}
/**
* Sets the value of the 'paymentId' field.
* @param value the value to set.
*/
public void setPaymentId(java.lang.String value) {
this.paymentId = value;
}
/**
* Gets the value of the 'customerId' field.
* @return The value of the 'customerId' field.
*/
public java.lang.String getCustomerId() {
return customerId;
}
/**
* Sets the value of the 'customerId' field.
* @param value the value to set.
*/
public void setCustomerId(java.lang.String value) {
this.customerId = value;
}
/**
* Gets the value of the 'orderId' field.
* @return The value of the 'orderId' field.
*/
public java.lang.String getOrderId() {
return orderId;
}
/**
* Sets the value of the 'orderId' field.
* @param value the value to set.
*/
public void setOrderId(java.lang.String value) {
this.orderId = value;
}
/**
* Gets the value of the 'price' field.
* @return The value of the 'price' field.
*/
public java.math.BigDecimal getPrice() {
return price;
}
/**
* Sets the value of the 'price' field.
* @param value the value to set.
*/
public void setPrice(java.math.BigDecimal value) {
this.price = value;
}
/**
* Gets the value of the 'createdAt' field.
* @return The value of the 'createdAt' field.
*/
public java.time.Instant getCreatedAt() {
return createdAt;
}
/**
* Sets the value of the 'createdAt' field.
* @param value the value to set.
*/
public void setCreatedAt(java.time.Instant value) {
this.createdAt = value.truncatedTo(java.time.temporal.ChronoUnit.MILLIS);
}
/**
* Gets the value of the 'paymentStatus' field.
* @return The value of the 'paymentStatus' field.
*/
public com.food.order.system.kafka.order.avro.model.PaymentStatus getPaymentStatus() {
return paymentStatus;
}
/**
* Sets the value of the 'paymentStatus' field.
* @param value the value to set.
*/
public void setPaymentStatus(com.food.order.system.kafka.order.avro.model.PaymentStatus value) {
this.paymentStatus = value;
}
/**
* Gets the value of the 'failureMessages' field.
* @return The value of the 'failureMessages' field.
*/
public java.util.List<java.lang.String> getFailureMessages() {
return failureMessages;
}
/**
* Sets the value of the 'failureMessages' field.
* @param value the value to set.
*/
public void setFailureMessages(java.util.List<java.lang.String> value) {
this.failureMessages = value;
}
/**
* Creates a new PaymentResponseAvroModel RecordBuilder.
* @return A new PaymentResponseAvroModel RecordBuilder
*/
public static com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder newBuilder() {
return new com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder();
}
/**
* Creates a new PaymentResponseAvroModel RecordBuilder by copying an existing Builder.
* @param other The existing builder to copy.
* @return A new PaymentResponseAvroModel RecordBuilder
*/
public static com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder newBuilder(com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder other) {
if (other == null) {
return new com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder();
} else {
return new com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder(other);
}
}
/**
* Creates a new PaymentResponseAvroModel RecordBuilder by copying an existing PaymentResponseAvroModel instance.
* @param other The existing instance to copy.
* @return A new PaymentResponseAvroModel RecordBuilder
*/
public static com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder newBuilder(com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel other) {
if (other == null) {
return new com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder();
} else {
return new com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder(other);
}
}
/**
* RecordBuilder for PaymentResponseAvroModel instances.
*/
@org.apache.avro.specific.AvroGenerated
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<PaymentResponseAvroModel>
implements org.apache.avro.data.RecordBuilder<PaymentResponseAvroModel> {
private java.lang.String id;
private java.lang.String sagaId;
private java.lang.String paymentId;
private java.lang.String customerId;
private java.lang.String orderId;
private java.math.BigDecimal price;
private java.time.Instant createdAt;
private com.food.order.system.kafka.order.avro.model.PaymentStatus paymentStatus;
private java.util.List<java.lang.String> failureMessages;
/** Creates a new Builder */
private Builder() {
super(SCHEMA$, MODEL$);
}
/**
* Creates a Builder by copying an existing Builder.
* @param other The existing Builder to copy.
*/
private Builder(com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder other) {
super(other);
if (isValidValue(fields()[0], other.id)) {
this.id = data().deepCopy(fields()[0].schema(), other.id);
fieldSetFlags()[0] = other.fieldSetFlags()[0];
}
if (isValidValue(fields()[1], other.sagaId)) {
this.sagaId = data().deepCopy(fields()[1].schema(), other.sagaId);
fieldSetFlags()[1] = other.fieldSetFlags()[1];
}
if (isValidValue(fields()[2], other.paymentId)) {
this.paymentId = data().deepCopy(fields()[2].schema(), other.paymentId);
fieldSetFlags()[2] = other.fieldSetFlags()[2];
}
if (isValidValue(fields()[3], other.customerId)) {
this.customerId = data().deepCopy(fields()[3].schema(), other.customerId);
fieldSetFlags()[3] = other.fieldSetFlags()[3];
}
if (isValidValue(fields()[4], other.orderId)) {
this.orderId = data().deepCopy(fields()[4].schema(), other.orderId);
fieldSetFlags()[4] = other.fieldSetFlags()[4];
}
if (isValidValue(fields()[5], other.price)) {
this.price = data().deepCopy(fields()[5].schema(), other.price);
fieldSetFlags()[5] = other.fieldSetFlags()[5];
}
if (isValidValue(fields()[6], other.createdAt)) {
this.createdAt = data().deepCopy(fields()[6].schema(), other.createdAt);
fieldSetFlags()[6] = other.fieldSetFlags()[6];
}
if (isValidValue(fields()[7], other.paymentStatus)) {
this.paymentStatus = data().deepCopy(fields()[7].schema(), other.paymentStatus);
fieldSetFlags()[7] = other.fieldSetFlags()[7];
}
if (isValidValue(fields()[8], other.failureMessages)) {
this.failureMessages = data().deepCopy(fields()[8].schema(), other.failureMessages);
fieldSetFlags()[8] = other.fieldSetFlags()[8];
}
}
/**
* Creates a Builder by copying an existing PaymentResponseAvroModel instance
* @param other The existing instance to copy.
*/
private Builder(com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel other) {
super(SCHEMA$, MODEL$);
if (isValidValue(fields()[0], other.id)) {
this.id = data().deepCopy(fields()[0].schema(), other.id);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.sagaId)) {
this.sagaId = data().deepCopy(fields()[1].schema(), other.sagaId);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.paymentId)) {
this.paymentId = data().deepCopy(fields()[2].schema(), other.paymentId);
fieldSetFlags()[2] = true;
}
if (isValidValue(fields()[3], other.customerId)) {
this.customerId = data().deepCopy(fields()[3].schema(), other.customerId);
fieldSetFlags()[3] = true;
}
if (isValidValue(fields()[4], other.orderId)) {
this.orderId = data().deepCopy(fields()[4].schema(), other.orderId);
fieldSetFlags()[4] = true;
}
if (isValidValue(fields()[5], other.price)) {
this.price = data().deepCopy(fields()[5].schema(), other.price);
fieldSetFlags()[5] = true;
}
if (isValidValue(fields()[6], other.createdAt)) {
this.createdAt = data().deepCopy(fields()[6].schema(), other.createdAt);
fieldSetFlags()[6] = true;
}
if (isValidValue(fields()[7], other.paymentStatus)) {
this.paymentStatus = data().deepCopy(fields()[7].schema(), other.paymentStatus);
fieldSetFlags()[7] = true;
}
if (isValidValue(fields()[8], other.failureMessages)) {
this.failureMessages = data().deepCopy(fields()[8].schema(), other.failureMessages);
fieldSetFlags()[8] = true;
}
}
/**
* Gets the value of the 'id' field.
* @return The value.
*/
public java.lang.String getId() {
return id;
}
/**
* Sets the value of the 'id' field.
* @param value The value of 'id'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder setId(java.lang.String value) {
validate(fields()[0], value);
this.id = value;
fieldSetFlags()[0] = true;
return this;
}
/**
* Checks whether the 'id' field has been set.
* @return True if the 'id' field has been set, false otherwise.
*/
public boolean hasId() {
return fieldSetFlags()[0];
}
/**
* Clears the value of the 'id' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder clearId() {
id = null;
fieldSetFlags()[0] = false;
return this;
}
/**
* Gets the value of the 'sagaId' field.
* @return The value.
*/
public java.lang.String getSagaId() {
return sagaId;
}
/**
* Sets the value of the 'sagaId' field.
* @param value The value of 'sagaId'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder setSagaId(java.lang.String value) {
validate(fields()[1], value);
this.sagaId = value;
fieldSetFlags()[1] = true;
return this;
}
/**
* Checks whether the 'sagaId' field has been set.
* @return True if the 'sagaId' field has been set, false otherwise.
*/
public boolean hasSagaId() {
return fieldSetFlags()[1];
}
/**
* Clears the value of the 'sagaId' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder clearSagaId() {
sagaId = null;
fieldSetFlags()[1] = false;
return this;
}
/**
* Gets the value of the 'paymentId' field.
* @return The value.
*/
public java.lang.String getPaymentId() {
return paymentId;
}
/**
* Sets the value of the 'paymentId' field.
* @param value The value of 'paymentId'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder setPaymentId(java.lang.String value) {
validate(fields()[2], value);
this.paymentId = value;
fieldSetFlags()[2] = true;
return this;
}
/**
* Checks whether the 'paymentId' field has been set.
* @return True if the 'paymentId' field has been set, false otherwise.
*/
public boolean hasPaymentId() {
return fieldSetFlags()[2];
}
/**
* Clears the value of the 'paymentId' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder clearPaymentId() {
paymentId = null;
fieldSetFlags()[2] = false;
return this;
}
/**
* Gets the value of the 'customerId' field.
* @return The value.
*/
public java.lang.String getCustomerId() {
return customerId;
}
/**
* Sets the value of the 'customerId' field.
* @param value The value of 'customerId'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder setCustomerId(java.lang.String value) {
validate(fields()[3], value);
this.customerId = value;
fieldSetFlags()[3] = true;
return this;
}
/**
* Checks whether the 'customerId' field has been set.
* @return True if the 'customerId' field has been set, false otherwise.
*/
public boolean hasCustomerId() {
return fieldSetFlags()[3];
}
/**
* Clears the value of the 'customerId' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder clearCustomerId() {
customerId = null;
fieldSetFlags()[3] = false;
return this;
}
/**
* Gets the value of the 'orderId' field.
* @return The value.
*/
public java.lang.String getOrderId() {
return orderId;
}
/**
* Sets the value of the 'orderId' field.
* @param value The value of 'orderId'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder setOrderId(java.lang.String value) {
validate(fields()[4], value);
this.orderId = value;
fieldSetFlags()[4] = true;
return this;
}
/**
* Checks whether the 'orderId' field has been set.
* @return True if the 'orderId' field has been set, false otherwise.
*/
public boolean hasOrderId() {
return fieldSetFlags()[4];
}
/**
* Clears the value of the 'orderId' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder clearOrderId() {
orderId = null;
fieldSetFlags()[4] = false;
return this;
}
/**
* Gets the value of the 'price' field.
* @return The value.
*/
public java.math.BigDecimal getPrice() {
return price;
}
/**
* Sets the value of the 'price' field.
* @param value The value of 'price'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder setPrice(java.math.BigDecimal value) {
validate(fields()[5], value);
this.price = value;
fieldSetFlags()[5] = true;
return this;
}
/**
* Checks whether the 'price' field has been set.
* @return True if the 'price' field has been set, false otherwise.
*/
public boolean hasPrice() {
return fieldSetFlags()[5];
}
/**
* Clears the value of the 'price' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder clearPrice() {
price = null;
fieldSetFlags()[5] = false;
return this;
}
/**
* Gets the value of the 'createdAt' field.
* @return The value.
*/
public java.time.Instant getCreatedAt() {
return createdAt;
}
/**
* Sets the value of the 'createdAt' field.
* @param value The value of 'createdAt'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder setCreatedAt(java.time.Instant value) {
validate(fields()[6], value);
this.createdAt = value.truncatedTo(java.time.temporal.ChronoUnit.MILLIS);
fieldSetFlags()[6] = true;
return this;
}
/**
* Checks whether the 'createdAt' field has been set.
* @return True if the 'createdAt' field has been set, false otherwise.
*/
public boolean hasCreatedAt() {
return fieldSetFlags()[6];
}
/**
* Clears the value of the 'createdAt' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder clearCreatedAt() {
fieldSetFlags()[6] = false;
return this;
}
/**
* Gets the value of the 'paymentStatus' field.
* @return The value.
*/
public com.food.order.system.kafka.order.avro.model.PaymentStatus getPaymentStatus() {
return paymentStatus;
}
/**
* Sets the value of the 'paymentStatus' field.
* @param value The value of 'paymentStatus'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder setPaymentStatus(com.food.order.system.kafka.order.avro.model.PaymentStatus value) {
validate(fields()[7], value);
this.paymentStatus = value;
fieldSetFlags()[7] = true;
return this;
}
/**
* Checks whether the 'paymentStatus' field has been set.
* @return True if the 'paymentStatus' field has been set, false otherwise.
*/
public boolean hasPaymentStatus() {
return fieldSetFlags()[7];
}
/**
* Clears the value of the 'paymentStatus' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder clearPaymentStatus() {
paymentStatus = null;
fieldSetFlags()[7] = false;
return this;
}
/**
* Gets the value of the 'failureMessages' field.
* @return The value.
*/
public java.util.List<java.lang.String> getFailureMessages() {
return failureMessages;
}
/**
* Sets the value of the 'failureMessages' field.
* @param value The value of 'failureMessages'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder setFailureMessages(java.util.List<java.lang.String> value) {
validate(fields()[8], value);
this.failureMessages = value;
fieldSetFlags()[8] = true;
return this;
}
/**
* Checks whether the 'failureMessages' field has been set.
* @return True if the 'failureMessages' field has been set, false otherwise.
*/
public boolean hasFailureMessages() {
return fieldSetFlags()[8];
}
/**
* Clears the value of the 'failureMessages' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder clearFailureMessages() {
failureMessages = null;
fieldSetFlags()[8] = false;
return this;
}
@Override
@SuppressWarnings("unchecked")
public PaymentResponseAvroModel build() {
try {
PaymentResponseAvroModel record = new PaymentResponseAvroModel();
record.id = fieldSetFlags()[0] ? this.id : (java.lang.String) defaultValue(fields()[0]);
record.sagaId = fieldSetFlags()[1] ? this.sagaId : (java.lang.String) defaultValue(fields()[1]);
record.paymentId = fieldSetFlags()[2] ? this.paymentId : (java.lang.String) defaultValue(fields()[2]);
record.customerId = fieldSetFlags()[3] ? this.customerId : (java.lang.String) defaultValue(fields()[3]);
record.orderId = fieldSetFlags()[4] ? this.orderId : (java.lang.String) defaultValue(fields()[4]);
record.price = fieldSetFlags()[5] ? this.price : (java.math.BigDecimal) defaultValue(fields()[5]);
record.createdAt = fieldSetFlags()[6] ? this.createdAt : (java.time.Instant) defaultValue(fields()[6]);
record.paymentStatus = fieldSetFlags()[7] ? this.paymentStatus : (com.food.order.system.kafka.order.avro.model.PaymentStatus) defaultValue(fields()[7]);
record.failureMessages = fieldSetFlags()[8] ? this.failureMessages : (java.util.List<java.lang.String>) defaultValue(fields()[8]);
return record;
} catch (org.apache.avro.AvroMissingFieldException e) {
throw e;
} catch (java.lang.Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumWriter<PaymentResponseAvroModel>
WRITER$ = (org.apache.avro.io.DatumWriter<PaymentResponseAvroModel>)MODEL$.createDatumWriter(SCHEMA$);
@Override public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
WRITER$.write(this, SpecificData.getEncoder(out));
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumReader<PaymentResponseAvroModel>
READER$ = (org.apache.avro.io.DatumReader<PaymentResponseAvroModel>)MODEL$.createDatumReader(SCHEMA$);
@Override public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
READER$.read(this, SpecificData.getDecoder(in));
}
}

View File

@@ -0,0 +1,13 @@
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.food.order.system.kafka.order.avro.model;
@org.apache.avro.specific.AvroGenerated
public enum PaymentStatus implements org.apache.avro.generic.GenericEnumSymbol<PaymentStatus> {
COMPLETED, CANCELLED, FAILED ;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"enum\",\"name\":\"PaymentStatus\",\"namespace\":\"com.food.order.system.kafka.order.avro.model\",\"symbols\":[\"COMPLETED\",\"CANCELLED\",\"FAILED\"]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
}

View File

@@ -0,0 +1,392 @@
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.food.order.system.kafka.order.avro.model;
import org.apache.avro.generic.GenericArray;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.util.Utf8;
import org.apache.avro.message.BinaryMessageEncoder;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.message.SchemaStore;
@org.apache.avro.specific.AvroGenerated
public class Product extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
private static final long serialVersionUID = -6762943505103404653L;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Product\",\"namespace\":\"com.food.order.system.kafka.order.avro.model\",\"fields\":[{\"name\":\"id\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"},\"logicalType\":\"uuid\"},{\"name\":\"quantity\",\"type\":\"int\"}]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
private static final SpecificData MODEL$ = new SpecificData();
private static final BinaryMessageEncoder<Product> ENCODER =
new BinaryMessageEncoder<Product>(MODEL$, SCHEMA$);
private static final BinaryMessageDecoder<Product> DECODER =
new BinaryMessageDecoder<Product>(MODEL$, SCHEMA$);
/**
* Return the BinaryMessageEncoder instance used by this class.
* @return the message encoder used by this class
*/
public static BinaryMessageEncoder<Product> getEncoder() {
return ENCODER;
}
/**
* Return the BinaryMessageDecoder instance used by this class.
* @return the message decoder used by this class
*/
public static BinaryMessageDecoder<Product> getDecoder() {
return DECODER;
}
/**
* Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
* @param resolver a {@link SchemaStore} used to find schemas by fingerprint
* @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore
*/
public static BinaryMessageDecoder<Product> createDecoder(SchemaStore resolver) {
return new BinaryMessageDecoder<Product>(MODEL$, SCHEMA$, resolver);
}
/**
* Serializes this Product to a ByteBuffer.
* @return a buffer holding the serialized data for this instance
* @throws java.io.IOException if this instance could not be serialized
*/
public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
return ENCODER.encode(this);
}
/**
* Deserializes a Product from a ByteBuffer.
* @param b a byte buffer holding serialized data for an instance of this class
* @return a Product instance decoded from the given buffer
* @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class
*/
public static Product fromByteBuffer(
java.nio.ByteBuffer b) throws java.io.IOException {
return DECODER.decode(b);
}
private java.lang.String id;
private int quantity;
/**
* Default constructor. Note that this does not initialize fields
* to their default values from the schema. If that is desired then
* one should use <code>newBuilder()</code>.
*/
public Product() {}
/**
* All-args constructor.
* @param id The new value for id
* @param quantity The new value for quantity
*/
public Product(java.lang.String id, java.lang.Integer quantity) {
this.id = id;
this.quantity = quantity;
}
public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; }
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return id;
case 1: return quantity;
default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value$) {
switch (field$) {
case 0: id = value$ != null ? value$.toString() : null; break;
case 1: quantity = (java.lang.Integer)value$; break;
default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
}
}
/**
* Gets the value of the 'id' field.
* @return The value of the 'id' field.
*/
public java.lang.String getId() {
return id;
}
/**
* Sets the value of the 'id' field.
* @param value the value to set.
*/
public void setId(java.lang.String value) {
this.id = value;
}
/**
* Gets the value of the 'quantity' field.
* @return The value of the 'quantity' field.
*/
public int getQuantity() {
return quantity;
}
/**
* Sets the value of the 'quantity' field.
* @param value the value to set.
*/
public void setQuantity(int value) {
this.quantity = value;
}
/**
* Creates a new Product RecordBuilder.
* @return A new Product RecordBuilder
*/
public static com.food.order.system.kafka.order.avro.model.Product.Builder newBuilder() {
return new com.food.order.system.kafka.order.avro.model.Product.Builder();
}
/**
* Creates a new Product RecordBuilder by copying an existing Builder.
* @param other The existing builder to copy.
* @return A new Product RecordBuilder
*/
public static com.food.order.system.kafka.order.avro.model.Product.Builder newBuilder(com.food.order.system.kafka.order.avro.model.Product.Builder other) {
if (other == null) {
return new com.food.order.system.kafka.order.avro.model.Product.Builder();
} else {
return new com.food.order.system.kafka.order.avro.model.Product.Builder(other);
}
}
/**
* Creates a new Product RecordBuilder by copying an existing Product instance.
* @param other The existing instance to copy.
* @return A new Product RecordBuilder
*/
public static com.food.order.system.kafka.order.avro.model.Product.Builder newBuilder(com.food.order.system.kafka.order.avro.model.Product other) {
if (other == null) {
return new com.food.order.system.kafka.order.avro.model.Product.Builder();
} else {
return new com.food.order.system.kafka.order.avro.model.Product.Builder(other);
}
}
/**
* RecordBuilder for Product instances.
*/
@org.apache.avro.specific.AvroGenerated
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<Product>
implements org.apache.avro.data.RecordBuilder<Product> {
private java.lang.String id;
private int quantity;
/** Creates a new Builder */
private Builder() {
super(SCHEMA$, MODEL$);
}
/**
* Creates a Builder by copying an existing Builder.
* @param other The existing Builder to copy.
*/
private Builder(com.food.order.system.kafka.order.avro.model.Product.Builder other) {
super(other);
if (isValidValue(fields()[0], other.id)) {
this.id = data().deepCopy(fields()[0].schema(), other.id);
fieldSetFlags()[0] = other.fieldSetFlags()[0];
}
if (isValidValue(fields()[1], other.quantity)) {
this.quantity = data().deepCopy(fields()[1].schema(), other.quantity);
fieldSetFlags()[1] = other.fieldSetFlags()[1];
}
}
/**
* Creates a Builder by copying an existing Product instance
* @param other The existing instance to copy.
*/
private Builder(com.food.order.system.kafka.order.avro.model.Product other) {
super(SCHEMA$, MODEL$);
if (isValidValue(fields()[0], other.id)) {
this.id = data().deepCopy(fields()[0].schema(), other.id);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.quantity)) {
this.quantity = data().deepCopy(fields()[1].schema(), other.quantity);
fieldSetFlags()[1] = true;
}
}
/**
* Gets the value of the 'id' field.
* @return The value.
*/
public java.lang.String getId() {
return id;
}
/**
* Sets the value of the 'id' field.
* @param value The value of 'id'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.Product.Builder setId(java.lang.String value) {
validate(fields()[0], value);
this.id = value;
fieldSetFlags()[0] = true;
return this;
}
/**
* Checks whether the 'id' field has been set.
* @return True if the 'id' field has been set, false otherwise.
*/
public boolean hasId() {
return fieldSetFlags()[0];
}
/**
* Clears the value of the 'id' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.Product.Builder clearId() {
id = null;
fieldSetFlags()[0] = false;
return this;
}
/**
* Gets the value of the 'quantity' field.
* @return The value.
*/
public int getQuantity() {
return quantity;
}
/**
* Sets the value of the 'quantity' field.
* @param value The value of 'quantity'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.Product.Builder setQuantity(int value) {
validate(fields()[1], value);
this.quantity = value;
fieldSetFlags()[1] = true;
return this;
}
/**
* Checks whether the 'quantity' field has been set.
* @return True if the 'quantity' field has been set, false otherwise.
*/
public boolean hasQuantity() {
return fieldSetFlags()[1];
}
/**
* Clears the value of the 'quantity' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.Product.Builder clearQuantity() {
fieldSetFlags()[1] = false;
return this;
}
@Override
@SuppressWarnings("unchecked")
public Product build() {
try {
Product record = new Product();
record.id = fieldSetFlags()[0] ? this.id : (java.lang.String) defaultValue(fields()[0]);
record.quantity = fieldSetFlags()[1] ? this.quantity : (java.lang.Integer) defaultValue(fields()[1]);
return record;
} catch (org.apache.avro.AvroMissingFieldException e) {
throw e;
} catch (java.lang.Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumWriter<Product>
WRITER$ = (org.apache.avro.io.DatumWriter<Product>)MODEL$.createDatumWriter(SCHEMA$);
@Override public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
WRITER$.write(this, SpecificData.getEncoder(out));
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumReader<Product>
READER$ = (org.apache.avro.io.DatumReader<Product>)MODEL$.createDatumReader(SCHEMA$);
@Override public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
READER$.read(this, SpecificData.getDecoder(in));
}
@Override protected boolean hasCustomCoders() { return true; }
@Override public void customEncode(org.apache.avro.io.Encoder out)
throws java.io.IOException
{
out.writeString(this.id);
out.writeInt(this.quantity);
}
@Override public void customDecode(org.apache.avro.io.ResolvingDecoder in)
throws java.io.IOException
{
org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff();
if (fieldOrder == null) {
this.id = in.readString();
this.quantity = in.readInt();
} else {
for (int i = 0; i < 2; i++) {
switch (fieldOrder[i].pos()) {
case 0:
this.id = in.readString();
break;
case 1:
this.quantity = in.readInt();
break;
default:
throw new java.io.IOException("Corrupt ResolvingDecoder.");
}
}
}
}
}

View File

@@ -0,0 +1,809 @@
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.food.order.system.kafka.order.avro.model;
import org.apache.avro.generic.GenericArray;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.util.Utf8;
import org.apache.avro.message.BinaryMessageEncoder;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.message.SchemaStore;
@org.apache.avro.specific.AvroGenerated
public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
private static final long serialVersionUID = -3514710772324064017L;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"RestaurantApprovalRequestAvroModel\",\"namespace\":\"com.food.order.system.kafka.order.avro.model\",\"fields\":[{\"name\":\"id\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"sagaId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"restaurantId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"orderId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"restaurantOrderStatus\",\"type\":{\"type\":\"enum\",\"name\":\"RestaurantOrderStatus\",\"symbols\":[\"PAID\"]}},{\"name\":\"products\",\"type\":{\"type\":\"array\",\"items\":{\"type\":\"record\",\"name\":\"Product\",\"fields\":[{\"name\":\"id\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"},\"logicalType\":\"uuid\"},{\"name\":\"quantity\",\"type\":\"int\"}]}}},{\"name\":\"price\",\"type\":{\"type\":\"bytes\",\"logicalType\":\"decimal\",\"precision\":10,\"scale\":2}},{\"name\":\"createdAt\",\"type\":{\"type\":\"long\",\"logicalType\":\"timestamp-millis\"}}]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
private static final SpecificData MODEL$ = new SpecificData();
static {
MODEL$.addLogicalTypeConversion(new org.apache.avro.data.TimeConversions.TimestampMillisConversion());
MODEL$.addLogicalTypeConversion(new org.apache.avro.Conversions.DecimalConversion());
}
private static final BinaryMessageEncoder<RestaurantApprovalRequestAvroModel> ENCODER =
new BinaryMessageEncoder<RestaurantApprovalRequestAvroModel>(MODEL$, SCHEMA$);
private static final BinaryMessageDecoder<RestaurantApprovalRequestAvroModel> DECODER =
new BinaryMessageDecoder<RestaurantApprovalRequestAvroModel>(MODEL$, SCHEMA$);
/**
* Return the BinaryMessageEncoder instance used by this class.
* @return the message encoder used by this class
*/
public static BinaryMessageEncoder<RestaurantApprovalRequestAvroModel> getEncoder() {
return ENCODER;
}
/**
* Return the BinaryMessageDecoder instance used by this class.
* @return the message decoder used by this class
*/
public static BinaryMessageDecoder<RestaurantApprovalRequestAvroModel> getDecoder() {
return DECODER;
}
/**
* Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
* @param resolver a {@link SchemaStore} used to find schemas by fingerprint
* @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore
*/
public static BinaryMessageDecoder<RestaurantApprovalRequestAvroModel> createDecoder(SchemaStore resolver) {
return new BinaryMessageDecoder<RestaurantApprovalRequestAvroModel>(MODEL$, SCHEMA$, resolver);
}
/**
* Serializes this RestaurantApprovalRequestAvroModel to a ByteBuffer.
* @return a buffer holding the serialized data for this instance
* @throws java.io.IOException if this instance could not be serialized
*/
public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
return ENCODER.encode(this);
}
/**
* Deserializes a RestaurantApprovalRequestAvroModel from a ByteBuffer.
* @param b a byte buffer holding serialized data for an instance of this class
* @return a RestaurantApprovalRequestAvroModel instance decoded from the given buffer
* @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class
*/
public static RestaurantApprovalRequestAvroModel fromByteBuffer(
java.nio.ByteBuffer b) throws java.io.IOException {
return DECODER.decode(b);
}
private java.lang.String id;
private java.lang.String sagaId;
private java.lang.String restaurantId;
private java.lang.String orderId;
private com.food.order.system.kafka.order.avro.model.RestaurantOrderStatus restaurantOrderStatus;
private java.util.List<com.food.order.system.kafka.order.avro.model.Product> products;
private java.math.BigDecimal price;
private java.time.Instant createdAt;
/**
* Default constructor. Note that this does not initialize fields
* to their default values from the schema. If that is desired then
* one should use <code>newBuilder()</code>.
*/
public RestaurantApprovalRequestAvroModel() {}
/**
* All-args constructor.
* @param id The new value for id
* @param sagaId The new value for sagaId
* @param restaurantId The new value for restaurantId
* @param orderId The new value for orderId
* @param restaurantOrderStatus The new value for restaurantOrderStatus
* @param products The new value for products
* @param price The new value for price
* @param createdAt The new value for createdAt
*/
public RestaurantApprovalRequestAvroModel(java.lang.String id, java.lang.String sagaId, java.lang.String restaurantId, java.lang.String orderId, com.food.order.system.kafka.order.avro.model.RestaurantOrderStatus restaurantOrderStatus, java.util.List<com.food.order.system.kafka.order.avro.model.Product> products, java.math.BigDecimal price, java.time.Instant createdAt) {
this.id = id;
this.sagaId = sagaId;
this.restaurantId = restaurantId;
this.orderId = orderId;
this.restaurantOrderStatus = restaurantOrderStatus;
this.products = products;
this.price = price;
this.createdAt = createdAt.truncatedTo(java.time.temporal.ChronoUnit.MILLIS);
}
public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; }
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return id;
case 1: return sagaId;
case 2: return restaurantId;
case 3: return orderId;
case 4: return restaurantOrderStatus;
case 5: return products;
case 6: return price;
case 7: return createdAt;
default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
}
}
private static final org.apache.avro.Conversion<?>[] conversions =
new org.apache.avro.Conversion<?>[] {
null,
null,
null,
null,
null,
null,
new org.apache.avro.Conversions.DecimalConversion(),
new org.apache.avro.data.TimeConversions.TimestampMillisConversion(),
null
};
@Override
public org.apache.avro.Conversion<?> getConversion(int field) {
return conversions[field];
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value$) {
switch (field$) {
case 0: id = value$ != null ? value$.toString() : null; break;
case 1: sagaId = value$ != null ? value$.toString() : null; break;
case 2: restaurantId = value$ != null ? value$.toString() : null; break;
case 3: orderId = value$ != null ? value$.toString() : null; break;
case 4: restaurantOrderStatus = (com.food.order.system.kafka.order.avro.model.RestaurantOrderStatus)value$; break;
case 5: products = (java.util.List<com.food.order.system.kafka.order.avro.model.Product>)value$; break;
case 6: price = (java.math.BigDecimal)value$; break;
case 7: createdAt = (java.time.Instant)value$; break;
default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
}
}
/**
* Gets the value of the 'id' field.
* @return The value of the 'id' field.
*/
public java.lang.String getId() {
return id;
}
/**
* Sets the value of the 'id' field.
* @param value the value to set.
*/
public void setId(java.lang.String value) {
this.id = value;
}
/**
* Gets the value of the 'sagaId' field.
* @return The value of the 'sagaId' field.
*/
public java.lang.String getSagaId() {
return sagaId;
}
/**
* Sets the value of the 'sagaId' field.
* @param value the value to set.
*/
public void setSagaId(java.lang.String value) {
this.sagaId = value;
}
/**
* Gets the value of the 'restaurantId' field.
* @return The value of the 'restaurantId' field.
*/
public java.lang.String getRestaurantId() {
return restaurantId;
}
/**
* Sets the value of the 'restaurantId' field.
* @param value the value to set.
*/
public void setRestaurantId(java.lang.String value) {
this.restaurantId = value;
}
/**
* Gets the value of the 'orderId' field.
* @return The value of the 'orderId' field.
*/
public java.lang.String getOrderId() {
return orderId;
}
/**
* Sets the value of the 'orderId' field.
* @param value the value to set.
*/
public void setOrderId(java.lang.String value) {
this.orderId = value;
}
/**
* Gets the value of the 'restaurantOrderStatus' field.
* @return The value of the 'restaurantOrderStatus' field.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantOrderStatus getRestaurantOrderStatus() {
return restaurantOrderStatus;
}
/**
* Sets the value of the 'restaurantOrderStatus' field.
* @param value the value to set.
*/
public void setRestaurantOrderStatus(com.food.order.system.kafka.order.avro.model.RestaurantOrderStatus value) {
this.restaurantOrderStatus = value;
}
/**
* Gets the value of the 'products' field.
* @return The value of the 'products' field.
*/
public java.util.List<com.food.order.system.kafka.order.avro.model.Product> getProducts() {
return products;
}
/**
* Sets the value of the 'products' field.
* @param value the value to set.
*/
public void setProducts(java.util.List<com.food.order.system.kafka.order.avro.model.Product> value) {
this.products = value;
}
/**
* Gets the value of the 'price' field.
* @return The value of the 'price' field.
*/
public java.math.BigDecimal getPrice() {
return price;
}
/**
* Sets the value of the 'price' field.
* @param value the value to set.
*/
public void setPrice(java.math.BigDecimal value) {
this.price = value;
}
/**
* Gets the value of the 'createdAt' field.
* @return The value of the 'createdAt' field.
*/
public java.time.Instant getCreatedAt() {
return createdAt;
}
/**
* Sets the value of the 'createdAt' field.
* @param value the value to set.
*/
public void setCreatedAt(java.time.Instant value) {
this.createdAt = value.truncatedTo(java.time.temporal.ChronoUnit.MILLIS);
}
/**
* Creates a new RestaurantApprovalRequestAvroModel RecordBuilder.
* @return A new RestaurantApprovalRequestAvroModel RecordBuilder
*/
public static com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder newBuilder() {
return new com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder();
}
/**
* Creates a new RestaurantApprovalRequestAvroModel RecordBuilder by copying an existing Builder.
* @param other The existing builder to copy.
* @return A new RestaurantApprovalRequestAvroModel RecordBuilder
*/
public static com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder newBuilder(com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder other) {
if (other == null) {
return new com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder();
} else {
return new com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder(other);
}
}
/**
* Creates a new RestaurantApprovalRequestAvroModel RecordBuilder by copying an existing RestaurantApprovalRequestAvroModel instance.
* @param other The existing instance to copy.
* @return A new RestaurantApprovalRequestAvroModel RecordBuilder
*/
public static com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder newBuilder(com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel other) {
if (other == null) {
return new com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder();
} else {
return new com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder(other);
}
}
/**
* RecordBuilder for RestaurantApprovalRequestAvroModel instances.
*/
@org.apache.avro.specific.AvroGenerated
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<RestaurantApprovalRequestAvroModel>
implements org.apache.avro.data.RecordBuilder<RestaurantApprovalRequestAvroModel> {
private java.lang.String id;
private java.lang.String sagaId;
private java.lang.String restaurantId;
private java.lang.String orderId;
private com.food.order.system.kafka.order.avro.model.RestaurantOrderStatus restaurantOrderStatus;
private java.util.List<com.food.order.system.kafka.order.avro.model.Product> products;
private java.math.BigDecimal price;
private java.time.Instant createdAt;
/** Creates a new Builder */
private Builder() {
super(SCHEMA$, MODEL$);
}
/**
* Creates a Builder by copying an existing Builder.
* @param other The existing Builder to copy.
*/
private Builder(com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder other) {
super(other);
if (isValidValue(fields()[0], other.id)) {
this.id = data().deepCopy(fields()[0].schema(), other.id);
fieldSetFlags()[0] = other.fieldSetFlags()[0];
}
if (isValidValue(fields()[1], other.sagaId)) {
this.sagaId = data().deepCopy(fields()[1].schema(), other.sagaId);
fieldSetFlags()[1] = other.fieldSetFlags()[1];
}
if (isValidValue(fields()[2], other.restaurantId)) {
this.restaurantId = data().deepCopy(fields()[2].schema(), other.restaurantId);
fieldSetFlags()[2] = other.fieldSetFlags()[2];
}
if (isValidValue(fields()[3], other.orderId)) {
this.orderId = data().deepCopy(fields()[3].schema(), other.orderId);
fieldSetFlags()[3] = other.fieldSetFlags()[3];
}
if (isValidValue(fields()[4], other.restaurantOrderStatus)) {
this.restaurantOrderStatus = data().deepCopy(fields()[4].schema(), other.restaurantOrderStatus);
fieldSetFlags()[4] = other.fieldSetFlags()[4];
}
if (isValidValue(fields()[5], other.products)) {
this.products = data().deepCopy(fields()[5].schema(), other.products);
fieldSetFlags()[5] = other.fieldSetFlags()[5];
}
if (isValidValue(fields()[6], other.price)) {
this.price = data().deepCopy(fields()[6].schema(), other.price);
fieldSetFlags()[6] = other.fieldSetFlags()[6];
}
if (isValidValue(fields()[7], other.createdAt)) {
this.createdAt = data().deepCopy(fields()[7].schema(), other.createdAt);
fieldSetFlags()[7] = other.fieldSetFlags()[7];
}
}
/**
* Creates a Builder by copying an existing RestaurantApprovalRequestAvroModel instance
* @param other The existing instance to copy.
*/
private Builder(com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel other) {
super(SCHEMA$, MODEL$);
if (isValidValue(fields()[0], other.id)) {
this.id = data().deepCopy(fields()[0].schema(), other.id);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.sagaId)) {
this.sagaId = data().deepCopy(fields()[1].schema(), other.sagaId);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.restaurantId)) {
this.restaurantId = data().deepCopy(fields()[2].schema(), other.restaurantId);
fieldSetFlags()[2] = true;
}
if (isValidValue(fields()[3], other.orderId)) {
this.orderId = data().deepCopy(fields()[3].schema(), other.orderId);
fieldSetFlags()[3] = true;
}
if (isValidValue(fields()[4], other.restaurantOrderStatus)) {
this.restaurantOrderStatus = data().deepCopy(fields()[4].schema(), other.restaurantOrderStatus);
fieldSetFlags()[4] = true;
}
if (isValidValue(fields()[5], other.products)) {
this.products = data().deepCopy(fields()[5].schema(), other.products);
fieldSetFlags()[5] = true;
}
if (isValidValue(fields()[6], other.price)) {
this.price = data().deepCopy(fields()[6].schema(), other.price);
fieldSetFlags()[6] = true;
}
if (isValidValue(fields()[7], other.createdAt)) {
this.createdAt = data().deepCopy(fields()[7].schema(), other.createdAt);
fieldSetFlags()[7] = true;
}
}
/**
* Gets the value of the 'id' field.
* @return The value.
*/
public java.lang.String getId() {
return id;
}
/**
* Sets the value of the 'id' field.
* @param value The value of 'id'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder setId(java.lang.String value) {
validate(fields()[0], value);
this.id = value;
fieldSetFlags()[0] = true;
return this;
}
/**
* Checks whether the 'id' field has been set.
* @return True if the 'id' field has been set, false otherwise.
*/
public boolean hasId() {
return fieldSetFlags()[0];
}
/**
* Clears the value of the 'id' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder clearId() {
id = null;
fieldSetFlags()[0] = false;
return this;
}
/**
* Gets the value of the 'sagaId' field.
* @return The value.
*/
public java.lang.String getSagaId() {
return sagaId;
}
/**
* Sets the value of the 'sagaId' field.
* @param value The value of 'sagaId'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder setSagaId(java.lang.String value) {
validate(fields()[1], value);
this.sagaId = value;
fieldSetFlags()[1] = true;
return this;
}
/**
* Checks whether the 'sagaId' field has been set.
* @return True if the 'sagaId' field has been set, false otherwise.
*/
public boolean hasSagaId() {
return fieldSetFlags()[1];
}
/**
* Clears the value of the 'sagaId' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder clearSagaId() {
sagaId = null;
fieldSetFlags()[1] = false;
return this;
}
/**
* Gets the value of the 'restaurantId' field.
* @return The value.
*/
public java.lang.String getRestaurantId() {
return restaurantId;
}
/**
* Sets the value of the 'restaurantId' field.
* @param value The value of 'restaurantId'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder setRestaurantId(java.lang.String value) {
validate(fields()[2], value);
this.restaurantId = value;
fieldSetFlags()[2] = true;
return this;
}
/**
* Checks whether the 'restaurantId' field has been set.
* @return True if the 'restaurantId' field has been set, false otherwise.
*/
public boolean hasRestaurantId() {
return fieldSetFlags()[2];
}
/**
* Clears the value of the 'restaurantId' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder clearRestaurantId() {
restaurantId = null;
fieldSetFlags()[2] = false;
return this;
}
/**
* Gets the value of the 'orderId' field.
* @return The value.
*/
public java.lang.String getOrderId() {
return orderId;
}
/**
* Sets the value of the 'orderId' field.
* @param value The value of 'orderId'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder setOrderId(java.lang.String value) {
validate(fields()[3], value);
this.orderId = value;
fieldSetFlags()[3] = true;
return this;
}
/**
* Checks whether the 'orderId' field has been set.
* @return True if the 'orderId' field has been set, false otherwise.
*/
public boolean hasOrderId() {
return fieldSetFlags()[3];
}
/**
* Clears the value of the 'orderId' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder clearOrderId() {
orderId = null;
fieldSetFlags()[3] = false;
return this;
}
/**
* Gets the value of the 'restaurantOrderStatus' field.
* @return The value.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantOrderStatus getRestaurantOrderStatus() {
return restaurantOrderStatus;
}
/**
* Sets the value of the 'restaurantOrderStatus' field.
* @param value The value of 'restaurantOrderStatus'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder setRestaurantOrderStatus(com.food.order.system.kafka.order.avro.model.RestaurantOrderStatus value) {
validate(fields()[4], value);
this.restaurantOrderStatus = value;
fieldSetFlags()[4] = true;
return this;
}
/**
* Checks whether the 'restaurantOrderStatus' field has been set.
* @return True if the 'restaurantOrderStatus' field has been set, false otherwise.
*/
public boolean hasRestaurantOrderStatus() {
return fieldSetFlags()[4];
}
/**
* Clears the value of the 'restaurantOrderStatus' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder clearRestaurantOrderStatus() {
restaurantOrderStatus = null;
fieldSetFlags()[4] = false;
return this;
}
/**
* Gets the value of the 'products' field.
* @return The value.
*/
public java.util.List<com.food.order.system.kafka.order.avro.model.Product> getProducts() {
return products;
}
/**
* Sets the value of the 'products' field.
* @param value The value of 'products'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder setProducts(java.util.List<com.food.order.system.kafka.order.avro.model.Product> value) {
validate(fields()[5], value);
this.products = value;
fieldSetFlags()[5] = true;
return this;
}
/**
* Checks whether the 'products' field has been set.
* @return True if the 'products' field has been set, false otherwise.
*/
public boolean hasProducts() {
return fieldSetFlags()[5];
}
/**
* Clears the value of the 'products' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder clearProducts() {
products = null;
fieldSetFlags()[5] = false;
return this;
}
/**
* Gets the value of the 'price' field.
* @return The value.
*/
public java.math.BigDecimal getPrice() {
return price;
}
/**
* Sets the value of the 'price' field.
* @param value The value of 'price'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder setPrice(java.math.BigDecimal value) {
validate(fields()[6], value);
this.price = value;
fieldSetFlags()[6] = true;
return this;
}
/**
* Checks whether the 'price' field has been set.
* @return True if the 'price' field has been set, false otherwise.
*/
public boolean hasPrice() {
return fieldSetFlags()[6];
}
/**
* Clears the value of the 'price' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder clearPrice() {
price = null;
fieldSetFlags()[6] = false;
return this;
}
/**
* Gets the value of the 'createdAt' field.
* @return The value.
*/
public java.time.Instant getCreatedAt() {
return createdAt;
}
/**
* Sets the value of the 'createdAt' field.
* @param value The value of 'createdAt'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder setCreatedAt(java.time.Instant value) {
validate(fields()[7], value);
this.createdAt = value.truncatedTo(java.time.temporal.ChronoUnit.MILLIS);
fieldSetFlags()[7] = true;
return this;
}
/**
* Checks whether the 'createdAt' field has been set.
* @return True if the 'createdAt' field has been set, false otherwise.
*/
public boolean hasCreatedAt() {
return fieldSetFlags()[7];
}
/**
* Clears the value of the 'createdAt' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder clearCreatedAt() {
fieldSetFlags()[7] = false;
return this;
}
@Override
@SuppressWarnings("unchecked")
public RestaurantApprovalRequestAvroModel build() {
try {
RestaurantApprovalRequestAvroModel record = new RestaurantApprovalRequestAvroModel();
record.id = fieldSetFlags()[0] ? this.id : (java.lang.String) defaultValue(fields()[0]);
record.sagaId = fieldSetFlags()[1] ? this.sagaId : (java.lang.String) defaultValue(fields()[1]);
record.restaurantId = fieldSetFlags()[2] ? this.restaurantId : (java.lang.String) defaultValue(fields()[2]);
record.orderId = fieldSetFlags()[3] ? this.orderId : (java.lang.String) defaultValue(fields()[3]);
record.restaurantOrderStatus = fieldSetFlags()[4] ? this.restaurantOrderStatus : (com.food.order.system.kafka.order.avro.model.RestaurantOrderStatus) defaultValue(fields()[4]);
record.products = fieldSetFlags()[5] ? this.products : (java.util.List<com.food.order.system.kafka.order.avro.model.Product>) defaultValue(fields()[5]);
record.price = fieldSetFlags()[6] ? this.price : (java.math.BigDecimal) defaultValue(fields()[6]);
record.createdAt = fieldSetFlags()[7] ? this.createdAt : (java.time.Instant) defaultValue(fields()[7]);
return record;
} catch (org.apache.avro.AvroMissingFieldException e) {
throw e;
} catch (java.lang.Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumWriter<RestaurantApprovalRequestAvroModel>
WRITER$ = (org.apache.avro.io.DatumWriter<RestaurantApprovalRequestAvroModel>)MODEL$.createDatumWriter(SCHEMA$);
@Override public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
WRITER$.write(this, SpecificData.getEncoder(out));
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumReader<RestaurantApprovalRequestAvroModel>
READER$ = (org.apache.avro.io.DatumReader<RestaurantApprovalRequestAvroModel>)MODEL$.createDatumReader(SCHEMA$);
@Override public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
READER$.read(this, SpecificData.getDecoder(in));
}
}

View File

@@ -0,0 +1,735 @@
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.food.order.system.kafka.order.avro.model;
import org.apache.avro.generic.GenericArray;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.util.Utf8;
import org.apache.avro.message.BinaryMessageEncoder;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.message.SchemaStore;
@org.apache.avro.specific.AvroGenerated
public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
private static final long serialVersionUID = -5203212934279996672L;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"RestaurantApprovalResponseAvroModel\",\"namespace\":\"com.food.order.system.kafka.order.avro.model\",\"fields\":[{\"name\":\"id\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"sagaId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"restaurantId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"orderId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"createdAt\",\"type\":{\"type\":\"long\",\"logicalType\":\"timestamp-millis\"}},{\"name\":\"orderApprovalStatus\",\"type\":{\"type\":\"enum\",\"name\":\"OrderApprovalStatus\",\"symbols\":[\"APPROVED\",\"REJECTED\"]}},{\"name\":\"failureMessages\",\"type\":{\"type\":\"array\",\"items\":{\"type\":\"string\",\"avro.java.string\":\"String\"}}}]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
private static final SpecificData MODEL$ = new SpecificData();
static {
MODEL$.addLogicalTypeConversion(new org.apache.avro.data.TimeConversions.TimestampMillisConversion());
}
private static final BinaryMessageEncoder<RestaurantApprovalResponseAvroModel> ENCODER =
new BinaryMessageEncoder<RestaurantApprovalResponseAvroModel>(MODEL$, SCHEMA$);
private static final BinaryMessageDecoder<RestaurantApprovalResponseAvroModel> DECODER =
new BinaryMessageDecoder<RestaurantApprovalResponseAvroModel>(MODEL$, SCHEMA$);
/**
* Return the BinaryMessageEncoder instance used by this class.
* @return the message encoder used by this class
*/
public static BinaryMessageEncoder<RestaurantApprovalResponseAvroModel> getEncoder() {
return ENCODER;
}
/**
* Return the BinaryMessageDecoder instance used by this class.
* @return the message decoder used by this class
*/
public static BinaryMessageDecoder<RestaurantApprovalResponseAvroModel> getDecoder() {
return DECODER;
}
/**
* Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
* @param resolver a {@link SchemaStore} used to find schemas by fingerprint
* @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore
*/
public static BinaryMessageDecoder<RestaurantApprovalResponseAvroModel> createDecoder(SchemaStore resolver) {
return new BinaryMessageDecoder<RestaurantApprovalResponseAvroModel>(MODEL$, SCHEMA$, resolver);
}
/**
* Serializes this RestaurantApprovalResponseAvroModel to a ByteBuffer.
* @return a buffer holding the serialized data for this instance
* @throws java.io.IOException if this instance could not be serialized
*/
public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
return ENCODER.encode(this);
}
/**
* Deserializes a RestaurantApprovalResponseAvroModel from a ByteBuffer.
* @param b a byte buffer holding serialized data for an instance of this class
* @return a RestaurantApprovalResponseAvroModel instance decoded from the given buffer
* @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class
*/
public static RestaurantApprovalResponseAvroModel fromByteBuffer(
java.nio.ByteBuffer b) throws java.io.IOException {
return DECODER.decode(b);
}
private java.lang.String id;
private java.lang.String sagaId;
private java.lang.String restaurantId;
private java.lang.String orderId;
private java.time.Instant createdAt;
private com.food.order.system.kafka.order.avro.model.OrderApprovalStatus orderApprovalStatus;
private java.util.List<java.lang.String> failureMessages;
/**
* Default constructor. Note that this does not initialize fields
* to their default values from the schema. If that is desired then
* one should use <code>newBuilder()</code>.
*/
public RestaurantApprovalResponseAvroModel() {}
/**
* All-args constructor.
* @param id The new value for id
* @param sagaId The new value for sagaId
* @param restaurantId The new value for restaurantId
* @param orderId The new value for orderId
* @param createdAt The new value for createdAt
* @param orderApprovalStatus The new value for orderApprovalStatus
* @param failureMessages The new value for failureMessages
*/
public RestaurantApprovalResponseAvroModel(java.lang.String id, java.lang.String sagaId, java.lang.String restaurantId, java.lang.String orderId, java.time.Instant createdAt, com.food.order.system.kafka.order.avro.model.OrderApprovalStatus orderApprovalStatus, java.util.List<java.lang.String> failureMessages) {
this.id = id;
this.sagaId = sagaId;
this.restaurantId = restaurantId;
this.orderId = orderId;
this.createdAt = createdAt.truncatedTo(java.time.temporal.ChronoUnit.MILLIS);
this.orderApprovalStatus = orderApprovalStatus;
this.failureMessages = failureMessages;
}
public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; }
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return id;
case 1: return sagaId;
case 2: return restaurantId;
case 3: return orderId;
case 4: return createdAt;
case 5: return orderApprovalStatus;
case 6: return failureMessages;
default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
}
}
private static final org.apache.avro.Conversion<?>[] conversions =
new org.apache.avro.Conversion<?>[] {
null,
null,
null,
null,
new org.apache.avro.data.TimeConversions.TimestampMillisConversion(),
null,
null,
null
};
@Override
public org.apache.avro.Conversion<?> getConversion(int field) {
return conversions[field];
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value$) {
switch (field$) {
case 0: id = value$ != null ? value$.toString() : null; break;
case 1: sagaId = value$ != null ? value$.toString() : null; break;
case 2: restaurantId = value$ != null ? value$.toString() : null; break;
case 3: orderId = value$ != null ? value$.toString() : null; break;
case 4: createdAt = (java.time.Instant)value$; break;
case 5: orderApprovalStatus = (com.food.order.system.kafka.order.avro.model.OrderApprovalStatus)value$; break;
case 6: failureMessages = (java.util.List<java.lang.String>)value$; break;
default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
}
}
/**
* Gets the value of the 'id' field.
* @return The value of the 'id' field.
*/
public java.lang.String getId() {
return id;
}
/**
* Sets the value of the 'id' field.
* @param value the value to set.
*/
public void setId(java.lang.String value) {
this.id = value;
}
/**
* Gets the value of the 'sagaId' field.
* @return The value of the 'sagaId' field.
*/
public java.lang.String getSagaId() {
return sagaId;
}
/**
* Sets the value of the 'sagaId' field.
* @param value the value to set.
*/
public void setSagaId(java.lang.String value) {
this.sagaId = value;
}
/**
* Gets the value of the 'restaurantId' field.
* @return The value of the 'restaurantId' field.
*/
public java.lang.String getRestaurantId() {
return restaurantId;
}
/**
* Sets the value of the 'restaurantId' field.
* @param value the value to set.
*/
public void setRestaurantId(java.lang.String value) {
this.restaurantId = value;
}
/**
* Gets the value of the 'orderId' field.
* @return The value of the 'orderId' field.
*/
public java.lang.String getOrderId() {
return orderId;
}
/**
* Sets the value of the 'orderId' field.
* @param value the value to set.
*/
public void setOrderId(java.lang.String value) {
this.orderId = value;
}
/**
* Gets the value of the 'createdAt' field.
* @return The value of the 'createdAt' field.
*/
public java.time.Instant getCreatedAt() {
return createdAt;
}
/**
* Sets the value of the 'createdAt' field.
* @param value the value to set.
*/
public void setCreatedAt(java.time.Instant value) {
this.createdAt = value.truncatedTo(java.time.temporal.ChronoUnit.MILLIS);
}
/**
* Gets the value of the 'orderApprovalStatus' field.
* @return The value of the 'orderApprovalStatus' field.
*/
public com.food.order.system.kafka.order.avro.model.OrderApprovalStatus getOrderApprovalStatus() {
return orderApprovalStatus;
}
/**
* Sets the value of the 'orderApprovalStatus' field.
* @param value the value to set.
*/
public void setOrderApprovalStatus(com.food.order.system.kafka.order.avro.model.OrderApprovalStatus value) {
this.orderApprovalStatus = value;
}
/**
* Gets the value of the 'failureMessages' field.
* @return The value of the 'failureMessages' field.
*/
public java.util.List<java.lang.String> getFailureMessages() {
return failureMessages;
}
/**
* Sets the value of the 'failureMessages' field.
* @param value the value to set.
*/
public void setFailureMessages(java.util.List<java.lang.String> value) {
this.failureMessages = value;
}
/**
* Creates a new RestaurantApprovalResponseAvroModel RecordBuilder.
* @return A new RestaurantApprovalResponseAvroModel RecordBuilder
*/
public static com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder newBuilder() {
return new com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder();
}
/**
* Creates a new RestaurantApprovalResponseAvroModel RecordBuilder by copying an existing Builder.
* @param other The existing builder to copy.
* @return A new RestaurantApprovalResponseAvroModel RecordBuilder
*/
public static com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder newBuilder(com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder other) {
if (other == null) {
return new com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder();
} else {
return new com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder(other);
}
}
/**
* Creates a new RestaurantApprovalResponseAvroModel RecordBuilder by copying an existing RestaurantApprovalResponseAvroModel instance.
* @param other The existing instance to copy.
* @return A new RestaurantApprovalResponseAvroModel RecordBuilder
*/
public static com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder newBuilder(com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel other) {
if (other == null) {
return new com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder();
} else {
return new com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder(other);
}
}
/**
* RecordBuilder for RestaurantApprovalResponseAvroModel instances.
*/
@org.apache.avro.specific.AvroGenerated
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<RestaurantApprovalResponseAvroModel>
implements org.apache.avro.data.RecordBuilder<RestaurantApprovalResponseAvroModel> {
private java.lang.String id;
private java.lang.String sagaId;
private java.lang.String restaurantId;
private java.lang.String orderId;
private java.time.Instant createdAt;
private com.food.order.system.kafka.order.avro.model.OrderApprovalStatus orderApprovalStatus;
private java.util.List<java.lang.String> failureMessages;
/** Creates a new Builder */
private Builder() {
super(SCHEMA$, MODEL$);
}
/**
* Creates a Builder by copying an existing Builder.
* @param other The existing Builder to copy.
*/
private Builder(com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder other) {
super(other);
if (isValidValue(fields()[0], other.id)) {
this.id = data().deepCopy(fields()[0].schema(), other.id);
fieldSetFlags()[0] = other.fieldSetFlags()[0];
}
if (isValidValue(fields()[1], other.sagaId)) {
this.sagaId = data().deepCopy(fields()[1].schema(), other.sagaId);
fieldSetFlags()[1] = other.fieldSetFlags()[1];
}
if (isValidValue(fields()[2], other.restaurantId)) {
this.restaurantId = data().deepCopy(fields()[2].schema(), other.restaurantId);
fieldSetFlags()[2] = other.fieldSetFlags()[2];
}
if (isValidValue(fields()[3], other.orderId)) {
this.orderId = data().deepCopy(fields()[3].schema(), other.orderId);
fieldSetFlags()[3] = other.fieldSetFlags()[3];
}
if (isValidValue(fields()[4], other.createdAt)) {
this.createdAt = data().deepCopy(fields()[4].schema(), other.createdAt);
fieldSetFlags()[4] = other.fieldSetFlags()[4];
}
if (isValidValue(fields()[5], other.orderApprovalStatus)) {
this.orderApprovalStatus = data().deepCopy(fields()[5].schema(), other.orderApprovalStatus);
fieldSetFlags()[5] = other.fieldSetFlags()[5];
}
if (isValidValue(fields()[6], other.failureMessages)) {
this.failureMessages = data().deepCopy(fields()[6].schema(), other.failureMessages);
fieldSetFlags()[6] = other.fieldSetFlags()[6];
}
}
/**
* Creates a Builder by copying an existing RestaurantApprovalResponseAvroModel instance
* @param other The existing instance to copy.
*/
private Builder(com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel other) {
super(SCHEMA$, MODEL$);
if (isValidValue(fields()[0], other.id)) {
this.id = data().deepCopy(fields()[0].schema(), other.id);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.sagaId)) {
this.sagaId = data().deepCopy(fields()[1].schema(), other.sagaId);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.restaurantId)) {
this.restaurantId = data().deepCopy(fields()[2].schema(), other.restaurantId);
fieldSetFlags()[2] = true;
}
if (isValidValue(fields()[3], other.orderId)) {
this.orderId = data().deepCopy(fields()[3].schema(), other.orderId);
fieldSetFlags()[3] = true;
}
if (isValidValue(fields()[4], other.createdAt)) {
this.createdAt = data().deepCopy(fields()[4].schema(), other.createdAt);
fieldSetFlags()[4] = true;
}
if (isValidValue(fields()[5], other.orderApprovalStatus)) {
this.orderApprovalStatus = data().deepCopy(fields()[5].schema(), other.orderApprovalStatus);
fieldSetFlags()[5] = true;
}
if (isValidValue(fields()[6], other.failureMessages)) {
this.failureMessages = data().deepCopy(fields()[6].schema(), other.failureMessages);
fieldSetFlags()[6] = true;
}
}
/**
* Gets the value of the 'id' field.
* @return The value.
*/
public java.lang.String getId() {
return id;
}
/**
* Sets the value of the 'id' field.
* @param value The value of 'id'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder setId(java.lang.String value) {
validate(fields()[0], value);
this.id = value;
fieldSetFlags()[0] = true;
return this;
}
/**
* Checks whether the 'id' field has been set.
* @return True if the 'id' field has been set, false otherwise.
*/
public boolean hasId() {
return fieldSetFlags()[0];
}
/**
* Clears the value of the 'id' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder clearId() {
id = null;
fieldSetFlags()[0] = false;
return this;
}
/**
* Gets the value of the 'sagaId' field.
* @return The value.
*/
public java.lang.String getSagaId() {
return sagaId;
}
/**
* Sets the value of the 'sagaId' field.
* @param value The value of 'sagaId'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder setSagaId(java.lang.String value) {
validate(fields()[1], value);
this.sagaId = value;
fieldSetFlags()[1] = true;
return this;
}
/**
* Checks whether the 'sagaId' field has been set.
* @return True if the 'sagaId' field has been set, false otherwise.
*/
public boolean hasSagaId() {
return fieldSetFlags()[1];
}
/**
* Clears the value of the 'sagaId' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder clearSagaId() {
sagaId = null;
fieldSetFlags()[1] = false;
return this;
}
/**
* Gets the value of the 'restaurantId' field.
* @return The value.
*/
public java.lang.String getRestaurantId() {
return restaurantId;
}
/**
* Sets the value of the 'restaurantId' field.
* @param value The value of 'restaurantId'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder setRestaurantId(java.lang.String value) {
validate(fields()[2], value);
this.restaurantId = value;
fieldSetFlags()[2] = true;
return this;
}
/**
* Checks whether the 'restaurantId' field has been set.
* @return True if the 'restaurantId' field has been set, false otherwise.
*/
public boolean hasRestaurantId() {
return fieldSetFlags()[2];
}
/**
* Clears the value of the 'restaurantId' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder clearRestaurantId() {
restaurantId = null;
fieldSetFlags()[2] = false;
return this;
}
/**
* Gets the value of the 'orderId' field.
* @return The value.
*/
public java.lang.String getOrderId() {
return orderId;
}
/**
* Sets the value of the 'orderId' field.
* @param value The value of 'orderId'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder setOrderId(java.lang.String value) {
validate(fields()[3], value);
this.orderId = value;
fieldSetFlags()[3] = true;
return this;
}
/**
* Checks whether the 'orderId' field has been set.
* @return True if the 'orderId' field has been set, false otherwise.
*/
public boolean hasOrderId() {
return fieldSetFlags()[3];
}
/**
* Clears the value of the 'orderId' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder clearOrderId() {
orderId = null;
fieldSetFlags()[3] = false;
return this;
}
/**
* Gets the value of the 'createdAt' field.
* @return The value.
*/
public java.time.Instant getCreatedAt() {
return createdAt;
}
/**
* Sets the value of the 'createdAt' field.
* @param value The value of 'createdAt'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder setCreatedAt(java.time.Instant value) {
validate(fields()[4], value);
this.createdAt = value.truncatedTo(java.time.temporal.ChronoUnit.MILLIS);
fieldSetFlags()[4] = true;
return this;
}
/**
* Checks whether the 'createdAt' field has been set.
* @return True if the 'createdAt' field has been set, false otherwise.
*/
public boolean hasCreatedAt() {
return fieldSetFlags()[4];
}
/**
* Clears the value of the 'createdAt' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder clearCreatedAt() {
fieldSetFlags()[4] = false;
return this;
}
/**
* Gets the value of the 'orderApprovalStatus' field.
* @return The value.
*/
public com.food.order.system.kafka.order.avro.model.OrderApprovalStatus getOrderApprovalStatus() {
return orderApprovalStatus;
}
/**
* Sets the value of the 'orderApprovalStatus' field.
* @param value The value of 'orderApprovalStatus'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder setOrderApprovalStatus(com.food.order.system.kafka.order.avro.model.OrderApprovalStatus value) {
validate(fields()[5], value);
this.orderApprovalStatus = value;
fieldSetFlags()[5] = true;
return this;
}
/**
* Checks whether the 'orderApprovalStatus' field has been set.
* @return True if the 'orderApprovalStatus' field has been set, false otherwise.
*/
public boolean hasOrderApprovalStatus() {
return fieldSetFlags()[5];
}
/**
* Clears the value of the 'orderApprovalStatus' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder clearOrderApprovalStatus() {
orderApprovalStatus = null;
fieldSetFlags()[5] = false;
return this;
}
/**
* Gets the value of the 'failureMessages' field.
* @return The value.
*/
public java.util.List<java.lang.String> getFailureMessages() {
return failureMessages;
}
/**
* Sets the value of the 'failureMessages' field.
* @param value The value of 'failureMessages'.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder setFailureMessages(java.util.List<java.lang.String> value) {
validate(fields()[6], value);
this.failureMessages = value;
fieldSetFlags()[6] = true;
return this;
}
/**
* Checks whether the 'failureMessages' field has been set.
* @return True if the 'failureMessages' field has been set, false otherwise.
*/
public boolean hasFailureMessages() {
return fieldSetFlags()[6];
}
/**
* Clears the value of the 'failureMessages' field.
* @return This builder.
*/
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder clearFailureMessages() {
failureMessages = null;
fieldSetFlags()[6] = false;
return this;
}
@Override
@SuppressWarnings("unchecked")
public RestaurantApprovalResponseAvroModel build() {
try {
RestaurantApprovalResponseAvroModel record = new RestaurantApprovalResponseAvroModel();
record.id = fieldSetFlags()[0] ? this.id : (java.lang.String) defaultValue(fields()[0]);
record.sagaId = fieldSetFlags()[1] ? this.sagaId : (java.lang.String) defaultValue(fields()[1]);
record.restaurantId = fieldSetFlags()[2] ? this.restaurantId : (java.lang.String) defaultValue(fields()[2]);
record.orderId = fieldSetFlags()[3] ? this.orderId : (java.lang.String) defaultValue(fields()[3]);
record.createdAt = fieldSetFlags()[4] ? this.createdAt : (java.time.Instant) defaultValue(fields()[4]);
record.orderApprovalStatus = fieldSetFlags()[5] ? this.orderApprovalStatus : (com.food.order.system.kafka.order.avro.model.OrderApprovalStatus) defaultValue(fields()[5]);
record.failureMessages = fieldSetFlags()[6] ? this.failureMessages : (java.util.List<java.lang.String>) defaultValue(fields()[6]);
return record;
} catch (org.apache.avro.AvroMissingFieldException e) {
throw e;
} catch (java.lang.Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumWriter<RestaurantApprovalResponseAvroModel>
WRITER$ = (org.apache.avro.io.DatumWriter<RestaurantApprovalResponseAvroModel>)MODEL$.createDatumWriter(SCHEMA$);
@Override public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
WRITER$.write(this, SpecificData.getEncoder(out));
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumReader<RestaurantApprovalResponseAvroModel>
READER$ = (org.apache.avro.io.DatumReader<RestaurantApprovalResponseAvroModel>)MODEL$.createDatumReader(SCHEMA$);
@Override public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
READER$.read(this, SpecificData.getDecoder(in));
}
}

View File

@@ -0,0 +1,13 @@
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.food.order.system.kafka.order.avro.model;
@org.apache.avro.specific.AvroGenerated
public enum RestaurantOrderStatus implements org.apache.avro.generic.GenericEnumSymbol<RestaurantOrderStatus> {
PAID ;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"enum\",\"name\":\"RestaurantOrderStatus\",\"namespace\":\"com.food.order.system.kafka.order.avro.model\",\"symbols\":[\"PAID\"]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
}

View File

@@ -0,0 +1,32 @@
{
"namespace": "com.food.order.system.kafka.order.avro.model",
"type": "record",
"name": "CustomerAvroModel",
"fields": [
{
"name": "id",
"type": {
"type": "string",
"logicalType": "uuid"
}
},
{
"name": "username",
"type": {
"type": "string"
}
},
{
"name": "firstName",
"type": {
"type": "string"
}
},
{
"name": "lastName",
"type": {
"type": "string"
}
}
]
}

View File

@@ -0,0 +1,59 @@
{
"namespace": "com.food.order.system.kafka.order.avro.model",
"type": "record",
"name": "PaymentRequestAvroModel",
"fields": [
{
"name": "id",
"type": {
"type": "string",
"logicalType": "uuid"
}
},
{
"name": "sagaId",
"type": {
"type": "string",
"logicalType": "uuid"
}
},
{
"name": "customerId",
"type": {
"type": "string",
"logicalType": "uuid"
}
},
{
"name": "orderId",
"type": {
"type": "string",
"logicalType": "uuid"
}
},
{
"name": "price",
"type": {
"type": "bytes",
"logicalType": "decimal",
"precision": 10,
"scale": 2
}
},
{
"name": "createdAt",
"type": {
"type": "long",
"logicalType": "timestamp-millis"
}
},
{
"name": "paymentOrderStatus",
"type": {
"type": "enum",
"name": "PaymentOrderStatus",
"symbols": ["PENDING", "CANCELLED"]
}
}
]
}

View File

@@ -0,0 +1,75 @@
{
"namespace": "com.food.order.system.kafka.order.avro.model",
"type": "record",
"name": "PaymentResponseAvroModel",
"fields": [
{
"name": "id",
"type": {
"type": "string",
"logicalType": "uuid"
}
},
{
"name": "sagaId",
"type": {
"type": "string",
"logicalType": "uuid"
}
},
{
"name": "paymentId",
"type": {
"type": "string",
"logicalType": "uuid"
}
},
{
"name": "customerId",
"type": {
"type": "string",
"logicalType": "uuid"
}
},
{
"name": "orderId",
"type": {
"type": "string",
"logicalType": "uuid"
}
},
{
"name": "price",
"type": {
"type": "bytes",
"logicalType": "decimal",
"precision": 10,
"scale": 2
}
},
{
"name": "createdAt",
"type": {
"type": "long",
"logicalType": "timestamp-millis"
}
},
{
"name": "paymentStatus",
"type": {
"type": "enum",
"name": "PaymentStatus",
"symbols": ["COMPLETED", "CANCELLED", "FAILED"]
}
},
{
"name": "failureMessages",
"type": {
"type": "array",
"items":{
"type":"string"
}
}
}
]
}

View File

@@ -0,0 +1,73 @@
{
"namespace": "com.food.order.system.kafka.order.avro.model",
"type": "record",
"name": "RestaurantApprovalRequestAvroModel",
"fields": [
{
"name": "id",
"type": {
"type": "string",
"logicalType": "uuid"
}
},
{
"name": "sagaId",
"type": {
"type": "string",
"logicalType": "uuid"
}
},
{
"name": "restaurantId",
"type": {
"type": "string",
"logicalType": "uuid"
}
},
{
"name": "orderId",
"type": {
"type": "string",
"logicalType": "uuid"
}
},
{
"name": "restaurantOrderStatus",
"type": {
"type": "enum",
"name": "RestaurantOrderStatus",
"symbols": ["PAID"]
}
},
{
"name": "products",
"type": {
"type": "array",
"items":{
"name":"Product",
"type":"record",
"fields":[
{"name":"id", "type": "string", "logicalType": "uuid"},
{"name":"quantity", "type": "int"}
]
}
}
},
{
"name": "price",
"type": {
"type": "bytes",
"logicalType": "decimal",
"precision": 10,
"scale": 2
}
},
{
"name": "createdAt",
"type": {
"type": "long",
"logicalType": "timestamp-millis"
}
}
]
}

View File

@@ -0,0 +1,59 @@
{
"namespace": "com.food.order.system.kafka.order.avro.model",
"type": "record",
"name": "RestaurantApprovalResponseAvroModel",
"fields": [
{
"name": "id",
"type": {
"type": "string",
"logicalType": "uuid"
}
},
{
"name": "sagaId",
"type": {
"type": "string",
"logicalType": "uuid"
}
},
{
"name": "restaurantId",
"type": {
"type": "string",
"logicalType": "uuid"
}
},
{
"name": "orderId",
"type": {
"type": "string",
"logicalType": "uuid"
}
},
{
"name": "createdAt",
"type": {
"type": "long",
"logicalType": "timestamp-millis"
}
},
{
"name": "orderApprovalStatus",
"type": {
"type": "enum",
"name": "OrderApprovalStatus",
"symbols": ["APPROVED", "REJECTED"]
}
},
{
"name": "failureMessages",
"type": {
"type": "array",
"items":{
"type":"string"
}
}
}
]
}

View File

@@ -0,0 +1,52 @@
<?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>kafka</artifactId>
<groupId>com.food.order</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>kafka-producer</artifactId>
<dependencies>
<dependency>
<groupId>com.food.order</groupId>
<artifactId>kafka-model</artifactId>
</dependency>
<dependency>
<groupId>com.food.order</groupId>
<artifactId>kafka-config</artifactId>
</dependency>
<dependency>
<groupId>com.food.order</groupId>
<artifactId>order-core-domain</artifactId>
</dependency>
<dependency>
<groupId>com.food.order</groupId>
<artifactId>common-domain</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<dependency>
<groupId>io.confluent</groupId>
<artifactId>kafka-avro-serializer</artifactId>
</dependency>
<dependency>
<groupId>com.food.order</groupId>
<artifactId>outbox</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,59 @@
package com.food.order.system.kafka.producer;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.food.order.system.domain.exception.OrderDomainException;
import com.food.order.system.outbox.OutboxStatus;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.springframework.kafka.support.SendResult;
import org.springframework.stereotype.Component;
import org.springframework.util.concurrent.ListenableFutureCallback;
import java.util.function.BiConsumer;
@Component
@Slf4j
@RequiredArgsConstructor
public class KafkaMessageHelper {
private final ObjectMapper objectMapper;
public <T, U> ListenableFutureCallback<SendResult<String, T>>
getKafkaCallback(String responseTopicName, T avroModel, U outboxMessage,
BiConsumer<U, OutboxStatus> outboxCallback,
String orderId, String avroModelName) {
return new ListenableFutureCallback<SendResult<String, T>>() {
@Override
public void onFailure(Throwable ex) {
log.error("Error while sending {} with message: {} and outbox type: {} to topic {}",
avroModelName, avroModel.toString(), outboxMessage.getClass().getName(), responseTopicName, ex);
outboxCallback.accept(outboxMessage, OutboxStatus.FAILED);
}
@Override
public void onSuccess(SendResult<String, T> result) {
RecordMetadata metadata = result.getRecordMetadata();
log.info("Received successful response from Kafka for order id: {}" +
" Topic: {} Partition: {} Offset: {} Timestamp: {}",
orderId,
metadata.topic(),
metadata.partition(),
metadata.offset(),
metadata.timestamp());
outboxCallback.accept(outboxMessage, OutboxStatus.COMPLETED);
}
};
}
public <T> T getOrderEventPayload(String payload, Class<T> outputType) {
try {
return objectMapper.readValue(payload, outputType);
} catch (JsonProcessingException e) {
log.error("Could not read {} object!", outputType.getName(), e);
throw new OrderDomainException("Could not read " + outputType.getName() + " object!", e);
}
}
}

View File

@@ -0,0 +1,56 @@
package com.food.order.system.kafka.producer;
import com.food.order.kafka.config.data.KafkaConfigData;
import com.food.order.kafka.config.data.KafkaProducerConfigData;
import lombok.RequiredArgsConstructor;
import org.apache.avro.specific.SpecificRecordBase;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.core.DefaultKafkaProducerFactory;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.kafka.core.ProducerFactory;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
@Configuration
@RequiredArgsConstructor
public class KafkaProducerConfig<K extends Serializable, V extends SpecificRecordBase> {
private final KafkaConfigData kafkaConfigData;
private final KafkaProducerConfigData kafkaProducerConfigData;
@Bean
public Map<String, Object> producerConfig(){
Map<String, Object> props = new HashMap<>();
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaConfigData.getBootstrapServers());
props.put(kafkaConfigData.getSchemaRegistryUrlKey(), kafkaConfigData.getSchemaRegistryUrl());
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, kafkaProducerConfigData.getKeySerializerClass());
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, kafkaProducerConfigData.getValueSerializerClass());
props.put(ProducerConfig.BATCH_SIZE_CONFIG, kafkaProducerConfigData.getBatchSize() *
kafkaProducerConfigData.getBatchSizeBoostFactor());
props.put(ProducerConfig.LINGER_MS_CONFIG, kafkaProducerConfigData.getLingerMs());
props.put(ProducerConfig.COMPRESSION_TYPE_CONFIG, kafkaProducerConfigData.getCompressionType());
props.put(ProducerConfig.ACKS_CONFIG, kafkaProducerConfigData.getAcks());
props.put(ProducerConfig.REQUEST_TIMEOUT_MS_CONFIG, kafkaProducerConfigData.getRequestTimeoutMs());
props.put(ProducerConfig.RETRIES_CONFIG, kafkaProducerConfigData.getRetryCount());
return props;
}
@Bean
public ProducerFactory<K,V> producerFactory(){
return new DefaultKafkaProducerFactory<>(producerConfig());
}
@Bean
public KafkaTemplate<K,V> kafkaTemplate(){
return new KafkaTemplate<>(producerFactory());
}
}

Some files were not shown because too many files have changed in this diff Show More