Commit 9237735b authored by yanzg's avatar yanzg

身份证识别

parent 618c2aaa
...@@ -16,10 +16,11 @@ import java.util.concurrent.ConcurrentLinkedQueue; ...@@ -16,10 +16,11 @@ import java.util.concurrent.ConcurrentLinkedQueue;
* @author 颜佐光 * @author 颜佐光
*/ */
@Component @Component
public class QueueServiceImpl implements QueueService, Runnable { public class QueueServiceImpl implements QueueService {
private final BeanDao beanDao; private final BeanDao beanDao;
private final Queue<QueueVo> queue = new ConcurrentLinkedQueue<>(); private final Queue<QueueVo> queue = new ConcurrentLinkedQueue<>();
private boolean isAsyncRun = false; private boolean isAsyncRun = false;
public static boolean DEFAULT_IS_ASYNC = false;
public QueueServiceImpl(BeanDao beanDao) { public QueueServiceImpl(BeanDao beanDao) {
this.beanDao = beanDao; this.beanDao = beanDao;
...@@ -33,7 +34,7 @@ public class QueueServiceImpl implements QueueService, Runnable { ...@@ -33,7 +34,7 @@ public class QueueServiceImpl implements QueueService, Runnable {
*/ */
@Override @Override
public void create(QueueVo req) { public void create(QueueVo req) {
initBean(req, true); initBean(req, DEFAULT_IS_ASYNC);
} }
@Override @Override
...@@ -57,7 +58,9 @@ public class QueueServiceImpl implements QueueService, Runnable { ...@@ -57,7 +58,9 @@ public class QueueServiceImpl implements QueueService, Runnable {
} }
synchronized (this) { synchronized (this) {
isAsyncRun = true; isAsyncRun = true;
new Thread(this).start(); Thread thread = new Thread(this::handleQueue);
thread.setDaemon(true);
thread.start();
} }
} }
} }
...@@ -85,8 +88,7 @@ public class QueueServiceImpl implements QueueService, Runnable { ...@@ -85,8 +88,7 @@ public class QueueServiceImpl implements QueueService, Runnable {
beanDao.createBinding(vo.getExchangeName(), vo.getQueueName(), vo.getRouteKey()); beanDao.createBinding(vo.getExchangeName(), vo.getQueueName(), vo.getRouteKey());
} }
@Override private void handleQueue() {
public void run() {
while (!this.queue.isEmpty()) { while (!this.queue.isEmpty()) {
QueueVo vo = this.queue.poll(); QueueVo vo = this.queue.poll();
try { try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment