本文整理汇总了Java中com.hazelcast.core.Message.getMessageObject方法的典型用法代码示例。如果您正苦于以下问题:Java Message.getMessageObject方法的具体用法?Java Message.getMessageObject怎么用?Java Message.getMessageObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hazelcast.core.Message
的用法示例。
在下文中一共展示了Message.getMessageObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onMessage
import com.hazelcast.core.Message; //导入方法依赖的package包/类
@Override
public void onMessage(final Message<CacheEvictionEvent> message) {
CacheEvictionEvent event = message.getMessageObject();
if (LOG.isDebugEnabled()) {
LOG.debug("Received cache eviction event: " + event);
}
Ehcache cache = cacheManager.getEhcache(event.getName());
// No need to evict something in a cache which was not yet created
if (cache != null) {
Object key = event.getKey();
if (key == null) {
cache.removeAll(true);
} else {
cache.remove(key, true);
}
}
}
示例2: onMessage
import com.hazelcast.core.Message; //导入方法依赖的package包/类
@Override
public void onMessage(Message<ChatMessage> event) {
System.out.println("HZ ChatMessage Topic Listener invoked");
ChatMessage msg = event.getMessageObject();
Predicate<Session> filterCriteria = null;
if (!msg.isPrivate()) {
//for ALL (except self)
filterCriteria = (session) -> !session.getUserProperties().get("user").equals(msg.from());
} else {
String privateRecepient = msg.getRecepient();
//private IM
filterCriteria = (session) -> privateRecepient.equals(session.getUserProperties().get("user"));
}
ChatServer.getSessions().stream()
.filter(filterCriteria)
.forEach((session) -> session.getAsyncRemote().sendObject(new Reply(msg.getMsg(), msg.from(), msg.isPrivate())));
}
开发者ID:abhirockzz,项目名称:scalable-websocket-chat-with-hazelcast,代码行数:21,代码来源:ChatMessageEventListener.java
示例3: onMessage
import com.hazelcast.core.Message; //导入方法依赖的package包/类
@Override
public void onMessage(Message<SessionDataDTO> sessionDataDTOMessage) {
SessionDataDTO sessionDataDTO = sessionDataDTOMessage.getMessageObject();
try {
String thisServer = IpAddresssUtil.getLocalHostAddress();
for (SessionDiscoveryCallback callback : callBacks) {
String location = sessionDataDTO.getLocation();
if (thisServer.equals(location)) {
if (LOG.isDebugEnabled()) LOG.debug("Ignoring session discovery message as it originated on this server");
continue;
} else {
if (LOG.isDebugEnabled()) LOG.debug("Updating with session discovery message on this server");
callback.update(sessionDataDTO);
}
}
} catch (Exception e) {
LOG.error("Failed to act on message", e);
}
}
示例4: onMessage
import com.hazelcast.core.Message; //导入方法依赖的package包/类
@Override
public void onMessage(Message<byte[]> message) {
if(closed)
return;
if(message.getPublishingMember().localMember())
{
log.debug("Ignoring bytes received from self..");
return;
}
byte[] bytesRecvd = message.getMessageObject();
log.debug("Got bytes of length- "+bytesRecvd.length);
try
{
handleBytesReceived(bytesRecvd);
}
finally
{
}
}
示例5: progressFlowMessage
import com.hazelcast.core.Message; //导入方法依赖的package包/类
@Override
public void progressFlowMessage(Message<FlowMessage> Message) {//处理流表订阅消息
FlowMessage flowMessage = Message.getMessageObject();
Map<String,Object> rawValues = new HashMap<String,Object>();
String json = flowMessage.json;
System.out.println(json);
try {
rawValues = FlowEntryPushUtil.jsonToStorageEntry(json);
int state = FlowEntryPushUtil.checkFlow(rawValues);
if(state == 0 ){
storageSourceService.insertRowAsync(StaticFlowEntryPusher.TABLE_NAME, rawValues);
}
} catch (IOException e) {
e.printStackTrace();
}
}
示例6: onMessage
import com.hazelcast.core.Message; //导入方法依赖的package包/类
public void onMessage(Message<ClusterEvent> message) {
long start = System.currentTimeMillis() ;
ClusterEvent event = message.getMessageObject() ;
Timer.Context timeCtx = appMonitor.timer("event", event.getType().toString()).time() ;
logger.info("Start onMessage(...), event = " + event.getType());
for(int i = 0; i < listeners.size(); i++) {
ClusterListener<Server> listener = listeners.get(i) ;
listener.onEvent(server, event) ;
}
long end = System.currentTimeMillis() ;
String msg = "Received an event " + event.getType() + " " + event.getSource() + " from " + event.getSourceMember().toString();
String activityLogName = event.getType().toString() ;
timeCtx.stop() ;
ActivityLog log = new ActivityLog(activityLogName, ActivityLog.Type.ClusterEvent, start, end, msg) ;
server.getActivityLogs().add(log);
logger.info(log.toString());
logger.info("Finish onMessage(...), event = " + event.getType());
}
示例7: onMessage
import com.hazelcast.core.Message; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void onMessage(Message message) {
//TODO: do we need to handle this only for non-local members?
ClusterNotification clusterNotification = (ClusterNotification) message.getMessageObject();
if (log.isDebugEnabled()) {
log.debug("Handling cluster gossip: received a DB sync request " + clusterNotification
.getEncodedObjectAsString());
}
log.info("DB sync request received after a split brain recovery from cluster " + message
.getPublishingMember());
for (DBSyncNotificationHandler dbSyncNotificationListener : dbSyncNotificationListeners) {
dbSyncNotificationListener.handleClusterNotification(clusterNotification);
}
log.info("DB sync completed for the request from cluster " + message.getPublishingMember());
}
示例8: onMessage
import com.hazelcast.core.Message; //导入方法依赖的package包/类
@Override
public void onMessage(Message<HazelcastMsg> msg) {
ByteBuf payload = null;
try {
if (!msg.getPublishingMember().equals(server.getHazelcastInstance().getCluster().getLocalMember())) {
HazelcastMsg hzMsg = msg.getMessageObject();
LOG.info("{} received from hazelcast for topic {} message: {}", hzMsg.getClientId(), hzMsg.getTopic(),
hzMsg.getPayload());
// TODO pass forward this information in somehow publishMessage.setLocal(false);
MqttQoS qos = MqttQoS.valueOf(hzMsg.getQos());
MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.PUBLISH, false, qos, false, 0);
MqttPublishVariableHeader varHeader = new MqttPublishVariableHeader(hzMsg.getTopic(), 0);
payload = Unpooled.wrappedBuffer(hzMsg.getPayload());
MqttPublishMessage publishMessage = new MqttPublishMessage(fixedHeader, varHeader, payload);
server.internalPublish(publishMessage, hzMsg.getClientId());
}
} catch (Exception ex) {
LOG.error("error polling hazelcast msg queue", ex);
} finally {
ReferenceCountUtil.release(payload);
}
}
示例9: onMessage
import com.hazelcast.core.Message; //导入方法依赖的package包/类
@Override
public void onMessage(Message<MessageEntity> message) {
String threadId = message.getMessageObject().thread;
Long previousValue = values.get(threadId);
if (previousValue == null) {
previousValue = 0L;
}
long actualValue = message.getMessageObject().value;
long expectedValue = previousValue + 1;
if (expectedValue != actualValue) {
failures.incrementAndGet();
ExceptionReporter.report(testContext.getTestId(), new TestException(format(
"There is an unexpected gap or equality between values. Expected %d, but was %d",
expectedValue, actualValue)));
}
values.put(threadId, actualValue);
if (received.getAndIncrement() % 100000 == 0) {
logger.info(toString() + " is at " + message.getMessageObject().toString());
}
}
示例10: createMessageListener
import com.hazelcast.core.Message; //导入方法依赖的package包/类
protected MessageListener<Object> createMessageListener() {
return new MessageListener<Object>() {
public void onMessage(final Message<Object> message) {
final Invalidation invalidation = (Invalidation) message.getMessageObject();
if (versionComparator != null) {
final Value value = cache.get(invalidation.getKey());
if (value != null) {
Object currentVersion = value.getVersion();
Object newVersion = invalidation.getVersion();
if (versionComparator.compare(newVersion, currentVersion) > 0) {
cache.remove(invalidation.getKey(), value);
}
}
} else {
cache.remove(invalidation.getKey());
}
}
};
}
开发者ID:health-and-care-developer-network,项目名称:health-and-care-developer-network,代码行数:20,代码来源:LocalRegionCache.java
示例11: onMessage
import com.hazelcast.core.Message; //导入方法依赖的package包/类
@Override
public void onMessage(Message<LogOutNotification> event) {
System.out.println("HZ Logout notification Topic Listener invoked");
LogOutNotification msg = event.getMessageObject();
ChatServer.getSessions().stream()
.filter((sn) -> sn.isOpen())
.forEach((session) -> session.getAsyncRemote().sendObject(msg));
}
开发者ID:abhirockzz,项目名称:scalable-websocket-chat-with-hazelcast,代码行数:10,代码来源:LogoutNotificationEventListener.java
示例12: onMessage
import com.hazelcast.core.Message; //导入方法依赖的package包/类
@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]
}
示例13: onMessage
import com.hazelcast.core.Message; //导入方法依赖的package包/类
@Override
public void onMessage(Message<Byte> message) {
log.debug("Message received from Member:: ["+message.getPublishingMember()+"] "+message.getMessageObject());
switch (message.getMessageObject())
{
case DUMP_MODEL_REQ:
dumpClassifierSnapshot();
break;
case DUMP_MODEL_RES:
notifyIfProcessing();
break;
default:
break;
}
}
示例14: onMessage
import com.hazelcast.core.Message; //导入方法依赖的package包/类
@Override
public void onMessage(Message<Byte> message)
{
if(message.getPublishingMember().localMember())
return;
switch(message.getMessageObject())
{
case SEND_FILE_ACK:
if (awaitingFileSendAck) {
latch.countDown();
}
break;
case SEND_FILE:
startFileConsumingTask();
break;
case RECV_FILE_ACK:
if (awaitingFileReceiptAck) {
latch.countDown();
}
break;
case RECV_FILE_ERR:
if (awaitingFileReceiptAck) {
sharingErrorCount.incrementAndGet();
fileReceiptErrored.add(message.getPublishingMember());
latch.countDown();
log.error("*** RECV_FILE_ERR ***");
}
break;
default: break;
}
}
示例15: progressRoleMessage
import com.hazelcast.core.Message; //导入方法依赖的package包/类
@Override
public void progressRoleMessage(Message<RoleMessage> message) {//处理角色请求订阅消息
RoleMessage roleMessage = message.getMessageObject();
String switchId = roleMessage.SwitchId;
DatapathId dpid = DatapathId.of(switchId);// 得到请求交换机机id
IOFSwitch sw = switchService.getSwitch(dpid);// 得到交换机
OFControllerRole controllerRole = parseRole(roleMessage.Role);
sw.writeRequest(sw.getOFFactory()
.buildRoleRequest()
.setGenerationId(U64.ZERO)
.setRole(controllerRole).
build());
}