记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
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
董敬伟
liquidnet-bus-v1
Commits
c153d97f
Commit
c153d97f
authored
Jul 20, 2022
by
张国柄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
~opt;
parent
3b6c7030
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
353 additions
and
353 deletions
+353
-353
ConsumerCommonBizRedisStreamConfig.java
...nsumer/nft/config/ConsumerCommonBizRedisStreamConfig.java
+12
-12
AbstractBizRedisReceiver.java
...rvice/consumer/nft/receiver/AbstractBizRedisReceiver.java
+48
-48
AbstractMdbRedisReceiver.java
...rvice/consumer/nft/receiver/AbstractMdbRedisReceiver.java
+105
-105
AbstractSqlRedisReceiver.java
...rvice/consumer/nft/receiver/AbstractSqlRedisReceiver.java
+72
-72
ConsumerGalaxyJsonNftPublishAndBuyReceiver.java
.../receiver/ConsumerGalaxyJsonNftPublishAndBuyReceiver.java
+58
-58
ConsumerGalaxyJsonNftUserRegisterReceiver.java
...t/receiver/ConsumerGalaxyJsonNftUserRegisterReceiver.java
+58
-58
No files found.
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-nft/src/main/java/com/liquidnet/service/consumer/nft/config/ConsumerCommonBizRedisStreamConfig.java
View file @
c153d97f
package
com
.
liquidnet
.
service
.
consumer
.
nft
.
config
;
import
com.liquidnet.common.cache.redis.config.RedisStreamConfig
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
@Configuration
public
class
ConsumerCommonBizRedisStreamConfig
extends
RedisStreamConfig
{
@Autowired
StringRedisTemplate
stringRedisTemplate
;
}
//
package com.liquidnet.service.consumer.nft.config;
//
//
import com.liquidnet.common.cache.redis.config.RedisStreamConfig;
//
import org.springframework.beans.factory.annotation.Autowired;
//
import org.springframework.context.annotation.Configuration;
//
import org.springframework.data.redis.core.StringRedisTemplate;
//
//
@Configuration
//
public class ConsumerCommonBizRedisStreamConfig extends RedisStreamConfig {
//
@Autowired
//
StringRedisTemplate stringRedisTemplate;
//
}
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-nft/src/main/java/com/liquidnet/service/consumer/nft/receiver/AbstractBizRedisReceiver.java
View file @
c153d97f
package
com
.
liquidnet
.
service
.
consumer
.
nft
.
receiver
;
import
com.liquidnet.service.base.constant.MQConst
;
import
com.liquidnet.service.consumer.nft.service.IBaseDao
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.connection.stream.MapRecord
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.data.redis.stream.StreamListener
;
/**
* 公共的业务队列消息监听器,具体业务消费逻辑通过`consumerMessageHandler`实现
*
* @author zhanggb
* Created by IntelliJ IDEA at 2022/3/31
*/
@Slf4j
public
abstract
class
AbstractBizRedisReceiver
implements
StreamListener
<
String
,
MapRecord
<
String
,
String
,
String
>>
{
@Autowired
public
IBaseDao
baseDao
;
@Autowired
public
StringRedisTemplate
stringRedisTemplate
;
@Override
public
void
onMessage
(
MapRecord
<
String
,
String
,
String
>
message
)
{
String
redisStreamKey
=
this
.
getRedisStreamKey
();
log
.
debug
(
"CONSUMER MSG[streamKey:{},messageId:{},stream:{},body:{}]"
,
redisStreamKey
,
message
.
getId
(),
message
.
getStream
(),
message
.
getValue
());
boolean
result
=
this
.
consumerMessageHandler
(
message
.
getValue
().
get
(
MQConst
.
QUEUE_MESSAGE_KEY
));
log
.
info
(
"CONSUMER MSG RESULT:{} ==> [{}]MESSAGE_ID:{}"
,
result
,
redisStreamKey
,
message
.
getId
());
try
{
stringRedisTemplate
.
opsForStream
().
acknowledge
(
getRedisStreamGroup
(),
message
);
}
catch
(
Exception
e
)
{
log
.
error
(
"#CONSUMER MSG EX_ACK ==> [{}]RESULT:{},MESSAGE:{}"
,
redisStreamKey
,
result
,
message
.
getValue
(),
e
);
}
try
{
stringRedisTemplate
.
opsForStream
().
delete
(
redisStreamKey
,
message
.
getId
());
}
catch
(
Exception
e
)
{
log
.
error
(
"#CONSUMER MSG EX_DEL ==> [{}]RESULT:{},MESSAGE:{}"
,
redisStreamKey
,
result
,
message
.
getValue
(),
e
);
}
}
protected
abstract
boolean
consumerMessageHandler
(
String
msg
);
protected
abstract
String
getRedisStreamKey
();
protected
abstract
String
getRedisStreamGroup
();
}
\ No newline at end of file
//package com.liquidnet.service.consumer.nft.receiver;
//
//import com.liquidnet.service.base.constant.MQConst;
//import com.liquidnet.service.consumer.nft.service.IBaseDao;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.redis.connection.stream.MapRecord;
//import org.springframework.data.redis.core.StringRedisTemplate;
//import org.springframework.data.redis.stream.StreamListener;
//
///**
// * 公共的业务队列消息监听器,具体业务消费逻辑通过`consumerMessageHandler`实现
// *
// * @author zhanggb
// * Created by IntelliJ IDEA at 2022/3/31
// */
//@Slf4j
//public abstract class AbstractBizRedisReceiver implements StreamListener<String, MapRecord<String, String, String>> {
// @Autowired
// public IBaseDao baseDao;
// @Autowired
// public StringRedisTemplate stringRedisTemplate;
//
// @Override
// public void onMessage(MapRecord<String, String, String> message) {
// String redisStreamKey = this.getRedisStreamKey();
// log.debug("CONSUMER MSG[streamKey:{},messageId:{},stream:{},body:{}]", redisStreamKey, message.getId(), message.getStream(), message.getValue());
// boolean result = this.consumerMessageHandler(message.getValue().get(MQConst.QUEUE_MESSAGE_KEY));
// log.info("CONSUMER MSG RESULT:{} ==> [{}]MESSAGE_ID:{}", result, redisStreamKey, message.getId());
//
// try {
// stringRedisTemplate.opsForStream().acknowledge(getRedisStreamGroup(), message);
// } catch (Exception e) {
// log.error("#CONSUMER MSG EX_ACK ==> [{}]RESULT:{},MESSAGE:{}", redisStreamKey, result, message.getValue(), e);
// }
// try {
// stringRedisTemplate.opsForStream().delete(redisStreamKey, message.getId());
// } catch (Exception e) {
// log.error("#CONSUMER MSG EX_DEL ==> [{}]RESULT:{},MESSAGE:{}", redisStreamKey, result, message.getValue(), e);
// }
// }
//
// protected abstract boolean consumerMessageHandler(String msg);
//
// protected abstract String getRedisStreamKey();
//
// protected abstract String getRedisStreamGroup();
//}
\ No newline at end of file
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-nft/src/main/java/com/liquidnet/service/consumer/nft/receiver/AbstractMdbRedisReceiver.java
View file @
c153d97f
package
com
.
liquidnet
.
service
.
consumer
.
nft
.
receiver
;
import
com.liquidnet.common.cache.redis.util.RedisUtil
;
import
com.liquidnet.commons.lang.util.CollectionUtil
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.service.base.constant.MQConst
;
import
com.liquidnet.service.goblin.dto.GoblinQueueBizMongoDto
;
import
com.mongodb.BasicDBObject
;
import
com.mongodb.client.result.UpdateResult
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.redis.connection.stream.MapRecord
;
import
org.springframework.data.redis.connection.stream.StreamRecords
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.data.redis.stream.StreamListener
;
import
java.util.HashMap
;
/**
* 公共的业务Mongo数据处理队列消息监听器,具体业务消费逻辑通过`consumerMessageHandler`实现
*
* @author zhanggb
* Created by IntelliJ IDEA at 2022/4/22
*/
@Slf4j
public
abstract
class
AbstractMdbRedisReceiver
implements
StreamListener
<
String
,
MapRecord
<
String
,
String
,
String
>>
{
@Autowired
public
StringRedisTemplate
stringRedisTemplate
;
@Autowired
private
MongoTemplate
mongoTemplate
;
@Autowired
private
RedisUtil
redisUtil
;
private
static
final
BasicDBObject
BASIC_DB_OBJECT
=
new
BasicDBObject
();
@Override
public
void
onMessage
(
MapRecord
<
String
,
String
,
String
>
message
)
{
String
redisStreamKey
=
this
.
getRedisStreamKey
();
log
.
debug
(
"CONSUMER MSG[streamKey:{},messageId:{},stream:{},body:{}]"
,
redisStreamKey
,
message
.
getId
(),
message
.
getStream
(),
message
.
getValue
());
boolean
result
=
this
.
consumerMessageHandler
(
message
.
getValue
().
get
(
MQConst
.
QUEUE_MESSAGE_KEY
));
log
.
info
(
"CONSUMER MSG RESULT:{} ==> [{}]MESSAGE_ID:{}"
,
result
,
redisStreamKey
,
message
.
getId
());
try
{
stringRedisTemplate
.
opsForStream
().
acknowledge
(
getRedisStreamGroup
(),
message
);
}
catch
(
Exception
e
)
{
log
.
error
(
"#CONSUMER MSG EX_ACK ==> [{}]RESULT:{},MESSAGE:{}"
,
redisStreamKey
,
result
,
message
.
getValue
(),
e
);
}
try
{
stringRedisTemplate
.
opsForStream
().
delete
(
redisStreamKey
,
message
.
getId
());
}
catch
(
Exception
e
)
{
log
.
error
(
"#CONSUMER MSG EX_DEL ==> [{}]RESULT:{},MESSAGE:{}"
,
redisStreamKey
,
result
,
message
.
getValue
(),
e
);
}
}
private
boolean
consumerMessageHandler
(
String
msg
)
{
boolean
aBoolean
=
true
;
try
{
GoblinQueueBizMongoDto
queueBizMongoDto
=
JsonUtils
.
fromJson
(
msg
,
GoblinQueueBizMongoDto
.
class
);
if
(
null
!=
queueBizMongoDto
)
{
String
collectName
=
queueBizMongoDto
.
getCollect
(),
columnName
=
queueBizMongoDto
.
getColumn
();
String
prefix
=
queueBizMongoDto
.
getPrefix
(),
bizId
=
queueBizMongoDto
.
getBizId
();
Object
o
;
switch
(
queueBizMongoDto
.
getOpType
())
{
case
1
:
// insert
o
=
redisUtil
.
get
(
prefix
.
concat
(
bizId
));
if
(
null
!=
o
)
{
mongoTemplate
.
insert
(
o
,
collectName
);
}
break
;
case
2
:
// update
o
=
redisUtil
.
get
(
prefix
.
concat
(
bizId
));
if
(
null
!=
o
)
{
BasicDBObject
basicDBObject
=
(
BasicDBObject
)
AbstractMdbRedisReceiver
.
BASIC_DB_OBJECT
.
clone
();
UpdateResult
updateResult
=
mongoTemplate
.
getCollection
(
collectName
).
updateOne
(
Query
.
query
(
Criteria
.
where
(
columnName
).
is
(
bizId
)).
getQueryObject
(),
basicDBObject
.
append
(
"$set"
,
mongoTemplate
.
getConverter
().
convertToMongoType
(
o
))
);
}
break
;
default
:
log
.
error
(
"CONSUMER MSG ERR_HANDLE[未知的操作类型,{}]"
,
msg
);
break
;
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"CONSUMER MSG EX_HANDLE ==> [{}]:{}"
,
this
.
getRedisStreamKey
(),
msg
,
e
);
aBoolean
=
false
;
}
finally
{
if
(!
aBoolean
)
{
HashMap
<
String
,
String
>
map
=
CollectionUtil
.
mapStringString
();
map
.
put
(
MQConst
.
QUEUE_MESSAGE_KEY
,
msg
);
stringRedisTemplate
.
opsForStream
().
add
(
StreamRecords
.
mapBacked
(
map
).
withStreamKey
(
this
.
getRedisStreamKey
()));
}
}
return
aBoolean
;
}
protected
abstract
String
getRedisStreamKey
();
protected
abstract
String
getRedisStreamGroup
();
}
\ No newline at end of file
//package com.liquidnet.service.consumer.nft.receiver;
//
//import com.liquidnet.common.cache.redis.util.RedisUtil;
//import com.liquidnet.commons.lang.util.CollectionUtil;
//import com.liquidnet.commons.lang.util.JsonUtils;
//import com.liquidnet.service.base.constant.MQConst;
//import com.liquidnet.service.goblin.dto.GoblinQueueBizMongoDto;
//import com.mongodb.BasicDBObject;
//import com.mongodb.client.result.UpdateResult;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.mongodb.core.MongoTemplate;
//import org.springframework.data.mongodb.core.query.Criteria;
//import org.springframework.data.mongodb.core.query.Query;
//import org.springframework.data.redis.connection.stream.MapRecord;
//import org.springframework.data.redis.connection.stream.StreamRecords;
//import org.springframework.data.redis.core.StringRedisTemplate;
//import org.springframework.data.redis.stream.StreamListener;
//
//import java.util.HashMap;
//
///**
// * 公共的业务Mongo数据处理队列消息监听器,具体业务消费逻辑通过`consumerMessageHandler`实现
// *
// * @author zhanggb
// * Created by IntelliJ IDEA at 2022/4/22
// */
//@Slf4j
//public abstract class AbstractMdbRedisReceiver implements StreamListener<String, MapRecord<String, String, String>> {
// @Autowired
// public StringRedisTemplate stringRedisTemplate;
// @Autowired
// private MongoTemplate mongoTemplate;
// @Autowired
// private RedisUtil redisUtil;
//
// private static final BasicDBObject BASIC_DB_OBJECT = new BasicDBObject();
//
// @Override
// public void onMessage(MapRecord<String, String, String> message) {
// String redisStreamKey = this.getRedisStreamKey();
// log.debug("CONSUMER MSG[streamKey:{},messageId:{},stream:{},body:{}]", redisStreamKey, message.getId(), message.getStream(), message.getValue());
// boolean result = this.consumerMessageHandler(message.getValue().get(MQConst.QUEUE_MESSAGE_KEY));
// log.info("CONSUMER MSG RESULT:{} ==> [{}]MESSAGE_ID:{}", result, redisStreamKey, message.getId());
//
// try {
// stringRedisTemplate.opsForStream().acknowledge(getRedisStreamGroup(), message);
// } catch (Exception e) {
// log.error("#CONSUMER MSG EX_ACK ==> [{}]RESULT:{},MESSAGE:{}", redisStreamKey, result, message.getValue(), e);
// }
// try {
// stringRedisTemplate.opsForStream().delete(redisStreamKey, message.getId());
// } catch (Exception e) {
// log.error("#CONSUMER MSG EX_DEL ==> [{}]RESULT:{},MESSAGE:{}", redisStreamKey, result, message.getValue(), e);
// }
// }
//
// private boolean consumerMessageHandler(String msg) {
// boolean aBoolean = true;
// try {
// GoblinQueueBizMongoDto queueBizMongoDto = JsonUtils.fromJson(msg, GoblinQueueBizMongoDto.class);
// if (null != queueBizMongoDto) {
// String collectName = queueBizMongoDto.getCollect(), columnName = queueBizMongoDto.getColumn();
// String prefix = queueBizMongoDto.getPrefix(), bizId = queueBizMongoDto.getBizId();
//
// Object o;
// switch (queueBizMongoDto.getOpType()) {
// case 1:// insert
// o = redisUtil.get(prefix.concat(bizId));
// if (null != o) {
// mongoTemplate.insert(o, collectName);
// }
// break;
// case 2:// update
// o = redisUtil.get(prefix.concat(bizId));
// if (null != o) {
// BasicDBObject basicDBObject = (BasicDBObject) AbstractMdbRedisReceiver.BASIC_DB_OBJECT.clone();
// UpdateResult updateResult = mongoTemplate.getCollection(collectName).updateOne(
// Query.query(Criteria.where(columnName).is(bizId)).getQueryObject(),
// basicDBObject.append("$set", mongoTemplate.getConverter().convertToMongoType(o))
// );
// }
// break;
// default:
// log.error("CONSUMER MSG ERR_HANDLE[未知的操作类型,{}]", msg);
// break;
// }
// }
// } catch (Exception e) {
// log.error("CONSUMER MSG EX_HANDLE ==> [{}]:{}", this.getRedisStreamKey(), msg, e);
// aBoolean = false;
// } finally {
// if (!aBoolean) {
// HashMap<String, String> map = CollectionUtil.mapStringString();
// map.put(MQConst.QUEUE_MESSAGE_KEY, msg);
// stringRedisTemplate.opsForStream().add(StreamRecords.mapBacked(map).withStreamKey(this.getRedisStreamKey()));
// }
// }
// return aBoolean;
// }
//
// protected abstract String getRedisStreamKey();
//
// protected abstract String getRedisStreamGroup();
//}
\ No newline at end of file
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-nft/src/main/java/com/liquidnet/service/consumer/nft/receiver/AbstractSqlRedisReceiver.java
View file @
c153d97f
package
com
.
liquidnet
.
service
.
consumer
.
nft
.
receiver
;
import
com.liquidnet.commons.lang.util.CollectionUtil
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.service.base.SqlMapping
;
import
com.liquidnet.service.consumer.nft.service.IBaseDao
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.connection.stream.MapRecord
;
import
org.springframework.data.redis.connection.stream.StreamRecords
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.data.redis.stream.StreamListener
;
import
java.util.HashMap
;
/**
* 公共的SQL队列消息监听器,具体SQL消费逻辑统一使用`consumerMessageHandler`
*
* @author zhanggb
* Created by IntelliJ IDEA at 2022/3/31
*/
@Slf4j
public
abstract
class
AbstractSqlRedisReceiver
implements
StreamListener
<
String
,
MapRecord
<
String
,
String
,
String
>>
{
@Autowired
private
IBaseDao
baseDao
;
@Autowired
StringRedisTemplate
stringRedisTemplate
;
@Override
public
void
onMessage
(
MapRecord
<
String
,
String
,
String
>
message
)
{
String
redisStreamKey
=
this
.
getRedisStreamKey
();
log
.
debug
(
"CONSUMER MSG[streamKey:{},messageId:{},stream:{},body:{}]"
,
redisStreamKey
,
message
.
getId
(),
message
.
getStream
(),
message
.
getValue
());
boolean
result
=
this
.
consumerMessageHandler
(
message
.
getValue
().
get
(
"message"
));
log
.
info
(
"CONSUMER MSG RESULT:{} ==> [{}]MESSAGE_ID:{}"
,
result
,
redisStreamKey
,
message
.
getId
());
try
{
stringRedisTemplate
.
opsForStream
().
acknowledge
(
getRedisStreamGroup
(),
message
);
}
catch
(
Exception
e
)
{
log
.
error
(
"#CONSUMER MSG EX_ACK ==> [{}]RESULT:{},MESSAGE:{}"
,
redisStreamKey
,
result
,
message
.
getValue
(),
e
);
}
try
{
stringRedisTemplate
.
opsForStream
().
delete
(
redisStreamKey
,
message
.
getId
());
}
catch
(
Exception
e
)
{
log
.
error
(
"#CONSUMER MSG EX_DEL ==> [{}]RESULT:{},MESSAGE:{}"
,
redisStreamKey
,
result
,
message
.
getValue
(),
e
);
}
}
private
boolean
consumerMessageHandler
(
String
msg
)
{
boolean
aBoolean
=
false
;
try
{
SqlMapping
.
SqlMessage
sqlMessage
=
JsonUtils
.
fromJson
(
msg
,
SqlMapping
.
SqlMessage
.
class
);
if
(
sqlMessage
==
null
)
{
aBoolean
=
true
;
}
else
{
aBoolean
=
baseDao
.
batchSqls
(
sqlMessage
.
getSqls
(),
sqlMessage
.
getArgs
());
}
}
catch
(
Exception
e
)
{
log
.
error
(
"CONSUMER MSG EX_HANDLE ==> [{}]:{}"
,
this
.
getRedisStreamKey
(),
msg
,
e
);
}
finally
{
if
(!
aBoolean
)
{
HashMap
<
String
,
String
>
map
=
CollectionUtil
.
mapStringString
();
map
.
put
(
"message"
,
msg
);
stringRedisTemplate
.
opsForStream
().
add
(
StreamRecords
.
mapBacked
(
map
).
withStreamKey
(
this
.
getRedisStreamKey
()));
}
}
return
aBoolean
;
}
protected
abstract
String
getRedisStreamKey
();
protected
abstract
String
getRedisStreamGroup
();
}
\ No newline at end of file
//package com.liquidnet.service.consumer.nft.receiver;
//
//import com.liquidnet.commons.lang.util.CollectionUtil;
//import com.liquidnet.commons.lang.util.JsonUtils;
//import com.liquidnet.service.base.SqlMapping;
//import com.liquidnet.service.consumer.nft.service.IBaseDao;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.redis.connection.stream.MapRecord;
//import org.springframework.data.redis.connection.stream.StreamRecords;
//import org.springframework.data.redis.core.StringRedisTemplate;
//import org.springframework.data.redis.stream.StreamListener;
//
//import java.util.HashMap;
//
///**
// * 公共的SQL队列消息监听器,具体SQL消费逻辑统一使用`consumerMessageHandler`
// *
// * @author zhanggb
// * Created by IntelliJ IDEA at 2022/3/31
// */
//@Slf4j
//public abstract class AbstractSqlRedisReceiver implements StreamListener<String, MapRecord<String, String, String>> {
// @Autowired
// private IBaseDao baseDao;
// @Autowired
// StringRedisTemplate stringRedisTemplate;
//
// @Override
// public void onMessage(MapRecord<String, String, String> message) {
// String redisStreamKey = this.getRedisStreamKey();
// log.debug("CONSUMER MSG[streamKey:{},messageId:{},stream:{},body:{}]", redisStreamKey, message.getId(), message.getStream(), message.getValue());
// boolean result = this.consumerMessageHandler(message.getValue().get("message"));
// log.info("CONSUMER MSG RESULT:{} ==> [{}]MESSAGE_ID:{}", result, redisStreamKey, message.getId());
//
// try {
// stringRedisTemplate.opsForStream().acknowledge(getRedisStreamGroup(), message);
// } catch (Exception e) {
// log.error("#CONSUMER MSG EX_ACK ==> [{}]RESULT:{},MESSAGE:{}", redisStreamKey, result, message.getValue(), e);
// }
// try {
// stringRedisTemplate.opsForStream().delete(redisStreamKey, message.getId());
// } catch (Exception e) {
// log.error("#CONSUMER MSG EX_DEL ==> [{}]RESULT:{},MESSAGE:{}", redisStreamKey, result, message.getValue(), e);
// }
// }
//
// private boolean consumerMessageHandler(String msg) {
// boolean aBoolean = false;
// try {
// SqlMapping.SqlMessage sqlMessage = JsonUtils.fromJson(msg, SqlMapping.SqlMessage.class);
// if (sqlMessage == null) {
// aBoolean = true;
// } else {
// aBoolean = baseDao.batchSqls(sqlMessage.getSqls(), sqlMessage.getArgs());
// }
// } catch (Exception e) {
// log.error("CONSUMER MSG EX_HANDLE ==> [{}]:{}", this.getRedisStreamKey(), msg, e);
// } finally {
// if (!aBoolean) {
// HashMap<String, String> map = CollectionUtil.mapStringString();
// map.put("message", msg);
// stringRedisTemplate.opsForStream().add(StreamRecords.mapBacked(map).withStreamKey(this.getRedisStreamKey()));
// }
// }
// return aBoolean;
// }
//
// protected abstract String getRedisStreamKey();
//
// protected abstract String getRedisStreamGroup();
//}
\ No newline at end of file
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-nft/src/main/java/com/liquidnet/service/consumer/nft/receiver/ConsumerGalaxyJsonNftPublishAndBuyReceiver.java
View file @
c153d97f
package
com
.
liquidnet
.
service
.
consumer
.
nft
.
receiver
;
import
com.liquidnet.commons.lang.util.CollectionUtil
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.constant.MQConst
;
import
com.liquidnet.service.consumer.nft.service.processor.ConsumerGalaxyJsonNftPublishAndBuyProcessor
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishAndBuyReqDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishAndBuyRespDto
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.connection.stream.StreamRecords
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
@Slf4j
@Component
public
class
ConsumerGalaxyJsonNftPublishAndBuyReceiver
extends
AbstractBizRedisReceiver
{
@Autowired
private
ConsumerGalaxyJsonNftPublishAndBuyProcessor
jsonNftPublishAndBuyProcessor
;
@Override
protected
boolean
consumerMessageHandler
(
String
msg
)
{
boolean
aBoolean
=
false
;
try
{
GalaxyNftPublishAndBuyReqDto
textMessage
=
JsonUtils
.
fromJson
(
msg
,
GalaxyNftPublishAndBuyReqDto
.
class
);
if
(
textMessage
==
null
)
{
aBoolean
=
true
;
}
else
{
//执行计数
ResponseDto
<
GalaxyNftPublishAndBuyRespDto
>
responseDto
=
jsonNftPublishAndBuyProcessor
.
nftPublishAndBuy
(
textMessage
);
if
(
responseDto
.
isSuccess
()){
aBoolean
=
true
;
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"CONSUMER MSG EX_HANDLE ==> [{}]:{}"
,
this
.
getRedisStreamKey
(),
msg
,
e
);
}
finally
{
if
(!
aBoolean
)
{
HashMap
<
String
,
String
>
map
=
CollectionUtil
.
mapStringString
();
map
.
put
(
"message"
,
msg
);
stringRedisTemplate
.
opsForStream
().
add
(
StreamRecords
.
mapBacked
(
map
).
withStreamKey
(
this
.
getRedisStreamKey
()));
}
}
return
aBoolean
;
}
@Override
protected
String
getRedisStreamKey
()
{
return
MQConst
.
GalaxyQueue
.
JSON_NFT_PUBLISH_AND_BUY
.
getKey
();
}
@Override
protected
String
getRedisStreamGroup
()
{
return
MQConst
.
GalaxyQueue
.
JSON_NFT_PUBLISH_AND_BUY
.
getGroup
();
}
}
//
package com.liquidnet.service.consumer.nft.receiver;
//
//
import com.liquidnet.commons.lang.util.CollectionUtil;
//
import com.liquidnet.commons.lang.util.JsonUtils;
//
import com.liquidnet.service.base.ResponseDto;
//
import com.liquidnet.service.base.constant.MQConst;
//
import com.liquidnet.service.consumer.nft.service.processor.ConsumerGalaxyJsonNftPublishAndBuyProcessor;
//
import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishAndBuyReqDto;
//
import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishAndBuyRespDto;
//
import lombok.extern.slf4j.Slf4j;
//
import org.springframework.beans.factory.annotation.Autowired;
//
import org.springframework.data.redis.connection.stream.StreamRecords;
//
import org.springframework.stereotype.Component;
//
//
import java.util.HashMap;
//
//
@Slf4j
//
@Component
//
public class ConsumerGalaxyJsonNftPublishAndBuyReceiver extends AbstractBizRedisReceiver {
//
@Autowired
//
private ConsumerGalaxyJsonNftPublishAndBuyProcessor jsonNftPublishAndBuyProcessor;
//
//
@Override
//
protected boolean consumerMessageHandler(String msg) {
//
boolean aBoolean = false;
//
try {
//
GalaxyNftPublishAndBuyReqDto textMessage = JsonUtils.fromJson(msg, GalaxyNftPublishAndBuyReqDto.class);
//
if (textMessage == null) {
//
aBoolean = true;
//
} else {
//
//执行计数
//
ResponseDto<GalaxyNftPublishAndBuyRespDto> responseDto = jsonNftPublishAndBuyProcessor.nftPublishAndBuy(textMessage);
//
if(responseDto.isSuccess()){
//
aBoolean = true;
//
}
//
}
//
} catch (Exception e) {
//
log.error("CONSUMER MSG EX_HANDLE ==> [{}]:{}", this.getRedisStreamKey(), msg, e);
//
} finally {
//
if (!aBoolean) {
//
HashMap<String, String> map = CollectionUtil.mapStringString();
//
map.put("message", msg);
//
stringRedisTemplate.opsForStream().add(StreamRecords.mapBacked(map).withStreamKey(this.getRedisStreamKey()));
//
}
//
}
//
return aBoolean;
//
}
//
//
@Override
//
protected String getRedisStreamKey() {
//
return MQConst.GalaxyQueue.JSON_NFT_PUBLISH_AND_BUY.getKey();
//
}
//
//
@Override
//
protected String getRedisStreamGroup() {
//
return MQConst.GalaxyQueue.JSON_NFT_PUBLISH_AND_BUY.getGroup();
//
}
//
}
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-nft/src/main/java/com/liquidnet/service/consumer/nft/receiver/ConsumerGalaxyJsonNftUserRegisterReceiver.java
View file @
c153d97f
package
com
.
liquidnet
.
service
.
consumer
.
nft
.
receiver
;
import
com.liquidnet.commons.lang.util.CollectionUtil
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.constant.MQConst
;
import
com.liquidnet.service.consumer.nft.service.processor.ConsumerGalaxyJsonNftUserRegisterProcessor
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterReqDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterRespDto
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.connection.stream.StreamRecords
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
@Slf4j
@Component
public
class
ConsumerGalaxyJsonNftUserRegisterReceiver
extends
AbstractBizRedisReceiver
{
@Autowired
private
ConsumerGalaxyJsonNftUserRegisterProcessor
jsonNftUserRegisterProcessor
;
@Override
protected
boolean
consumerMessageHandler
(
String
msg
)
{
boolean
aBoolean
=
false
;
try
{
GalaxyUserRegisterReqDto
textMessage
=
JsonUtils
.
fromJson
(
msg
,
GalaxyUserRegisterReqDto
.
class
);
if
(
textMessage
==
null
)
{
aBoolean
=
true
;
}
else
{
//执行计数
ResponseDto
<
GalaxyUserRegisterRespDto
>
responseDto
=
jsonNftUserRegisterProcessor
.
userRegister
(
textMessage
);
// if(responseDto.isSuccess()){
aBoolean
=
true
;
//package com.liquidnet.service.consumer.nft.receiver;
//
//import com.liquidnet.commons.lang.util.CollectionUtil;
//import com.liquidnet.commons.lang.util.JsonUtils;
//import com.liquidnet.service.base.ResponseDto;
//import com.liquidnet.service.base.constant.MQConst;
//import com.liquidnet.service.consumer.nft.service.processor.ConsumerGalaxyJsonNftUserRegisterProcessor;
//import com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterReqDto;
//import com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterRespDto;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.redis.connection.stream.StreamRecords;
//import org.springframework.stereotype.Component;
//
//import java.util.HashMap;
//
//@Slf4j
//@Component
//public class ConsumerGalaxyJsonNftUserRegisterReceiver extends AbstractBizRedisReceiver {
// @Autowired
// private ConsumerGalaxyJsonNftUserRegisterProcessor jsonNftUserRegisterProcessor;
//
// @Override
// protected boolean consumerMessageHandler(String msg) {
// boolean aBoolean = false;
// try {
// GalaxyUserRegisterReqDto textMessage = JsonUtils.fromJson(msg, GalaxyUserRegisterReqDto.class);
// if (textMessage == null) {
// aBoolean = true;
// } else {
// //执行计数
// ResponseDto<GalaxyUserRegisterRespDto> responseDto = jsonNftUserRegisterProcessor.userRegister(textMessage);
//// if(responseDto.isSuccess()){
// aBoolean = true;
//// }
// }
}
}
catch
(
Exception
e
)
{
log
.
error
(
"CONSUMER MSG EX_HANDLE ==> [{}]:{}"
,
this
.
getRedisStreamKey
(),
msg
,
e
);
}
finally
{
if
(!
aBoolean
)
{
HashMap
<
String
,
String
>
map
=
CollectionUtil
.
mapStringString
();
map
.
put
(
"message"
,
msg
);
stringRedisTemplate
.
opsForStream
().
add
(
StreamRecords
.
mapBacked
(
map
).
withStreamKey
(
this
.
getRedisStreamKey
()));
}
}
return
aBoolean
;
}
@Override
protected
String
getRedisStreamKey
()
{
return
MQConst
.
GalaxyQueue
.
JSON_NFT_USER_REGISTER
.
getKey
();
}
@Override
protected
String
getRedisStreamGroup
()
{
return
MQConst
.
GalaxyQueue
.
JSON_NFT_USER_REGISTER
.
getGroup
();
}
}
// } catch (Exception e) {
// log.error("CONSUMER MSG EX_HANDLE ==> [{}]:{}", this.getRedisStreamKey(), msg, e);
// } finally {
// if (!aBoolean) {
// HashMap<String, String> map = CollectionUtil.mapStringString();
// map.put("message", msg);
// stringRedisTemplate.opsForStream().add(StreamRecords.mapBacked(map).withStreamKey(this.getRedisStreamKey()));
// }
// }
// return aBoolean;
// }
//
// @Override
// protected String getRedisStreamKey() {
// return MQConst.GalaxyQueue.JSON_NFT_USER_REGISTER.getKey();
// }
//
// @Override
// protected String getRedisStreamGroup() {
// return MQConst.GalaxyQueue.JSON_NFT_USER_REGISTER.getGroup();
// }
//}
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