记得上下班打卡 | 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
533ba47c
Commit
533ba47c
authored
Apr 12, 2022
by
anjiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改galaxy消费相关
parent
a8ed4fb1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
70 deletions
+35
-70
AbstractJsonRedisReceiver.java
...ce/consumer/kylin/receiver/AbstractJsonRedisReceiver.java
+0
-69
ConsumerGalaxyJsonNftPublishAndBuyReceiver.java
.../receiver/ConsumerGalaxyJsonNftPublishAndBuyReceiver.java
+35
-1
No files found.
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-kylin/src/main/java/com/liquidnet/service/consumer/kylin/receiver/AbstractJsonRedisReceiver.java
deleted
100644 → 0
View file @
a8ed4fb1
package
com
.
liquidnet
.
service
.
consumer
.
kylin
.
receiver
;
import
com.liquidnet.commons.lang.util.CollectionUtil
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.service.consumer.kylin.service.processor.ConsumerGalaxyJsonNftPublishAndBuyProcessor
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishAndBuyReqDto
;
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
;
@Slf4j
public
abstract
class
AbstractJsonRedisReceiver
implements
StreamListener
<
String
,
MapRecord
<
String
,
String
,
String
>>
{
@Autowired
StringRedisTemplate
stringRedisTemplate
;
@Autowired
private
ConsumerGalaxyJsonNftPublishAndBuyProcessor
jsonNftPublishAndBuyProcessor
;
@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
{
GalaxyNftPublishAndBuyReqDto
textMessage
=
JsonUtils
.
fromJson
(
msg
,
GalaxyNftPublishAndBuyReqDto
.
class
);
if
(
textMessage
==
null
)
{
aBoolean
=
true
;
}
else
{
//执行计数
jsonNftPublishAndBuyProcessor
.
nftPublishAndBuy
(
textMessage
);
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
;
}
protected
abstract
String
getRedisStreamKey
();
protected
abstract
String
getRedisStreamGroup
();
}
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-kylin/src/main/java/com/liquidnet/service/consumer/kylin/receiver/ConsumerGalaxyJsonNftPublishAndBuyReceiver.java
View file @
533ba47c
package
com
.
liquidnet
.
service
.
consumer
.
kylin
.
receiver
;
package
com
.
liquidnet
.
service
.
consumer
.
kylin
.
receiver
;
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.base.constant.MQConst
;
import
com.liquidnet.service.consumer.kylin.service.processor.ConsumerGalaxyJsonNftPublishAndBuyProcessor
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishAndBuyReqDto
;
import
lombok.extern.slf4j.Slf4j
;
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
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
@Slf4j
@Slf4j
@Component
@Component
public
class
ConsumerGalaxyJsonNftPublishAndBuyReceiver
extends
AbstractJsonRedisReceiver
{
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
{
//执行计数
jsonNftPublishAndBuyProcessor
.
nftPublishAndBuy
(
textMessage
);
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
@Override
protected
String
getRedisStreamKey
()
{
protected
String
getRedisStreamKey
()
{
...
...
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