0%

CountDownLatch 是 Java 并发工具类(位于 java.util.concurrent 包),核心作用是 让一个或多个线程等待其他线程完成一系列操作后,再继续执行。它基于「计数器」实现,本质是一种「同步屏障」。

阅读全文 »

将短信发送的异步回调接口改为同步接口,核心思路是:发起短信请求后,在后端服务内阻塞等待回调通知,直到超时或收到明确结果。以下是具体实现方案、代码示例和注意事项。

阅读全文 »

现象

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
025-11-07 13:58:40.051 ERROR [celina-data-center,,] 34880 --- [isson-netty-1-6] o.redisson.client.handler.CommandsQueue  : Exception occured. Channel: [id: 0xdd6f0878, L:/192.168.10.182:60652 - R:dmz-zjj.lanniuh.com/172.16.16.33:7073]

java.io.IOException: 远程主机强迫关闭了一个现有的连接。
at sun.nio.ch.SocketDispatcher.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
at sun.nio.ch.IOUtil.read(IOUtil.java:192)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:379)
at io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:258)
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1132)
at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:350)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:151)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:750)
阅读全文 »

背景

    windows服务器中,通过窗口启动jar包,每个窗口对应一个临时会话。当关闭CMD窗口时,启动的Java程序会立即终止,无法实现长期运行。

    将 JAR 包注册为 Windows 服务,可随系统启动自动运行,支持服务管理(启动 / 停止 / 重启)。

阅读全文 »

环境要求

在Linux环境中安装MariaDB 11.8.3版本,因为此版本较新,CentOS7系统版本过低,无法支持,因此采用Rocky Linux 9系统。

阅读全文 »