Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YZG
yzg-util
Commits
298e0892
Commit
298e0892
authored
Aug 06, 2021
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复实体关系
parent
34d85fa4
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
84 additions
and
61 deletions
+84
-61
MqInit.java
yzg-util-mq/src/main/java/com/yanzuoguang/mq/MqInit.java
+13
-0
MqStart.java
yzg-util-mq/src/main/java/com/yanzuoguang/mq/MqStart.java
+32
-0
YzgMqConsumer.java
.../src/main/java/com/yanzuoguang/mq/plan/YzgMqConsumer.java
+2
-5
YzgMqProcedure.java
...src/main/java/com/yanzuoguang/mq/plan/YzgMqProcedure.java
+5
-12
MqService.java
...q/src/main/java/com/yanzuoguang/mq/service/MqService.java
+7
-0
QueueService.java
...rc/main/java/com/yanzuoguang/mq/service/QueueService.java
+0
-7
MqServiceImpl.java
...n/java/com/yanzuoguang/mq/service/impl/MqServiceImpl.java
+25
-17
QueueServiceImpl.java
...ava/com/yanzuoguang/mq/service/impl/QueueServiceImpl.java
+0
-20
No files found.
yzg-util-mq/src/main/java/com/yanzuoguang/mq/MqInit.java
0 → 100644
View file @
298e0892
package
com
.
yanzuoguang
.
mq
;
/**
* Mq初始化
* @author 颜佐光
*/
public
interface
MqInit
{
/**
* 初始化颜佐光
*/
void
initMq
();
}
yzg-util-mq/src/main/java/com/yanzuoguang/mq/MqStart.java
0 → 100644
View file @
298e0892
package
com
.
yanzuoguang
.
mq
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
/**
* 最终初始化执行
* @author 颜佐光
*/
@Component
public
class
MqStart
implements
InitializingBean
,
ApplicationContextAware
{
@Autowired
private
List
<
MqInit
>
mqInitList
;
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
}
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
for
(
MqInit
init
:
mqInitList
){
init
.
initMq
();
}
}
}
yzg-util-mq/src/main/java/com/yanzuoguang/mq/plan/YzgMqConsumer.java
View file @
298e0892
...
@@ -27,7 +27,6 @@ public class YzgMqConsumer implements ApplicationContextAware {
...
@@ -27,7 +27,6 @@ public class YzgMqConsumer implements ApplicationContextAware {
private
MqService
mqService
;
private
MqService
mqService
;
private
YzgMqProcedure
yzgMqProcedure
;
private
YzgMqProcedure
yzgMqProcedure
;
private
QueueService
queueService
;
/**
/**
* Set the ApplicationContext that this object runs in.
* Set the ApplicationContext that this object runs in.
...
@@ -45,10 +44,8 @@ public class YzgMqConsumer implements ApplicationContextAware {
...
@@ -45,10 +44,8 @@ public class YzgMqConsumer implements ApplicationContextAware {
*/
*/
@Override
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
mqService
=
applicationContext
.
getBean
(
MqService
.
class
);
yzgMqProcedure
=
applicationContext
.
getBean
(
YzgMqProcedure
.
class
);
yzgMqProcedure
=
applicationContext
.
getBean
(
YzgMqProcedure
.
class
);
queueService
=
applicationContext
.
getBean
(
QueueService
.
class
);
mqService
=
applicationContext
.
getBean
(
MqService
.
class
);
}
}
/**
/**
...
@@ -133,7 +130,7 @@ public class YzgMqConsumer implements ApplicationContextAware {
...
@@ -133,7 +130,7 @@ public class YzgMqConsumer implements ApplicationContextAware {
@RabbitListener
(
queues
=
{
YzgMqProcedure
.
YZG_CLEAR_LOG
})
@RabbitListener
(
queues
=
{
YzgMqProcedure
.
YZG_CLEAR_LOG
})
public
void
yzgClearLog
(
String
day
,
Message
message
,
Channel
channel
)
{
public
void
yzgClearLog
(
String
day
,
Message
message
,
Channel
channel
)
{
try
{
try
{
queue
Service
.
clearLog
(
day
);
mq
Service
.
clearLog
(
day
);
}
catch
(
CodeException
ex
)
{
}
catch
(
CodeException
ex
)
{
Log
.
error
(
YzgMqConsumer
.
class
,
ex
);
Log
.
error
(
YzgMqConsumer
.
class
,
ex
);
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
...
...
yzg-util-mq/src/main/java/com/yanzuoguang/mq/plan/YzgMqProcedure.java
View file @
298e0892
package
com
.
yanzuoguang
.
mq
.
plan
;
package
com
.
yanzuoguang
.
mq
.
plan
;
import
com.yanzuoguang.mq.MqConfig
;
import
com.yanzuoguang.mq.MqConfig
;
import
com.yanzuoguang.mq.MqInit
;
import
com.yanzuoguang.mq.service.MqService
;
import
com.yanzuoguang.mq.service.MqService
;
import
com.yanzuoguang.mq.vo.MessagePlan
;
import
com.yanzuoguang.mq.vo.MessagePlan
;
import
com.yanzuoguang.mq.vo.MessageVo
;
import
com.yanzuoguang.mq.vo.MessageVo
;
...
@@ -14,6 +15,7 @@ import org.springframework.beans.BeansException;
...
@@ -14,6 +15,7 @@ import org.springframework.beans.BeansException;
import
org.springframework.beans.factory.BeanInitializationException
;
import
org.springframework.beans.factory.BeanInitializationException
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.context.*
;
import
org.springframework.context.*
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -26,7 +28,8 @@ import java.util.List;
...
@@ -26,7 +28,8 @@ import java.util.List;
* @author 颜佐光
* @author 颜佐光
*/
*/
@Component
@Component
public
class
YzgMqProcedure
implements
InitializingBean
,
ApplicationContextAware
{
@Order
(
2
)
public
class
YzgMqProcedure
implements
ApplicationContextAware
,
MqInit
{
/**
/**
* 执行的消息队列
* 执行的消息队列
*/
*/
...
@@ -72,18 +75,8 @@ public class YzgMqProcedure implements InitializingBean, ApplicationContextAware
...
@@ -72,18 +75,8 @@ public class YzgMqProcedure implements InitializingBean, ApplicationContextAware
mqConfig
=
applicationContext
.
getBean
(
MqConfig
.
class
);
mqConfig
=
applicationContext
.
getBean
(
MqConfig
.
class
);
}
}
/**
* Invoked by a BeanFactory after it has set all bean properties supplied
* (and satisfied BeanFactoryAware and ApplicationContextAware).
* <p>This method allows the bean instance to perform initialization only
* possible when all bean properties have been set and to throw an
* exception in the event of misconfiguration.
*
* @throws Exception in the event of misconfiguration (such
* as failure to set an essential property) or if initialization fails.
*/
@Override
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
public
void
initMq
()
{
mqService
.
createQueue
(
new
QueueVo
(
YZG_CLEAR_LOG
));
mqService
.
createQueue
(
new
QueueVo
(
YZG_CLEAR_LOG
));
mqService
.
createQueue
(
new
QueueVo
(
YZG_MQ_SYSTEM_QUEUE
));
mqService
.
createQueue
(
new
QueueVo
(
YZG_MQ_SYSTEM_QUEUE
));
mqService
.
createQueue
(
new
QueueVo
(
YZG_MQ_SYSTEM_QUEUE_PLAN
));
mqService
.
createQueue
(
new
QueueVo
(
YZG_MQ_SYSTEM_QUEUE_PLAN
));
...
...
yzg-util-mq/src/main/java/com/yanzuoguang/mq/service/MqService.java
View file @
298e0892
...
@@ -60,6 +60,13 @@ public interface MqService {
...
@@ -60,6 +60,13 @@ public interface MqService {
@ApiOperation
(
value
=
"删除一个消息"
)
@ApiOperation
(
value
=
"删除一个消息"
)
String
logRemove
(
MessageLogRemoveReqVo
req
);
String
logRemove
(
MessageLogRemoveReqVo
req
);
/**
* 删除日期
*
* @param day
*/
void
clearLog
(
String
day
);
/**
/**
* 发送消息
* 发送消息
*
*
...
...
yzg-util-mq/src/main/java/com/yanzuoguang/mq/service/QueueService.java
View file @
298e0892
...
@@ -15,11 +15,4 @@ public interface QueueService {
...
@@ -15,11 +15,4 @@ public interface QueueService {
* @param req 保存队列服务
* @param req 保存队列服务
*/
*/
void
create
(
QueueVo
req
);
void
create
(
QueueVo
req
);
/**
* 删除日期
*
* @param day
*/
void
clearLog
(
String
day
);
}
}
yzg-util-mq/src/main/java/com/yanzuoguang/mq/service/impl/MqServiceImpl.java
View file @
298e0892
...
@@ -2,6 +2,7 @@ package com.yanzuoguang.mq.service.impl;
...
@@ -2,6 +2,7 @@ package com.yanzuoguang.mq.service.impl;
import
com.alibaba.fastjson.TypeReference
;
import
com.alibaba.fastjson.TypeReference
;
import
com.rabbitmq.client.Channel
;
import
com.rabbitmq.client.Channel
;
import
com.yanzuoguang.mq.MqInit
;
import
com.yanzuoguang.mq.base.MqConsumeDynamic
;
import
com.yanzuoguang.mq.base.MqConsumeDynamic
;
import
com.yanzuoguang.mq.dao.MessageLogDao
;
import
com.yanzuoguang.mq.dao.MessageLogDao
;
import
com.yanzuoguang.mq.dao.QueueServerDao
;
import
com.yanzuoguang.mq.dao.QueueServerDao
;
...
@@ -26,7 +27,9 @@ import org.springframework.beans.BeansException;
...
@@ -26,7 +27,9 @@ import org.springframework.beans.BeansException;
import
org.springframework.beans.factory.BeanInitializationException
;
import
org.springframework.beans.factory.BeanInitializationException
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.context.*
;
import
org.springframework.context.*
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -38,7 +41,8 @@ import java.util.List;
...
@@ -38,7 +41,8 @@ import java.util.List;
* @author 颜佐光
* @author 颜佐光
*/
*/
@Component
@Component
public
class
MqServiceImpl
implements
MqService
,
InitializingBean
,
ApplicationContextAware
{
@Order
(
1
)
public
class
MqServiceImpl
implements
MqService
,
ApplicationContextAware
,
MqInit
{
private
QueueService
queueService
;
private
QueueService
queueService
;
private
MessageService
messageService
;
private
MessageService
messageService
;
...
@@ -70,29 +74,19 @@ public class MqServiceImpl implements MqService, InitializingBean, ApplicationCo
...
@@ -70,29 +74,19 @@ public class MqServiceImpl implements MqService, InitializingBean, ApplicationCo
*/
*/
@Override
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
queueService
=
applicationContext
.
getBean
(
QueueService
.
class
);
messageLogDao
=
applicationContext
.
getBean
(
MessageLogDao
.
class
);
messageService
=
applicationContext
.
getBean
(
MessageService
.
class
);
mqConsumeDynamic
=
applicationContext
.
getBean
(
MqConsumeDynamic
.
class
);
queueServerDao
=
applicationContext
.
getBean
(
QueueServerDao
.
class
);
queueServerDao
=
applicationContext
.
getBean
(
QueueServerDao
.
class
);
queueServerTokenDao
=
applicationContext
.
getBean
(
QueueServerTokenDao
.
class
);
queueServerTokenDao
=
applicationContext
.
getBean
(
QueueServerTokenDao
.
class
);
messageLogDao
=
applicationContext
.
getBean
(
MessageLogDao
.
class
);
messageService
=
applicationContext
.
getBean
(
MessageService
.
class
);
mqConsumeDynamic
=
applicationContext
.
getBean
(
MqConsumeDynamic
.
class
);
queueService
=
applicationContext
.
getBean
(
QueueService
.
class
);
yzgMqProcedure
=
applicationContext
.
getBean
(
YzgMqProcedure
.
class
);
yzgMqProcedure
=
applicationContext
.
getBean
(
YzgMqProcedure
.
class
);
this
.
localName
=
UrlHelper
.
getIp
();
this
.
localName
=
UrlHelper
.
getIp
();
}
}
/**
public
void
initMq
()
{
* Invoked by a BeanFactory after it has set all bean properties supplied
* (and satisfied BeanFactoryAware and ApplicationContextAware).
* <p>This method allows the bean instance to perform initialization only
* possible when all bean properties have been set and to throw an
* exception in the event of misconfiguration.
*
* @throws Exception in the event of misconfiguration (such
* as failure to set an essential property) or if initialization fails.
*/
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
QueueVo
removeToken
=
new
QueueVo
(
YzgMqProcedure
.
YZG_MQ_CLEAR_TOKEN_QUEUE
);
QueueVo
removeToken
=
new
QueueVo
(
YzgMqProcedure
.
YZG_MQ_CLEAR_TOKEN_QUEUE
);
removeToken
.
check
();
removeToken
.
check
();
queueService
.
create
(
removeToken
);
queueService
.
create
(
removeToken
);
...
@@ -160,6 +154,20 @@ public class MqServiceImpl implements MqService, InitializingBean, ApplicationCo
...
@@ -160,6 +154,20 @@ public class MqServiceImpl implements MqService, InitializingBean, ApplicationCo
return
load
.
getId
();
return
load
.
getId
();
}
}
/**
* 删除日期
*
* @param day
*/
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
clearLog
(
String
day
)
{
// 添加去重方法,只执行1次
this
.
log
(
new
MessageLogReqVo
(
YzgMqProcedure
.
YZG_CLEAR_LOG
,
day
));
messageLogDao
.
removeLastTime
();
yzgMqProcedure
.
clearLog
();
}
/**
/**
* 删除一个消息
* 删除一个消息
*
*
...
...
yzg-util-mq/src/main/java/com/yanzuoguang/mq/service/impl/QueueServiceImpl.java
View file @
298e0892
...
@@ -24,9 +24,6 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -24,9 +24,6 @@ import org.springframework.transaction.annotation.Transactional;
public
class
QueueServiceImpl
implements
QueueService
,
ApplicationContextAware
{
public
class
QueueServiceImpl
implements
QueueService
,
ApplicationContextAware
{
private
BeanDao
beanDao
;
private
BeanDao
beanDao
;
private
MessageLogDao
messageLogDao
;
private
MqService
mqService
;
private
YzgMqProcedure
mqProcedure
;
/**
/**
* Set the ApplicationContext that this object runs in.
* Set the ApplicationContext that this object runs in.
...
@@ -45,9 +42,6 @@ public class QueueServiceImpl implements QueueService, ApplicationContextAware {
...
@@ -45,9 +42,6 @@ public class QueueServiceImpl implements QueueService, ApplicationContextAware {
@Override
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
beanDao
=
applicationContext
.
getBean
(
BeanDao
.
class
);
beanDao
=
applicationContext
.
getBean
(
BeanDao
.
class
);
messageLogDao
=
applicationContext
.
getBean
(
MessageLogDao
.
class
);
mqService
=
applicationContext
.
getBean
(
MqService
.
class
);
mqProcedure
=
applicationContext
.
getBean
(
YzgMqProcedure
.
class
);
}
}
/**
/**
...
@@ -61,20 +55,6 @@ public class QueueServiceImpl implements QueueService, ApplicationContextAware {
...
@@ -61,20 +55,6 @@ public class QueueServiceImpl implements QueueService, ApplicationContextAware {
initBean
(
req
);
initBean
(
req
);
}
}
/**
* 删除日期
*
* @param day
*/
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
clearLog
(
String
day
)
{
// 添加去重方法,只执行1次
mqService
.
log
(
new
MessageLogReqVo
(
YzgMqProcedure
.
YZG_CLEAR_LOG
,
day
));
messageLogDao
.
removeLastTime
();
mqProcedure
.
clearLog
();
}
/**
/**
* 初始化实体
* 初始化实体
*
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment