小编Syn*_*ync的帖子

如何在微服务中跨服务执行验证

假设有两个微服务:订单和库存.还有就是为了服务,它的API ProductId,Qty等,并下订单.

理想情况下,如果库存服务中存在库存,则只允许下订单.人们建议使用Saga模式或任何其他分布式交易.这很好,最终将利用一致性.

但是如果有人想滥用这个系统怎么办呢.他可以推销ProductId无效或库存不足的产品订单.系统将接受所有这些订单并将这些订单放入队列,库存服务将处理这些无效订单.

不应该事先处理(在订购服务中)而不是将这些无效订单推送到下一级别(特别是在productId无效的情况下)

处理这些方案有哪些建议?

domain-driven-design microservices

10
推荐指数
1
解决办法
2157
查看次数

如何只替换一些匹配的子串?

这是一个我无法找到答案的正则表达式问题:

输入:

"the current time is <start time>00:00:00<end time>. at 00:00:00 there is a firework. Another appearance of 00:00:00."
Run Code Online (Sandbox Code Playgroud)

期望的输出:

"the current time is <start time>00:00:00<end time>. at <start time>00:00:00<end time> there is a firework. Another appearance of <start time>00:00:00<end time>."
Run Code Online (Sandbox Code Playgroud)

解决方案不得涉及首先按句子拆分字符串.

我尝试了什么:

简单input.replace(group, replace)不起作用,因为已经有一个不应该被替换的匹配.

    public static void main(String[] args) throws ParseException
    {
       String input = "the current time is <start time>00:00:00<end time>. at 00:00:00 there is a firework. Another appearance of 00:00:00.";
       Pattern p  = Pattern.compile("(<start time>)?(00:00:00)(<end …
Run Code Online (Sandbox Code Playgroud)

java regex

2
推荐指数
1
解决办法
64
查看次数

标签 统计

domain-driven-design ×1

java ×1

microservices ×1

regex ×1