/** Notify within transaction. */ private void handleNotify(NotifyMessage message) { Validate.notNull(message); WeiXinService.WEIXIN_LOG.info("Handle notify: " + message); try { String url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" + accessTokenManager.getAccessToken(); WeiXinResponse response = WeiXinUtils.post(url, message.getContent()); if (response != null) { log.debug(response); if (response.errcode == WeiXinResponse.CODE_OK) { return; } if (response.errcode == WeiXinResponse.CODE_INVALID_CREDENTIAL) { accessTokenManager.updateAccessToken(); } } else { log.warn("Null weixin response: message=" + message); } } catch (Exception e) { log.error("Notify subscriber failed: message=" + message, e); } /* * re-notify */ message.setLazy(true); notifySubscriber(message); }
public void notifySubscriber(NotifyMessage message) { // if (!weiXinAdminService.isAdmin(openId)) { // WeiXinService.WEIXIN_LOG.info(message); // return; // } Validate.notNull(message); if (message.isLazy()) { if (!queue.offer(message)) { log.error("Enqueue failed: " + message); } } else { handleNotify(message); } }