卡了大半天的联调问题
问题1:别人dubbo总是调不通我的服务
org.apache.dubbo.remoting.RemotingException: client(url: dubbo://192.168.56.1:28085/com.alibaba.cloud.dubbo.service.DubboMetadataService?actives=100&anyhost=true&application=seckill-service&bind.ip=192.168.56.1&bind.port=28085&check=false&codec=dubbo&connect.lazy.initial.state=true&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=cart-service&heartbeat=60000&interface=com.alibaba.cloud.dubbo.service.DubboMetadataService&methods=getAllServiceKeys,getServiceRestMetadata,getExportedURLs,getAllExportedURLs&pid=23444&qos.enable=false®ister.ip=192.168.8.102&release=2.7.12&remote.application=cart-service&revision=2.2.7.RELEASE&router=-default,revisionRouter&sca_revision=4F663C449502A050C7216B07EE4866D5&send.reconnect=true&service.name=ServiceBean:cart-service/com.alibaba.cloud.dubbo.service.DubboMetadataService:1.0.0&side=consumer&sticky=false&timeout=5000×tamp=1690978959234&version=1.0.0) failed to connect to server /192.168.56.1:28085 client-side timeout 3000ms (elapsed: 3002ms) from netty client 192.168.8.102 using dubbo version 2.7.12
at org.apache.dubbo.remoting.transport.netty4.NettyClient.doConnect(NettyClient.java:174)
at org.apache.dubbo.remoting.transport.AbstractClient.connect(AbstractClient.java:198)
at org.apache.dubbo.remoting.transport.AbstractClient.<init>(AbstractClient.java:73)
at org.apache.dubbo.remoting.transport.netty4.NettyClient.<init>(NettyClient.java:82)
然后我cmd,ipconfig,有2个网卡
查看Nacos的配置
问题2:Dubbo调用报找不到该类或者方法
一般从2个方面入手,配置和对方的实体类是否实现了序列化Serializable
配置:
dubbo:
scan:
base-packages: com.fh.shopping
protocol:
name: dubbo
port: 28090
consumer:
check: false
timeout: 5000
provider:
threads: 200
actives: 100
# 特别是这个地方【服务消费方 是否没有订阅 服务提供方】
cloud:
subscribed-services: base-service
问题3:用LocalDateTime做日期,用ShardingSphere做分表分库策略
报错如下:一直说我这个字段拿不到
{"@timestamp":"2023-10-11T10:54:09.825+08:00","level":"ERROR","thread":"http-nio-18080-exec-10","class":"com.marketing.plat.common.web.handler.
GlobalExceptionHandler","function":"handle","line":"41","tid":"1190cc8a63b44851858cc9acf8db3f1a.102.16969928498083813","uid":"1701506916987240449","orderNo":"",
"message":"[ 系统未知错误 ] org.springframework.dao.InvalidDataAccessApiUsageException: Error attempting to get column 'activity_start_time' from result set.
Cause: java.sql.SQLFeatureNotSupportedException: getObject with type\u2028; getObject with type; nested exception is java.sql.SQLFeatureNotSupportedException:
getObject with type\u2028\tat org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:96)\u2028Caused
by: java.sql.SQLFeatureNotSupportedException: getObject with type\u2028\tat org.apache.shardingsphere.shardingjdbc.jdbc.unsupported.
AbstractUnsupportedOperationResultSet.getObject(AbstractUnsupportedOperationResultSet.java:221)\u2028"}
心路历程:测试和本地都行,上到生产就不行呢???
实则不然,就是自己配置忘记了
dubbo:
scan:
base-packages: com.fh.shopping
protocol:
name: dubbo
port: 28090
consumer:
check: false
timeout: 5000
provider:
threads: 200
actives: 100
# 重要的就是这个配置
cloud:
subscribed-services: base-service
附赠Local DATe Time转化的策略
import cn.hutool.core.date.DatePattern;
import com.alibaba.csp.sentinel.util.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedTypes;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@MappedTypes(LocalDateTime.class)
public class CustomLocalDateTimeTypeHandler extends BaseTypeHandler<LocalDateTime> {
private final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN);
@Override
public void setNonNullParameter(PreparedStatement ps, int i, LocalDateTime parameter, JdbcType jdbcType)
throws SQLException {
if (parameter != null) {
ps.setString(i, dateTimeFormatter.format(parameter));
}
}
@Override
public LocalDateTime getNullableResult(ResultSet rs, String columnName) throws SQLException {
String target = rs.getString(columnName);
if (StringUtils.isEmpty(target)) {
return null;
}
return LocalDateTime.parse(target, dateTimeFormatter);
}
@Override
public LocalDateTime getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
String target = rs.getString(columnIndex);
if (StringUtil.isEmpty(target)) {
return null;
}
return LocalDateTime.parse(target, dateTimeFormatter);
}
@Override
public LocalDateTime getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
String target = cs.getString(columnIndex);
if (StringUtil.isEmpty(target)) {
return null;
}
return LocalDateTime.parse(target, dateTimeFormatter);
}
}
字符串拼接sql
update shopping_cart_22 set image_url_org = CONCAT(image_url_org ,‘?x-oss-process=image/resize,h_100,m_lfit’) where user_id = 1693459306401861634;
问题4:HTTP调用外部系统报连接拒绝,马上再请求一次就ok了,隔很长一段时间就会出现
http调用XX报错,org.apache.http.conn.HttpHostConnectException: Connect to 124.232.138.162:9900[/124.232.138.162] failed: Connection refused (Connection refused)
还在找原因!!!
谨以此文记录,愿我能从容!!!
可怜身上衣正单,心忧炭贱愿天寒。