-
Notifications
You must be signed in to change notification settings - Fork 417
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Apply saga framework for yas * Add tag custom version for postgres debezium
- Loading branch information
1 parent
e828c32
commit a8f1035
Showing
74 changed files
with
2,289 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
cart/src/main/java/com/yas/cart/saga/HandlerDispatcherRegister.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.yas.cart.saga; | ||
|
||
import com.yas.cart.saga.handler.CartItemCommandHandler; | ||
import io.eventuate.tram.commands.consumer.CommandDispatcher; | ||
import io.eventuate.tram.sagas.participant.SagaCommandDispatcherFactory; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class HandlerDispatcherRegister { | ||
@Bean | ||
public CommandDispatcher consumerCommandDispatcher(CartItemCommandHandler target, | ||
SagaCommandDispatcherFactory sagaCommandDispatcherFactory) { | ||
|
||
return sagaCommandDispatcherFactory.make("cartItemCommandDispatcher", target.commandHandlerDefinitions()); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
cart/src/main/java/com/yas/cart/saga/handler/CartItemCommandHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.yas.cart.saga.handler; | ||
|
||
import com.yas.cart.exception.BadRequestException; | ||
import com.yas.cart.exception.NotFoundException; | ||
import com.yas.cart.service.CartService; | ||
import com.yas.saga.cart.command.DeleteCartItemCommand; | ||
import com.yas.saga.cart.reply.DeleteCartItemFailure; | ||
import com.yas.saga.cart.reply.DeleteCartItemSuccess; | ||
import io.eventuate.tram.commands.consumer.CommandHandlers; | ||
import io.eventuate.tram.commands.consumer.CommandMessage; | ||
import io.eventuate.tram.messaging.common.Message; | ||
import io.eventuate.tram.sagas.participant.SagaCommandHandlersBuilder; | ||
import lombok.RequiredArgsConstructor; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.springframework.stereotype.Component; | ||
|
||
import static io.eventuate.tram.commands.consumer.CommandHandlerReplyBuilder.withFailure; | ||
import static io.eventuate.tram.commands.consumer.CommandHandlerReplyBuilder.withSuccess; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class CartItemCommandHandler { | ||
|
||
private final CartService cartService; | ||
|
||
public CommandHandlers commandHandlerDefinitions() { | ||
return SagaCommandHandlersBuilder | ||
.fromChannel("cartService") | ||
.onMessage(DeleteCartItemCommand.class, this::deleteCartItem) | ||
.build(); | ||
} | ||
|
||
private Message deleteCartItem(CommandMessage<DeleteCartItemCommand> cm) { | ||
DeleteCartItemCommand cmd = cm.getCommand(); | ||
try { | ||
this.cartService.removeCartItemListByProductIdList(cmd.getProductIds(), cmd.getCustomerId()); | ||
String productIdsStr = StringUtils.join(cmd.getProductIds(), ","); | ||
return withSuccess(new DeleteCartItemSuccess("Delete all card items of product ids [" + productIdsStr + "] success")); | ||
} catch (BadRequestException | NotFoundException e) { | ||
return withFailure(new DeleteCartItemFailure(e.getMessage())); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM debezium/postgres:15-alpine | ||
ENV WAL2JSON_TAG=wal2json_2_5 | ||
RUN apk add --no-cache --virtual .debezium-build-deps gcc clang15 llvm15 git make musl-dev pkgconf \ | ||
&& git clone https://github.com/eulerto/wal2json -b master --single-branch \ | ||
&& (cd /wal2json && git checkout tags/$WAL2JSON_TAG -b $WAL2JSON_TAG && make && make install) \ | ||
&& rm -rf wal2json \ | ||
&& apk del .debezium-build-deps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# LOGGING | ||
# log_min_error_statement = fatal | ||
# log_min_messages = DEBUG1 | ||
|
||
# CONNECTION | ||
listen_addresses = '*' | ||
|
||
# MODULES | ||
shared_preload_libraries = 'decoderbufs,wal2json' | ||
|
||
# REPLICATION | ||
wal_level = logical # minimal, archive, hot_standby, or logical (change requires restart) | ||
max_wal_senders = 20 # max number of walsender processes (change requires restart) | ||
#wal_keep_segments = 4 # in logfile segments, 16MB each; 0 disables | ||
#wal_sender_timeout = 60s # in milliseconds; 0 disables | ||
max_replication_slots = 20 # max number of replication slots (change requires restart) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
Oops, something went wrong.