Showing
13 changed files
with
351 additions
and
70 deletions
common/.classpath
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<classpath> | ||
3 | + <classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
4 | + <attributes> | ||
5 | + <attribute name="optional" value="true"/> | ||
6 | + <attribute name="maven.pomderived" value="true"/> | ||
7 | + </attributes> | ||
8 | + </classpathentry> | ||
9 | + <classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
10 | + <attributes> | ||
11 | + <attribute name="optional" value="true"/> | ||
12 | + <attribute name="maven.pomderived" value="true"/> | ||
13 | + </attributes> | ||
14 | + </classpathentry> | ||
15 | + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> | ||
16 | + <attributes> | ||
17 | + <attribute name="maven.pomderived" value="true"/> | ||
18 | + </attributes> | ||
19 | + </classpathentry> | ||
20 | + <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
21 | + <attributes> | ||
22 | + <attribute name="maven.pomderived" value="true"/> | ||
23 | + <attribute name="org.eclipse.jst.component.nondependency" value=""/> | ||
24 | + </attributes> | ||
25 | + </classpathentry> | ||
26 | + <classpathentry kind="output" path="target/classes"/> | ||
27 | +</classpath> |
common/pom.xml
0 → 100644
1 | +<?xml version="1.0"?> | ||
2 | +<project | ||
3 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
4 | + xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
5 | + <modelVersion>4.0.0</modelVersion> | ||
6 | + <parent> | ||
7 | + <groupId>com.yoho.dsf</groupId> | ||
8 | + <artifactId>yoho-message-sender</artifactId> | ||
9 | + <version>1.0.0-SNAPSHOT</version> | ||
10 | + </parent> | ||
11 | + | ||
12 | + <groupId>com.yoho.dsf.yhmessagesender</groupId> | ||
13 | + <artifactId>yoho-message-sender-common</artifactId> | ||
14 | + <packaging>jar</packaging> | ||
15 | + <name>yoho-message-sender-common</name> | ||
16 | + <url>http://maven.apache.org</url> | ||
17 | + | ||
18 | + <dependencies> | ||
19 | + <dependency> | ||
20 | + <groupId>com.yoho.dsf.yhmessagesender</groupId> | ||
21 | + <artifactId>yoho-message-sender-dal</artifactId> | ||
22 | + </dependency> | ||
23 | + <dependency> | ||
24 | + <groupId>com.yoho.service.model</groupId> | ||
25 | + <artifactId>message-service-model</artifactId> | ||
26 | + </dependency> | ||
27 | + <dependency> | ||
28 | + <groupId>com.yoho.core</groupId> | ||
29 | + <artifactId>yoho-core-redis</artifactId> | ||
30 | + </dependency> | ||
31 | + <dependency> | ||
32 | + <groupId>com.yoho.core</groupId> | ||
33 | + <artifactId>yoho-core-message</artifactId> | ||
34 | + </dependency> | ||
35 | + <dependency> | ||
36 | + <groupId>commons-httpclient</groupId> | ||
37 | + <artifactId>commons-httpclient</artifactId> | ||
38 | + <version>3.1</version> | ||
39 | + </dependency> | ||
40 | + <dependency> | ||
41 | + <groupId>com.yoho.common</groupId> | ||
42 | + <artifactId>error-code</artifactId> | ||
43 | + </dependency> | ||
44 | + <dependency> | ||
45 | + <groupId>org.json</groupId> | ||
46 | + <artifactId>json</artifactId> | ||
47 | + <version>20150729</version> | ||
48 | + </dependency> | ||
49 | + <dependency> | ||
50 | + <groupId>com.cloopen</groupId> | ||
51 | + <artifactId>CCP_REST_SMS_SDK_JAVA</artifactId> | ||
52 | + <version>v2.6.3r</version> | ||
53 | + </dependency> | ||
54 | + <dependency> | ||
55 | + <groupId>com.yoho.core</groupId> | ||
56 | + <artifactId>yoho-core-cache-clean</artifactId> | ||
57 | + </dependency> | ||
58 | + <dependency> | ||
59 | + <groupId>com.xuanwu</groupId> | ||
60 | + <artifactId>postmsg-ump</artifactId> | ||
61 | + <version>2.4</version> | ||
62 | + </dependency> | ||
63 | + <dependency> | ||
64 | + <groupId>com.thoughtworks.xstream</groupId> | ||
65 | + <artifactId>xstream</artifactId> | ||
66 | + <version>1.3.1</version> | ||
67 | + </dependency> | ||
68 | + <dependency> | ||
69 | + <groupId>com.aliyun</groupId> | ||
70 | + <artifactId>aliyun-java-sdk-core</artifactId> | ||
71 | + <version>3.0.8</version> | ||
72 | + </dependency> | ||
73 | + <dependency> | ||
74 | + <groupId>com.aliyun</groupId> | ||
75 | + <artifactId>aliyun-java-sdk-sms</artifactId> | ||
76 | + <version>3.0.0-rc1</version> | ||
77 | + </dependency> | ||
78 | + </dependencies> | ||
79 | + <build> | ||
80 | + <finalName>yoho-message-sender-sms</finalName> | ||
81 | + </build> | ||
82 | +</project> |
1 | -package com.yoho.yhmessage.sms.filter.impl; | 1 | +package com.yoho.yhmessage.filter.impl; |
2 | 2 | ||
3 | import java.util.ArrayList; | 3 | import java.util.ArrayList; |
4 | import java.util.List; | 4 | import java.util.List; |
5 | import java.util.concurrent.TimeUnit; | 5 | import java.util.concurrent.TimeUnit; |
6 | 6 | ||
7 | -import javax.annotation.Resource; | ||
8 | - | ||
9 | import org.apache.commons.lang.StringUtils; | 7 | import org.apache.commons.lang.StringUtils; |
10 | import org.slf4j.Logger; | 8 | import org.slf4j.Logger; |
11 | import org.slf4j.LoggerFactory; | 9 | import org.slf4j.LoggerFactory; |
@@ -17,10 +15,9 @@ import org.springframework.data.redis.core.RedisCallback; | @@ -17,10 +15,9 @@ import org.springframework.data.redis.core.RedisCallback; | ||
17 | import org.springframework.data.redis.serializer.RedisSerializer; | 15 | import org.springframework.data.redis.serializer.RedisSerializer; |
18 | import org.springframework.stereotype.Service; | 16 | import org.springframework.stereotype.Service; |
19 | 17 | ||
20 | -import com.yoho.core.redis.YHRedisTemplate; | ||
21 | -import com.yoho.yhmessage.sms.filter.IFilterByCountService; | ||
22 | -import com.yoho.yhmessage.sms.filter.IObjectKeyTransfer; | ||
23 | - | 18 | +import com.yoho.yhmessage.filter.IFilterByCountService; |
19 | +import com.yoho.yhmessage.filter.IObjectKeyTransfer; | ||
20 | +import com.yoho.yhmessage.redis.PushRedisService; | ||
24 | 21 | ||
25 | @Service | 22 | @Service |
26 | public class FilterByCountServiceImpl implements IFilterByCountService { | 23 | public class FilterByCountServiceImpl implements IFilterByCountService { |
@@ -28,8 +25,7 @@ public class FilterByCountServiceImpl implements IFilterByCountService { | @@ -28,8 +25,7 @@ public class FilterByCountServiceImpl implements IFilterByCountService { | ||
28 | private static final Logger logger = LoggerFactory.getLogger(FilterByCountServiceImpl.class); | 25 | private static final Logger logger = LoggerFactory.getLogger(FilterByCountServiceImpl.class); |
29 | 26 | ||
30 | @Autowired | 27 | @Autowired |
31 | - @Resource(name = "yhRedisTemplate") | ||
32 | - private YHRedisTemplate<String, String> yhRedisTemplate; | 28 | + private PushRedisService pushRedisService; |
33 | 29 | ||
34 | @Override | 30 | @Override |
35 | public <V> List<V> batchFilter(String redisKey, List<V> objects, List<V> whiteObjects, IObjectKeyTransfer<V> objectKeyTransfer, int maxCount, long timeout, TimeUnit unit) { | 31 | public <V> List<V> batchFilter(String redisKey, List<V> objects, List<V> whiteObjects, IObjectKeyTransfer<V> objectKeyTransfer, int maxCount, long timeout, TimeUnit unit) { |
@@ -53,7 +49,7 @@ public class FilterByCountServiceImpl implements IFilterByCountService { | @@ -53,7 +49,7 @@ public class FilterByCountServiceImpl implements IFilterByCountService { | ||
53 | timeout = 1; | 49 | timeout = 1; |
54 | unit = TimeUnit.DAYS; | 50 | unit = TimeUnit.DAYS; |
55 | } | 51 | } |
56 | - BoundHashOperations<String, String, String> operations = yhRedisTemplate.boundHashOps(redisKey); | 52 | + BoundHashOperations<String, String, String> operations = pushRedisService.getPushRedisTemplate().boundHashOps(redisKey); |
57 | if (operations.getExpire() <= 0) { | 53 | if (operations.getExpire() <= 0) { |
58 | operations.expire(timeout, unit); | 54 | operations.expire(timeout, unit); |
59 | } | 55 | } |
@@ -86,11 +82,11 @@ public class FilterByCountServiceImpl implements IFilterByCountService { | @@ -86,11 +82,11 @@ public class FilterByCountServiceImpl implements IFilterByCountService { | ||
86 | */ | 82 | */ |
87 | private List<Integer> bacthIncrCount(String redisKey, List<String> objectKeys, int incCount) { | 83 | private List<Integer> bacthIncrCount(String redisKey, List<String> objectKeys, int incCount) { |
88 | try { | 84 | try { |
89 | - List<Integer> increasedResults = yhRedisTemplate.execute(new RedisCallback<List<Integer>>() { | 85 | + List<Integer> increasedResults = pushRedisService.getPushRedisTemplate().execute(new RedisCallback<List<Integer>>() { |
90 | @Override | 86 | @Override |
91 | public List<Integer> doInRedis(RedisConnection redisConnection) throws DataAccessException { | 87 | public List<Integer> doInRedis(RedisConnection redisConnection) throws DataAccessException { |
92 | redisConnection.openPipeline(); | 88 | redisConnection.openPipeline(); |
93 | - RedisSerializer<String> stringSerializer = yhRedisTemplate.getStringSerializer(); | 89 | + RedisSerializer<String> stringSerializer = pushRedisService.getPushRedisTemplate().getStringSerializer(); |
94 | byte[] key = null; | 90 | byte[] key = null; |
95 | byte[] hkey = null; | 91 | byte[] hkey = null; |
96 | for (String objectKey : objectKeys) { | 92 | for (String objectKey : objectKeys) { |
1 | +package com.yoho.yhmessage.redis; | ||
2 | + | ||
3 | +import java.util.List; | ||
4 | +import java.util.concurrent.TimeUnit; | ||
5 | + | ||
6 | +import javax.annotation.PostConstruct; | ||
7 | +import javax.annotation.Resource; | ||
8 | + | ||
9 | +import org.springframework.data.redis.core.ListOperations; | ||
10 | +import org.springframework.data.redis.core.RedisTemplate; | ||
11 | +import org.springframework.data.redis.core.ValueOperations; | ||
12 | +import org.springframework.stereotype.Service; | ||
13 | + | ||
14 | +/** | ||
15 | + * | ||
16 | + * PUSH专用redis,和公用redis集群分开 | ||
17 | + * | ||
18 | + * @author hugufei | ||
19 | + */ | ||
20 | + | ||
21 | +@Service | ||
22 | +public class PushRedisService { | ||
23 | + | ||
24 | + @Resource(name = "pushRedisTemplate") | ||
25 | + private RedisTemplate<String, String> pushRedisTemplate; | ||
26 | + | ||
27 | + private ValueOperations<String, String> pushValueOperations; | ||
28 | + private ListOperations<String, String> pushListOperations; | ||
29 | + | ||
30 | + @PostConstruct | ||
31 | + void init() { | ||
32 | + pushValueOperations = pushRedisTemplate.opsForValue(); | ||
33 | + pushListOperations = pushRedisTemplate.opsForList(); | ||
34 | + } | ||
35 | + | ||
36 | + /*************************** redisTemplate *****************************/ | ||
37 | + public RedisTemplate<String, String> getPushRedisTemplate() { | ||
38 | + return pushRedisTemplate; | ||
39 | + } | ||
40 | + | ||
41 | + public void longExpire(String redisKey, long expiredTs, TimeUnit timeUnit) { | ||
42 | + pushRedisTemplate.expire(redisKey, expiredTs, timeUnit); | ||
43 | + } | ||
44 | + | ||
45 | + /*************************** value_operation *****************************/ | ||
46 | + public boolean value_setIfAbsent(String redisKey, String string) { | ||
47 | + return this.pushValueOperations.setIfAbsent(redisKey, string); | ||
48 | + } | ||
49 | + | ||
50 | + /*************************** list_operation *****************************/ | ||
51 | + public void list_rightPushAll(String redisKey, List<String> values) { | ||
52 | + this.pushListOperations.rightPushAll(redisKey, values); | ||
53 | + } | ||
54 | + | ||
55 | + public List<String> list_range(String redisKey, long fromIndex, long toIndex) { | ||
56 | + return this.pushListOperations.range(redisKey, fromIndex, toIndex); | ||
57 | + } | ||
58 | + | ||
59 | + public long list_size(String redisKey) { | ||
60 | + return this.pushListOperations.size(redisKey); | ||
61 | + } | ||
62 | + | ||
63 | +} |
1 | +package com.yoho.yhmessage.redis; | ||
2 | + | ||
3 | +import java.util.List; | ||
4 | + | ||
5 | +import javax.annotation.Resource; | ||
6 | + | ||
7 | +import org.springframework.stereotype.Service; | ||
8 | + | ||
9 | +import com.yoho.core.redis.YHListOperations; | ||
10 | +import com.yoho.core.redis.YHRedisTemplate; | ||
11 | + | ||
12 | +/** | ||
13 | + * yoho主从同步redis | ||
14 | + * @author hugufei | ||
15 | + */ | ||
16 | + | ||
17 | +@Service | ||
18 | +public class YohoRedisService { | ||
19 | + | ||
20 | + @Resource(name = "yhRedisTemplate") | ||
21 | + private YHRedisTemplate<String, String> yhRedisTemplate; | ||
22 | + @Resource(name = "yhListOperations") | ||
23 | + private YHListOperations<String, String> yhListOperations; | ||
24 | + | ||
25 | + public long list_size(String redisKey) { | ||
26 | + return yhListOperations.size(redisKey); | ||
27 | + } | ||
28 | + | ||
29 | + public List<String> list_range(String redisKey, int formIndex, int toIndex) { | ||
30 | + return yhListOperations.range(redisKey, formIndex, toIndex); | ||
31 | + } | ||
32 | + | ||
33 | +} |
common/src/test/java/org/common/AppTest.java
0 → 100644
1 | +package org.common; | ||
2 | + | ||
3 | +import junit.framework.Test; | ||
4 | +import junit.framework.TestCase; | ||
5 | +import junit.framework.TestSuite; | ||
6 | + | ||
7 | +/** | ||
8 | + * Unit test for simple App. | ||
9 | + */ | ||
10 | +public class AppTest | ||
11 | + extends TestCase | ||
12 | +{ | ||
13 | + /** | ||
14 | + * Create the test case | ||
15 | + * | ||
16 | + * @param testName name of the test case | ||
17 | + */ | ||
18 | + public AppTest( String testName ) | ||
19 | + { | ||
20 | + super( testName ); | ||
21 | + } | ||
22 | + | ||
23 | + /** | ||
24 | + * @return the suite of tests being tested | ||
25 | + */ | ||
26 | + public static Test suite() | ||
27 | + { | ||
28 | + return new TestSuite( AppTest.class ); | ||
29 | + } | ||
30 | + | ||
31 | + /** | ||
32 | + * Rigourous Test :-) | ||
33 | + */ | ||
34 | + public void testApp() | ||
35 | + { | ||
36 | + assertTrue( true ); | ||
37 | + } | ||
38 | +} |
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
3 | - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | 2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
4 | <modelVersion>4.0.0</modelVersion> | 3 | <modelVersion>4.0.0</modelVersion> |
5 | <parent> | 4 | <parent> |
6 | <groupId>com.yoho</groupId> | 5 | <groupId>com.yoho</groupId> |
@@ -25,6 +24,11 @@ | @@ -25,6 +24,11 @@ | ||
25 | <dependencies> | 24 | <dependencies> |
26 | <dependency> | 25 | <dependency> |
27 | <groupId>com.yoho.dsf.yhmessagesender</groupId> | 26 | <groupId>com.yoho.dsf.yhmessagesender</groupId> |
27 | + <artifactId>yoho-message-sender-common</artifactId> | ||
28 | + <version>${project-version}</version> | ||
29 | + </dependency> | ||
30 | + <dependency> | ||
31 | + <groupId>com.yoho.dsf.yhmessagesender</groupId> | ||
28 | <artifactId>yoho-message-sender-sms</artifactId> | 32 | <artifactId>yoho-message-sender-sms</artifactId> |
29 | <version>${project-version}</version> | 33 | <version>${project-version}</version> |
30 | </dependency> | 34 | </dependency> |
@@ -46,11 +50,14 @@ | @@ -46,11 +50,14 @@ | ||
46 | </dependencies> | 50 | </dependencies> |
47 | </dependencyManagement> | 51 | </dependencyManagement> |
48 | <modules> | 52 | <modules> |
53 | + <module>common</module> | ||
49 | <module>dal</module> | 54 | <module>dal</module> |
50 | <module>sms</module> | 55 | <module>sms</module> |
51 | <module>inbox</module> | 56 | <module>inbox</module> |
52 | <module>push</module> | 57 | <module>push</module> |
53 | <module>web</module> | 58 | <module>web</module> |
54 | <module>deploy</module> | 59 | <module>deploy</module> |
55 | - </modules> | ||
56 | -</project> | 60 | + <module>yoho-message-common</module> |
61 | + <module>common</module> | ||
62 | + </modules> | ||
63 | +</project> |
@@ -8,22 +8,26 @@ | @@ -8,22 +8,26 @@ | ||
8 | <artifactId>yoho-message-sender</artifactId> | 8 | <artifactId>yoho-message-sender</artifactId> |
9 | <version>1.0.0-SNAPSHOT</version> | 9 | <version>1.0.0-SNAPSHOT</version> |
10 | </parent> | 10 | </parent> |
11 | - | 11 | + |
12 | <groupId>com.yoho.dsf.yhmessagesender</groupId> | 12 | <groupId>com.yoho.dsf.yhmessagesender</groupId> |
13 | <artifactId>yoho-message-sender-sms</artifactId> | 13 | <artifactId>yoho-message-sender-sms</artifactId> |
14 | <packaging>jar</packaging> | 14 | <packaging>jar</packaging> |
15 | <name>yoho-message-sender-sms</name> | 15 | <name>yoho-message-sender-sms</name> |
16 | <url>http://maven.apache.org</url> | 16 | <url>http://maven.apache.org</url> |
17 | - | 17 | + |
18 | <dependencies> | 18 | <dependencies> |
19 | <dependency> | 19 | <dependency> |
20 | <groupId>com.yoho.dsf.yhmessagesender</groupId> | 20 | <groupId>com.yoho.dsf.yhmessagesender</groupId> |
21 | + <artifactId>yoho-message-sender-common</artifactId> | ||
22 | + </dependency> | ||
23 | + <dependency> | ||
24 | + <groupId>com.yoho.dsf.yhmessagesender</groupId> | ||
21 | <artifactId>yoho-message-sender-dal</artifactId> | 25 | <artifactId>yoho-message-sender-dal</artifactId> |
22 | </dependency> | 26 | </dependency> |
23 | <dependency> | 27 | <dependency> |
24 | - <groupId>com.yoho.service.model</groupId> | ||
25 | - <artifactId>message-service-model</artifactId> | ||
26 | - </dependency> | 28 | + <groupId>com.yoho.service.model</groupId> |
29 | + <artifactId>message-service-model</artifactId> | ||
30 | + </dependency> | ||
27 | <dependency> | 31 | <dependency> |
28 | <groupId>com.yoho.core</groupId> | 32 | <groupId>com.yoho.core</groupId> |
29 | <artifactId>yoho-core-redis</artifactId> | 33 | <artifactId>yoho-core-redis</artifactId> |
@@ -47,15 +51,15 @@ | @@ -47,15 +51,15 @@ | ||
47 | <version>20150729</version> | 51 | <version>20150729</version> |
48 | </dependency> | 52 | </dependency> |
49 | <dependency> | 53 | <dependency> |
50 | - <groupId>com.cloopen</groupId> | ||
51 | - <artifactId>CCP_REST_SMS_SDK_JAVA</artifactId> | ||
52 | - <version>v2.6.3r</version> | 54 | + <groupId>com.cloopen</groupId> |
55 | + <artifactId>CCP_REST_SMS_SDK_JAVA</artifactId> | ||
56 | + <version>v2.6.3r</version> | ||
53 | </dependency> | 57 | </dependency> |
54 | - <dependency> | ||
55 | - <groupId>com.yoho.core</groupId> | ||
56 | - <artifactId>yoho-core-cache-clean</artifactId> | ||
57 | - </dependency> | ||
58 | - <dependency> | 58 | + <dependency> |
59 | + <groupId>com.yoho.core</groupId> | ||
60 | + <artifactId>yoho-core-cache-clean</artifactId> | ||
61 | + </dependency> | ||
62 | + <dependency> | ||
59 | <groupId>com.xuanwu</groupId> | 63 | <groupId>com.xuanwu</groupId> |
60 | <artifactId>postmsg-ump</artifactId> | 64 | <artifactId>postmsg-ump</artifactId> |
61 | <version>2.4</version> | 65 | <version>2.4</version> |
@@ -12,15 +12,13 @@ import javax.annotation.Resource; | @@ -12,15 +12,13 @@ import javax.annotation.Resource; | ||
12 | 12 | ||
13 | import org.apache.commons.collections.CollectionUtils; | 13 | import org.apache.commons.collections.CollectionUtils; |
14 | import org.apache.commons.lang3.StringUtils; | 14 | import org.apache.commons.lang3.StringUtils; |
15 | -import org.slf4j.Logger; | ||
16 | -import org.slf4j.LoggerFactory; | ||
17 | import org.springframework.beans.factory.annotation.Autowired; | 15 | import org.springframework.beans.factory.annotation.Autowired; |
18 | import org.springframework.stereotype.Service; | 16 | import org.springframework.stereotype.Service; |
19 | 17 | ||
20 | import com.yoho.core.config.ConfigReader; | 18 | import com.yoho.core.config.ConfigReader; |
21 | -import com.yoho.yhmessage.sms.filter.IFilterByCountService; | 19 | +import com.yoho.yhmessage.filter.IFilterByCountService; |
20 | +import com.yoho.yhmessage.filter.IObjectKeyTransfer; | ||
22 | import com.yoho.yhmessage.sms.filter.IFilterUserService; | 21 | import com.yoho.yhmessage.sms.filter.IFilterUserService; |
23 | -import com.yoho.yhmessage.sms.filter.IObjectKeyTransfer; | ||
24 | import com.yoho.yhmessage.sms.util.CommonUtils; | 22 | import com.yoho.yhmessage.sms.util.CommonUtils; |
25 | 23 | ||
26 | /** | 24 | /** |
@@ -32,9 +30,8 @@ import com.yoho.yhmessage.sms.util.CommonUtils; | @@ -32,9 +30,8 @@ import com.yoho.yhmessage.sms.util.CommonUtils; | ||
32 | * @taskId <br> | 30 | * @taskId <br> |
33 | * @CreateDate 2016年12月8日 <br> | 31 | * @CreateDate 2016年12月8日 <br> |
34 | */ | 32 | */ |
35 | -@Service("filterUserService") | 33 | +@Service |
36 | public class FilterUserServiceImpl implements IFilterUserService { | 34 | public class FilterUserServiceImpl implements IFilterUserService { |
37 | - private static final Logger log = LoggerFactory.getLogger(FilterUserServiceImpl.class); | ||
38 | 35 | ||
39 | private static final DateFormat df = new SimpleDateFormat("yyyyMMdd"); | 36 | private static final DateFormat df = new SimpleDateFormat("yyyyMMdd"); |
40 | private static final String FREQUENT_USER_KEY_FORMAT = "msgcenter_sms_user_count_%s"; | 37 | private static final String FREQUENT_USER_KEY_FORMAT = "msgcenter_sms_user_count_%s"; |
@@ -42,24 +39,8 @@ public class FilterUserServiceImpl implements IFilterUserService { | @@ -42,24 +39,8 @@ public class FilterUserServiceImpl implements IFilterUserService { | ||
42 | 39 | ||
43 | @Resource(name = "core-config-reader") | 40 | @Resource(name = "core-config-reader") |
44 | private ConfigReader configReader; | 41 | private ConfigReader configReader; |
45 | - | ||
46 | @Autowired | 42 | @Autowired |
47 | private IFilterByCountService filterByCountService; | 43 | private IFilterByCountService filterByCountService; |
48 | - /** | ||
49 | - * | ||
50 | - * Description: 过滤场景<br> | ||
51 | - * | ||
52 | - * @author amos.shan<br> | ||
53 | - * @taskId <br> | ||
54 | - * @return <br> | ||
55 | - */ | ||
56 | - public List<String> getIgnoreMobileCountKeyList() { | ||
57 | - String ignoreMobileCountKeyList = ""; | ||
58 | - if (StringUtils.isBlank(ignoreMobileCountKeyList)) { | ||
59 | - return new ArrayList<String>(); | ||
60 | - } | ||
61 | - return Arrays.asList(ignoreMobileCountKeyList.split(",")); | ||
62 | - } | ||
63 | 44 | ||
64 | private IObjectKeyTransfer<String> getMobileTransfer() { | 45 | private IObjectKeyTransfer<String> getMobileTransfer() { |
65 | return new IObjectKeyTransfer<String>() { | 46 | return new IObjectKeyTransfer<String>() { |
@@ -95,6 +76,27 @@ public class FilterUserServiceImpl implements IFilterUserService { | @@ -95,6 +76,27 @@ public class FilterUserServiceImpl implements IFilterUserService { | ||
95 | 76 | ||
96 | /** | 77 | /** |
97 | * | 78 | * |
79 | + * Description: 过滤累计发送超过五次的用户<br> | ||
80 | + * | ||
81 | + * @author amos.shan<br> | ||
82 | + * @taskId <br> | ||
83 | + * @param mobileList | ||
84 | + * @return <br> | ||
85 | + */ | ||
86 | + public List<String> ignoreFrequentUsers(List<String> mobileList) { | ||
87 | + if (CollectionUtils.isEmpty(mobileList)) { | ||
88 | + return mobileList; | ||
89 | + } | ||
90 | + String redisKey = String.format(FREQUENT_USER_KEY_FORMAT, df.format(new Date())); | ||
91 | + int mobileSendLimit = this.getMobileSendLimit(); | ||
92 | + List<String> mobileWhiteList = this.getMobileWhiteList(); | ||
93 | + List<String> filtedResults = filterByCountService.batchFilter(redisKey, mobileList, mobileWhiteList, this.getMobileTransfer(), mobileSendLimit, 24 * 60 * 60, | ||
94 | + TimeUnit.SECONDS); | ||
95 | + return filtedResults; | ||
96 | + } | ||
97 | + | ||
98 | + /** | ||
99 | + * | ||
98 | * Description: 过滤mobile白名单<br> | 100 | * Description: 过滤mobile白名单<br> |
99 | * | 101 | * |
100 | * @author amos.shan<br> | 102 | * @author amos.shan<br> |
@@ -111,34 +113,29 @@ public class FilterUserServiceImpl implements IFilterUserService { | @@ -111,34 +113,29 @@ public class FilterUserServiceImpl implements IFilterUserService { | ||
111 | 113 | ||
112 | /** | 114 | /** |
113 | * | 115 | * |
114 | - * Description: 过滤累计发送超过五次的用户<br> | 116 | + * Description: 发送次数限制<br> |
115 | * | 117 | * |
116 | * @author amos.shan<br> | 118 | * @author amos.shan<br> |
117 | * @taskId <br> | 119 | * @taskId <br> |
118 | - * @param mobileList | ||
119 | * @return <br> | 120 | * @return <br> |
120 | */ | 121 | */ |
121 | - public List<String> ignoreFrequentUsers(List<String> mobileList) { | ||
122 | - if (CollectionUtils.isEmpty(mobileList)) { | ||
123 | - return mobileList; | ||
124 | - } | ||
125 | - String redisKey = String.format(FREQUENT_USER_KEY_FORMAT, df.format(new Date())); | ||
126 | - int mobileSendLimit = this.getMobileSendLimit(); | ||
127 | - List<String> mobileWhiteList = this.getMobileWhiteList(); | ||
128 | - List<String> filtedResults = filterByCountService.batchFilter(redisKey, mobileList, mobileWhiteList, this.getMobileTransfer(), mobileSendLimit, 24 * 60 * 60, | ||
129 | - TimeUnit.SECONDS); | ||
130 | - return filtedResults; | 122 | + private int getMobileSendLimit() { |
123 | + return configReader.getInt("msgcenter.sms.degrade.userSendLimit", 50); | ||
131 | } | 124 | } |
132 | - | 125 | + |
133 | /** | 126 | /** |
134 | * | 127 | * |
135 | - * Description: 发送次数限制<br> | 128 | + * Description: 过滤场景<br> |
136 | * | 129 | * |
137 | * @author amos.shan<br> | 130 | * @author amos.shan<br> |
138 | * @taskId <br> | 131 | * @taskId <br> |
139 | * @return <br> | 132 | * @return <br> |
140 | */ | 133 | */ |
141 | - private int getMobileSendLimit() { | ||
142 | - return configReader.getInt("msgcenter.sms.degrade.userSendLimit", 5); | 134 | + public List<String> getIgnoreMobileCountKeyList() { |
135 | + String ignoreMobileCountKeyList = ""; | ||
136 | + if (StringUtils.isBlank(ignoreMobileCountKeyList)) { | ||
137 | + return new ArrayList<String>(); | ||
138 | + } | ||
139 | + return Arrays.asList(ignoreMobileCountKeyList.split(",")); | ||
143 | } | 140 | } |
144 | } | 141 | } |
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
3 | + xmlns:p="http://www.springframework.org/schema/p" xmlns="http://www.springframework.org/schema/beans" | ||
4 | + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> | ||
5 | + | ||
6 | + <!-- pool config --> | ||
7 | + <bean id="pushJedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig"> | ||
8 | + <property name="maxTotal" value="${redis.pool.maxTotal:50}" /> | ||
9 | + <property name="maxIdle" value="${redis.pool.maxIdle:20}" /> | ||
10 | + <property name="minIdle" value="${redis.pool.minIdle:20}"/> | ||
11 | + <property name="maxWaitMillis" value="${redis.pool.maxWaitMillis:2000}" /> | ||
12 | + <property name="testOnBorrow" value="${redis.pool.testOnBorrow:false}" /> | ||
13 | + <property name="testWhileIdle" value="${redis.pool.testWhileIdle:false}"/> | ||
14 | + </bean> | ||
15 | + | ||
16 | + <bean id="pushRedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"> | ||
17 | + <property name="poolConfig" ref="pushJedisPoolConfig" /> | ||
18 | + <property name="port" value="${redis.push.port}" /> | ||
19 | + <property name="hostName" value="${redis.push.address}" /> | ||
20 | + <property name="password" value="${redis.push.auth}"/> | ||
21 | + <property name="timeout" value="1000"></property> | ||
22 | + </bean> | ||
23 | + | ||
24 | + <bean id="pushRedisTemplate" class="org.springframework.data.redis.core.RedisTemplate"> | ||
25 | + <property name="connectionFactory" ref="pushRedisConnectionFactory" /> | ||
26 | + <property name="keySerializer"> | ||
27 | + <bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/> | ||
28 | + </property> | ||
29 | + <property name="valueSerializer"> | ||
30 | + <bean class="org.springframework.data.redis.serializer.StringRedisSerializer" /> | ||
31 | + </property> | ||
32 | + </bean> | ||
33 | + | ||
34 | +</beans> |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | #msgcenter.sms.degrade.ignoreUserCountKeyList= | 4 | #msgcenter.sms.degrade.ignoreUserCountKeyList= |
5 | 5 | ||
6 | #search open personalized[true:open personalized, false:close personalized] | 6 | #search open personalized[true:open personalized, false:close personalized] |
7 | -msgcenter.sms.degrade.userSendLimit=5 | 7 | +msgcenter.sms.degrade.userSendLimit=50 |
8 | 8 | ||
9 | #search.open.descorebrand[true:open descorebrand, false:close descorebrand] | 9 | #search.open.descorebrand[true:open descorebrand, false:close descorebrand] |
10 | msgcenter.sms.degrade.mobileWhiteList=18751886435 | 10 | msgcenter.sms.degrade.mobileWhiteList=18751886435 |
-
Please register or login to post a comment