Пример #1
0
 @Override
 public void onMessageDo(Map<String, Object> m) throws Exception {
   String type = (String) m.get("type");
   if (ResmMessageListener.TYPE_OBJECT_SYNC.equals(type)) {
     Object text = m.get("id");
     int id = StringUtil.parseInt(text.toString(), -1);
     logger.debug("接收到同步消息:资源ID=" + text);
     if (id > 0) ServiceManager.getResourceUpdateService().syncResource(id);
   } else if (ResmMessageListener.TYPE_CACHE_ADD.equals(type)) {
     String cacheName = (String) m.get("cache");
     Object object = m.get("object");
     CacheableObject obj = (CacheableObject) object;
     logger.debug("接收到缓存增加消息:" + cacheName + " " + obj.getClass().getName());
     obj.onDeserialize();
     obj.dump();
     CacheManager.addCache(cacheName, obj);
   } else if (ResmMessageListener.TYPE_CACHE_REMOVE.equals(type)) {
     String cacheName = (String) m.get("cache");
     Object object = m.get("object");
     CacheableObject obj = (CacheableObject) object;
     logger.debug("接收到缓存删除消息:" + cacheName + " " + obj.getClass().getName());
     obj.onDeserialize();
     obj.dump();
     CacheManager.removeCache(cacheName, obj);
   } else {
     System.out.println(m.get("type"));
   }
 }
Пример #2
0
 @Override
 public void onMessageDo(Message msg) throws Exception {
   String type = msg.getStringProperty("type");
   if (ResmMessageListener.TYPE_OBJECT_SYNC.equals(type)) {
     TextMessage text = (TextMessage) msg;
     int id = StringUtil.parseInt(text.getText(), -1);
     logger.debug("接收到同步消息:资源ID=" + text.getText());
     if (id > 0) ServiceManager.getResourceUpdateService().syncResource(id);
   } else if (ResmMessageListener.TYPE_CACHE_ADD.equals(type)) {
     ObjectMessage object = (ObjectMessage) msg;
     String cacheName = msg.getStringProperty("cache");
     CacheableObject obj = (CacheableObject) object.getObject();
     logger.debug("接收到缓存增加消息:" + cacheName + " " + obj.getClass().getName());
     obj.onDeserialize();
     obj.dump();
     CacheManager.addCache(cacheName, obj);
   } else if (ResmMessageListener.TYPE_CACHE_REMOVE.equals(type)) {
     ObjectMessage object = (ObjectMessage) msg;
     String cacheName = msg.getStringProperty("cache");
     CacheableObject obj = (CacheableObject) object.getObject();
     logger.debug("接收到缓存删除消息:" + cacheName + " " + obj.getClass().getName());
     obj.onDeserialize();
     obj.dump();
     CacheManager.removeCache(cacheName, obj);
   } else {
     System.out.println(msg.toString());
   }
 }