diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/PushMessageServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/PushMessageServiceImpl.java index 4d7a943..b094107 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/PushMessageServiceImpl.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/PushMessageServiceImpl.java @@ -36,6 +36,7 @@ import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.FutureTask; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; /** @@ -112,14 +113,20 @@ public class PushMessageServiceImpl implements IMessageService { * @param tenantId 租户ID * @return 推送结果 */ - public R sendAndroidMsg(String subject,String content,List userIds,String tenantId) { + public synchronized R sendAndroidMsg(String subject,String content,List userIds,String tenantId) { PushInfoVO pushInfoVO = new PushInfoVO(); PushPlatform pushPlatform = PushPlatform.newBuilder().addPlatformType(PlatformType.Android).build(); PushAudience pushAudience = PushAudience.newBuilder().addPushAudienceType(PushAudienceType.TAG, userIds).build(); PushInfo pushInfo = new PushInfo("ops-push-android", subject, content,"", null, pushPlatform, pushAudience); pushInfoVO.setPushInfo(pushInfo); pushInfoVO.setTenantId(tenantId); - return pushClient.tenantPush(pushInfoVO); + R pushResponseR = pushClient.tenantPush(pushInfoVO); + try { + TimeUnit.SECONDS.sleep(1); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + return pushResponseR; } /** @@ -130,13 +137,19 @@ public class PushMessageServiceImpl implements IMessageService { * @param tenantId 租户ID * @return 推送结果 */ - public R sendIOSMsg(String subject,String content,List userIds,String tenantId) { + public synchronized R sendIOSMsg(String subject,String content,List userIds,String tenantId) { PushInfoVO pushInfoVO = new PushInfoVO(); PushPlatform pushPlatform = PushPlatform.newBuilder().addPlatformType(PlatformType.IOS).build(); PushAudience pushAudience = PushAudience.newBuilder().addPushAudienceType(PushAudienceType.TAG, userIds).build(); PushInfo pushInfo = new PushInfo("ops-push-ios", subject, content,"", null, pushPlatform, pushAudience); pushInfoVO.setPushInfo(pushInfo); pushInfoVO.setTenantId(tenantId); - return pushClient.tenantPush(pushInfoVO); + R pushResponseR = pushClient.tenantPush(pushInfoVO); + try { + TimeUnit.SECONDS.sleep(1); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + return pushResponseR; } }