Java Code Examples for com.hazelcast.core.Message#getMessageObject()

The following examples show how to use com.hazelcast.core.Message#getMessageObject() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClusterMasterListener.java    From youkefu with Apache License 2.0 6 votes vote down vote up
@Override
  public void onMessage(Message<Object> message) {
RPCDataBean rpcDataBean = (RPCDataBean) message.getMessageObject() ;
if(hazelcastInstance!=null && rpcDataBean!=null && !StringUtils.isBlank(rpcDataBean.getHost())) {
	ClusterContext.getInstance().setHost(rpcDataBean.getHost());
	ClusterContext.getInstance().setPort(rpcDataBean.getPort());
	ClusterContext.getInstance().setId(rpcDataBean.getId());
	ClusterContext.getInstance().setStart(rpcDataBean.getStart());
	
	if(hazelcastInstance.getCluster().getLocalMember().getStringAttribute("id").equals(rpcDataBean.getId())) {
		ClusterContext.getInstance().setMaster(true);
	}else {
		ClusterContext.getInstance().setMaster(false);
	}
}
  }
 
Example 2
Source File: JobDetailListener.java    From youkefu with Apache License 2.0 5 votes vote down vote up
@Override
  public void onMessage(Message<Object> message) {
RPCDataBean rpcDataBean = (RPCDataBean) message.getMessageObject() ;
if(rpcDataBean!=null && !StringUtils.isBlank(rpcDataBean.getId())) {
	JobDetail jobDetail = UKDataContext.localJobDetailMap.get(rpcDataBean.getId()) ;
	if(jobDetail!=null) {
		jobDetail.setFetcher(false);
	}
}
  }
 
Example 3
Source File: IMTopicListener.java    From youkefu with Apache License 2.0 5 votes vote down vote up
@Override
  public void onMessage(Message<Object> message) {
RPCDataBean rpcDataBean = (RPCDataBean) message.getMessageObject() ;
if(rpcDataBean!=null && !StringUtils.isBlank(rpcDataBean.getId())) {
	List<SocketIOClient> clents = NettyClients.getInstance().getIMClients().getClients(rpcDataBean.getId()) ;
	if(clents!=null && clents.size() > 0) {
		for(SocketIOClient client : clents){
			client.sendEvent(rpcDataBean.getEvent(), rpcDataBean.getData());
		}
	}
}
  }
 
Example 4
Source File: EntIMTopicListener.java    From youkefu with Apache License 2.0 5 votes vote down vote up
@Override
  public void onMessage(Message<Object> message) {
RPCDataBean rpcDataBean = (RPCDataBean) message.getMessageObject() ;
if(rpcDataBean!=null && !StringUtils.isBlank(rpcDataBean.getId())) {
	List<SocketIOClient> clents = NettyClients.getInstance().getEntIMClients().getClients(rpcDataBean.getId()) ;
	if(clents!=null && clents.size() > 0) {
		for(SocketIOClient client : clents){
			client.sendEvent(rpcDataBean.getEvent(), rpcDataBean.getData());
		}
	}
}
  }
 
Example 5
Source File: CallCenterTopicListener.java    From youkefu with Apache License 2.0 5 votes vote down vote up
@Override
  public void onMessage(Message<Object> message) {
RPCDataBean rpcDataBean = (RPCDataBean) message.getMessageObject() ;
if(rpcDataBean!=null && !StringUtils.isBlank(rpcDataBean.getId())) {
	List<SocketIOClient> clents = NettyClients.getInstance().getCallCenterClients().getClients(rpcDataBean.getId()) ;
	if(clents!=null && clents.size() > 0) {
		for(SocketIOClient client : clents){
			client.sendEvent(rpcDataBean.getEvent(), rpcDataBean.getData());
		}
	}
}
  }
 
