Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wecloud_im_server
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hewei
wecloud_im_server
Commits
d98cc350
Commit
d98cc350
authored
Sep 30, 2022
by
Future
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
发消息优化
parent
b7a5b582
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
82 additions
and
10 deletions
+82
-10
core/pom.xml
+12
-0
core/src/main/java/com/wecloud/im/action/NormalChatAction.java
+3
-10
core/src/main/java/com/wecloud/im/service/EhcacheService.java
+41
-0
core/src/main/resources/ehcache.xml
+26
-0
No files found.
core/pom.xml
View file @
d98cc350
...
@@ -146,6 +146,18 @@
...
@@ -146,6 +146,18 @@
<artifactId>
hutool-all
</artifactId>
<artifactId>
hutool-all
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-cache
</artifactId>
<version>
2.5.2
</version>
</dependency>
<dependency>
<groupId>
net.sf.ehcache
</groupId>
<artifactId>
ehcache
</artifactId>
<version>
2.10.8
</version>
</dependency>
</dependencies>
</dependencies>
<!-- <build>-->
<!-- <build>-->
<!-- <resources>-->
<!-- <resources>-->
...
...
core/src/main/java/com/wecloud/im/action/NormalChatAction.java
View file @
d98cc350
...
@@ -25,6 +25,7 @@ import com.wecloud.im.sdk.enums.ChatTypeEnum;
...
@@ -25,6 +25,7 @@ import com.wecloud.im.sdk.enums.ChatTypeEnum;
import
com.wecloud.im.sdk.enums.FriendStateEnum
;
import
com.wecloud.im.sdk.enums.FriendStateEnum
;
import
com.wecloud.im.sdk.enums.GroupRoleEnum
;
import
com.wecloud.im.sdk.enums.GroupRoleEnum
;
import
com.wecloud.im.sdk.enums.MutedEnum
;
import
com.wecloud.im.sdk.enums.MutedEnum
;
import
com.wecloud.im.service.EhcacheService
;
import
com.wecloud.im.service.ImApplicationService
;
import
com.wecloud.im.service.ImApplicationService
;
import
com.wecloud.im.service.ImClientBlacklistService
;
import
com.wecloud.im.service.ImClientBlacklistService
;
import
com.wecloud.im.service.ImClientService
;
import
com.wecloud.im.service.ImClientService
;
...
@@ -98,7 +99,7 @@ public class NormalChatAction {
...
@@ -98,7 +99,7 @@ public class NormalChatAction {
@Autowired
@Autowired
private
ImFriendService
friendService
;
private
ImFriendService
friendService
;
@Resource
@Resource
private
RedisUtils
redisUtils
;
private
EhcacheService
ehcacheService
;
@ActionMapping
(
"/normal/send"
)
@ActionMapping
(
"/normal/send"
)
@ApiOperation
(
"普通消息发送"
)
@ApiOperation
(
"普通消息发送"
)
...
@@ -186,15 +187,7 @@ public class NormalChatAction {
...
@@ -186,15 +187,7 @@ public class NormalChatAction {
imConversationMembersService
.
updateBatchById
(
tempMemberToUpdate
);
imConversationMembersService
.
updateBatchById
(
tempMemberToUpdate
);
}
}
}
}
String
key
=
"push_"
+
conversation
.
getId
();
final
Boolean
isPush
=
ehcacheService
.
getIsPush
(
conversation
.
getId
().
toString
());
String
value
=
redisUtils
.
getKey
(
key
);
final
Boolean
isPush
;
if
(
StringUtils
.
isBlank
(
value
))
{
isPush
=
Boolean
.
TRUE
;
redisUtils
.
addKey
(
key
,
"1"
,
Duration
.
ofMinutes
(
5
));
}
else
{
isPush
=
Boolean
.
FALSE
;
}
// 多线程处理消息下发
// 多线程处理消息下发
for
(
ImConversationMembers
member
:
membersList
)
{
for
(
ImConversationMembers
member
:
membersList
)
{
if
(
member
.
getFkClientId
().
equals
(
imClientSender
.
getId
()))
{
if
(
member
.
getFkClientId
().
equals
(
imClientSender
.
getId
()))
{
...
...
core/src/main/java/com/wecloud/im/service/EhcacheService.java
0 → 100644
View file @
d98cc350
package
com
.
wecloud
.
im
.
service
;
import
com.alibaba.fastjson.JSON
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.Cache
;
import
org.springframework.cache.CacheManager
;
import
org.springframework.stereotype.Service
;
/**
* @Author Future
* @Date 2022/8/24 17:18
* @Description 本地缓存服务
*/
@Slf4j
@Service
public
class
EhcacheService
{
@Autowired
private
CacheManager
cacheManager
;
/**
* 本地缓存中获取
* @param key
* @return
*/
public
Boolean
getIsPush
(
String
key
)
{
Cache
cache
=
cacheManager
.
getCache
(
"push"
);
Object
value
=
cache
.
get
(
key
);
log
.
info
(
"ehcache {}"
,
JSON
.
toJSONString
(
value
));
if
(
value
!=
null
)
{
return
false
;
}
else
{
cache
.
put
(
key
,
1
);
return
true
;
}
}
}
core/src/main/resources/ehcache.xml
0 → 100644
View file @
d98cc350
<ehcache
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"../config/ehcache.xsd"
>
<diskStore
path=
"java.io.tmpdir"
/>
<defaultCache
maxElementsInMemory=
"10000"
eternal=
"false"
timeToIdleSeconds=
"120"
timeToLiveSeconds=
"120"
maxElementsOnDisk=
"10000000"
diskExpiryThreadIntervalSeconds=
"120"
memoryStoreEvictionPolicy=
"LRU"
>
<persistence
strategy=
"localTempSwap"
/>
</defaultCache>
<cache
name=
"push"
maxElementsInMemory=
"10000"
eternal=
"false"
timeToIdleSeconds=
"300"
timeToLiveSeconds=
"300"
maxElementsOnDisk=
"10000000"
diskExpiryThreadIntervalSeconds=
"120"
memoryStoreEvictionPolicy=
"LRU"
>
<persistence
strategy=
"localTempSwap"
/>
</cache>
</ehcache>
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