6bb94fba3d8ea21e401d1ad491cff33df8740515.svn-base 1021 B

12345678910111213141516171819202122232425262728
  1. package org.jeecg.boot.starter.rabbitmq.event;
  2. import cn.hutool.core.util.ObjectUtil;
  3. import org.jeecg.common.util.SpringContextHolder;
  4. import org.springframework.context.ApplicationListener;
  5. import org.springframework.stereotype.Component;
  6. /**
  7. * 监听远程事件,并分发消息到业务模块消息处理器
  8. */
  9. @Component
  10. public class BaseApplicationEvent implements ApplicationListener<JeecgRemoteApplicationEvent> {
  11. @Override
  12. public void onApplicationEvent(JeecgRemoteApplicationEvent jeecgRemoteApplicationEvent) {
  13. EventObj eventObj = jeecgRemoteApplicationEvent.getEventObj();
  14. if (ObjectUtil.isNotEmpty(eventObj)) {
  15. //获取业务模块消息处理器
  16. JeecgBusEventHandler busEventHandler = SpringContextHolder.getHandler(eventObj.getHandlerName(), JeecgBusEventHandler.class);
  17. if (ObjectUtil.isNotEmpty(busEventHandler)) {
  18. //通知业务模块
  19. busEventHandler.onMessage(eventObj);
  20. }
  21. }
  22. }
  23. }