Example 6
Source File: AgentTopicListener.java    From youkefu with Apache License 2.0 5 votes vote down vote up
@Override
  public void onMessage(Message<Object> message) {
RPCDataBean rpcDataBean = (RPCDataBean) message.getMessageObject() ;
if(rpcDataBean!=null && !StringUtils.isBlank(rpcDataBean.getId())) {
	List<SocketIOClient> clents = NettyClients.getInstance().getAgentClients().getClients(rpcDataBean.getId()) ;
	if(clents!=null && clents.size() > 0) {
		for(SocketIOClient client : clents){
			client.sendEvent(rpcDataBean.getEvent(), rpcDataBean.getData());
		}
	}
}
  }
 
Example 7
Source File: NameSpaceTopicListener.java    From youkefu with Apache License 2.0 5 votes vote down vote up
@Override
  public void onMessage(Message<Object> message) {
RPCDataBean rpcDataBean = (RPCDataBean) message.getMessageObject() ;
if(rpcDataBean!=null && !StringUtils.isBlank(rpcDataBean.getId())) {
	UKDataContext.getContext().getBean(rpcDataBean.getId() , SocketIONamespace.class) .getBroadcastOperations().sendEvent(rpcDataBean.getEvent(), rpcDataBean.getData());
}
  }
 
Example 8
Source File: Sessions.java    From lannister with Apache License 2.0 5 votes vote down vote up
@Override
public void onMessage(Message<Notification> message) {
	Notification notified = message.getMessageObject();

	Session session = get(notified.clientId());
	if (session == null || !session.isConnected(true)) { return; }

	session.sendPublish(notified.topic(), notified.message());// [MQTT-3.3.1-8],[MQTT-3.3.1-9]
}
 
Example 9
Source File: JobProgressNotifier.java    From batchers with Apache License 2.0 5 votes vote down vote up
@Override
public void onMessage(Message<JobProgressEvent> message) {
    JobProgressEvent slaveProgressEvent = message.getMessageObject();

    int itemsDone = progressCount.addAndGet(slaveProgressEvent.getPercentageComplete());

    int progress = (int) (itemsDone / (employeeCount * 1.0) * 100);
    JobProgressEvent updateProgress = new JobProgressEvent(slaveProgressEvent.getJobStartParams(), slaveProgressEvent.getStepName(), progress);
    eventBus.post(updateProgress);
}
 
Example 10
Source File: MyClusterMessageListener.java    From sctalk with Apache License 2.0 4 votes vote down vote up
@Override
public void onMessage(Message<MyClusterMessage> message) {

    MyClusterMessage clusterMessage = message.getMessageObject();
    Member member = message.getPublishingMember();
    
    logger.debug("Length:{}, ServiceID:{}, CommandID:{}", clusterMessage.getLength(),
            clusterMessage.getServiceId(), clusterMessage.getCommandId());

    // 根据不同的消息,做不同的处理
    // 处理请求分发
    switch (clusterMessage.getServiceId()) {
        case IMBaseDefine.ServiceID.SID_BUDDY_LIST_VALUE:
            this.doBuddyList(clusterMessage.getCommandId(), clusterMessage, member);
            break;
        case IMBaseDefine.ServiceID.SID_MSG_VALUE:
            if (!member.localMember()) {
                // 不处理当前node的消息
                this.doMessage(clusterMessage.getCommandId(), clusterMessage);
            }
            break;
        case IMBaseDefine.ServiceID.SID_OTHER_VALUE:
            this.doOther(clusterMessage.getCommandId(), clusterMessage, member);
            break;
        case IMBaseDefine.ServiceID.SID_SWITCH_SERVICE_VALUE:
            if (!member.localMember()) {
                this.doSwitch(clusterMessage.getCommandId(), clusterMessage);
            }
            break;
        case IMBaseDefine.ServiceID.SID_FILE_VALUE:
            this.doFile(clusterMessage.getCommandId(), clusterMessage);
            break;
        case IMBaseDefine.ServiceID.SID_GROUP_VALUE:
            if (!member.localMember()) {
                this.doGroup(clusterMessage.getCommandId(), clusterMessage);
            }
            break;
        case IMBaseDefine.ServiceID.SID_AVCALL_VALUE:
            this.doWebrtc(clusterMessage.getCommandId(), clusterMessage, member);
            break;
        default:
            logger.warn("暂不支持的服务ID{}", clusterMessage.getServiceId());
            break;
    }
}