RabbitMQ应用场景:订单自动过期取消

场景描述

场景描述:当用户下单后,状态为待支付,假如在规定的过期时间内尚未支付金额,那么就应该设置订单状态为取消。在不用MQ的情况下,我们可以设置一个定时器,每秒轮询数据库查找超出过期时间且未支付的订单,然后修改状态,但是这种方式会占用很多资源,所以在这里我们可以利用RabbitMQ的死信队列。

Spring Cloud替换Feign默认Client

使用HTTP Client替换Feign默认Client

依赖配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<!-- Spring Cloud OpenFeign的Starter的依赖 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!-- 使用Apache HttpClient替换Feign原生httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>com.netflix.feign</groupId>
<artifactId>feign-httpclient</artifactId>
<version>8.17.0</version>
</dependency>

RestTemplate中使用ParameterizedTypeReference参数化类型支持泛型

使用普通的RestTemplate.postForObject是无法知道泛型的具体类型的,需要借助ParameterizedTypeReference参数化类型

1
2
3
4
5
6
7
8
9
10
11
12
13
14
public <T> T post(String url, @NotNull HttpEntity requestEntity, ParameterizedTypeReference<T> parameterizedTypeReference) {
ResponseEntity<T> responseEntity = restTemplate.exchange(
url,
HttpMethod.POST,
requestEntity,
parameterizedTypeReference
);
return responseEntity.getBody();
}

ParameterizedTypeReference<TestModelType<List<TestModelBody>>> parameterizedTypeReference =
new ParameterizedTypeReference<TestModelType<List<TestModelBody>>>() {};
TestModelType<List<TestModelBody>> listTestModelType =
restTemplateUtils.get(testUrl, parameterizedTypeReference);

CentOS下编译PHP 7.4报错Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met

错误分析

错误日志:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
checking for zip archive read/write support... yes
checking for libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0... no
configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met:

No package 'libzip' found
No package 'libzip' found
No package 'libzip' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables LIBZIP_CFLAGS
and LIBZIP_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :