当前位置: 首页>>代码示例>>Java>>正文


Java Message类代码示例

本文整理汇总了Java中com.hazelcast.core.Message的典型用法代码示例。如果您正苦于以下问题:Java Message类的具体用法?Java Message怎么用?Java Message使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Message类属于com.hazelcast.core包,在下文中一共展示了Message类的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);
        }
    }
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:18,代码来源:HazelcastCacheManagerPeerProvider.java

示例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);
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:21,代码来源:HazelcastSessionDiscoveryEventListener.java

示例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
  {
    
  }
  
  
}
 
开发者ID:javanotes,项目名称:reactive-data,代码行数:24,代码来源:DistributedPipedInputStream.java

示例5: onMessage

import com.hazelcast.core.Message; //导入依赖的package包/类
@Override
public void onMessage(final Message<FileChunk> message) {
  if(message.getPublishingMember().localMember())
  {
    return;
  }
  if(isMarkDiscard()){
    //log.debug(message.getMessageObject()+"");
    discardChunks++;
    return;
  }
  try 
  {
    boolean offered = queue.offer(message.getMessageObject(), 10, TimeUnit.SECONDS);
    if(!offered)
      log.error("Chunk lost. Unable to queue even after waiting 10 secs!");
    
  } catch (InterruptedException e) {
    Thread.currentThread().interrupt();

  }
  
}
 
开发者ID:javanotes,项目名称:reactive-data,代码行数:24,代码来源:FileChunkReceiver.java

示例6: shouldUseClusterTimestampFromInvalidationmessageInsteadOfSystemTime

import com.hazelcast.core.Message; //导入依赖的package包/类
@Test
public void shouldUseClusterTimestampFromInvalidationmessageInsteadOfSystemTime() {
    long firstTimestamp = 1;
    long secondTimestamp = 2;
    long publishTime = 3;
    long clusterTime = 4;

    when(cluster.getClusterTime()).thenReturn(firstTimestamp, secondTimestamp);

    // cache is primed by call, that uses clusterTime instead of system clock for timestamp
    assertThat(target.put("QuerySpace", firstTimestamp, firstTimestamp, null), is(true));

    assertThat("primed value should be in the cache", (Long)target.get("QuerySpace", firstTimestamp), is(firstTimestamp));

    // a message is generated on a different cluster member informing us to update the timestamp region cache
    Message<Object> message = new Message<Object>("topicName", new Timestamp("QuerySpace", secondTimestamp), publishTime, member);

    // process the timestamp region update
    listener.onMessage(message);

    // this fails if we use system time instead of cluster time, causing the value to stay invisible until clustertime == system time (which it often isn't)
    assertThat("key should be visible and have value specified in timestamp message, with current cluster time.", (Long)target.get("QuerySpace", clusterTime), is(secondTimestamp));
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate5,代码行数:24,代码来源:TimestampsRegionCacheTest.java

示例7: shouldUseClusterTimestampFromInvalidationmessageInsteadOfSystemTime

import com.hazelcast.core.Message; //导入依赖的package包/类
@Test
public void shouldUseClusterTimestampFromInvalidationmessageInsteadOfSystemTime() {
    long firstTimestamp = 1;
    long secondTimestamp = 2;
    long publishTime = 3;
    long clusterTime = 4;

    when(cluster.getClusterTime()).thenReturn(firstTimestamp, secondTimestamp);

    // cache is primed by call, that uses clusterTime instead of system clock for timestamp
    assertThat(target.put("QuerySpace", firstTimestamp, firstTimestamp, null), is(true));

    assertThat("primed value should be in the cache", (Long)target.get("QuerySpace", firstTimestamp), is(firstTimestamp));

    // a message is generated on a different cluster member informing us to update the timestamp region cache
    Message<Object> message = new Message<Object>("topicName", new Timestamp("QuerySpace", secondTimestamp), publishTime, member);
    
    // process the timestamp region update
    listener.onMessage(message);

    // this fails if we use system time instead of cluster time, causing the value to stay invisible until clustertime == system time (which it often isn't)
    assertThat("key should be visible and have value specified in timestamp message, with current cluster time.", (Long)target.get("QuerySpace", clusterTime), is(secondTimestamp));
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate,代码行数:24,代码来源:TimestampsRegionCacheTest.java

示例8: onMessage

import com.hazelcast.core.Message; //导入依赖的package包/类
@Override
public void onMessage(final Message<DashboardNotificationEvent> message) {
    try {
        hybridbpmUI.access(new Runnable() {
            @Override
            public void run() {
                DashboardNotificationEvent event = message.getMessageObject();
                switch (event.getAction()) {
                    case SHOW:
                        hybridbpmUI.getMainMenu().changeNotification(event.getViewUrl(), true, event.getMessage());
                        break;
                    case REMOVE:
                        hybridbpmUI.getMainMenu().changeNotification(event.getViewUrl(), false, null);
                        break;
                }

                hybridbpmUI.push();
            }
        });
    } catch (Exception ex) {
        logger.log(Level.SEVERE, ex.getMessage(), ex);
    }
}
 
开发者ID:hybridbpm,项目名称:hybridbpm,代码行数:24,代码来源:DashBoardNotificationMessageListener.java

示例9: 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();
	}
}
 
开发者ID:DaiDongLiang,项目名称:DSC,代码行数:18,代码来源:HazelcastService.java

示例10: onMessage

import com.hazelcast.core.Message; //导入依赖的package包/类
@Override
public void onMessage(final Message<Event> eventMessage) {
    lockTemplate.lock(() -> {
        final Event event = eventMessage.getMessageObject();
        if (synced) {
            log.debug("Recording event [id={}]", event.id());
            recordEventStore.append(eventMessage.getMessageObject());
            if (!isSyncRequest(event)) {
                playbackQueue.add(event);
            }
        } else {
            if (!isSyncRequest(event)) {
                tempPlaybackQueue.add(event);
            }
        }
    });
}
 
开发者ID:wassgren,项目名称:NoMQ,代码行数:18,代码来源:NoMQMessageListener.java

示例11: postRegister

import com.hazelcast.core.Message; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void postRegister(Boolean registrationDone) {
    super.postRegister(registrationDone);
    if (!registrationDone) {
        return;
    }
    if (managementService.showDetails()) {
        servedStats = ManagementService.newStatisticsCollector();
        listener = new MessageListener() {

            public void onMessage(Message msg) {
                servedStats.addEvent();
            }
        };
        getManagedObject().addMessageListener(listener);
    }
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:19,代码来源:TopicMBean.java

示例12: addMessageListener

import com.hazelcast.core.Message; //导入依赖的package包/类
@Test
public void addMessageListener() throws InterruptedException {
    HazelcastClient hClient = getHazelcastClient();
    ITopic<String> topic = hClient.getTopic("addMessageListener");
    final CountDownLatch latch = new CountDownLatch(1);
    final String message = "Hazelcast Rocks!";
    topic.addMessageListener(new MessageListener<String>() {
        public void onMessage(Message<String> msg) {
            if (msg.getMessageObject().equals(message)) {
                latch.countDown();
            }
        }
    });
    topic.publish(message);
    assertTrue(latch.await(10000, TimeUnit.MILLISECONDS));
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:17,代码来源:HazelcastClientTopicTest.java

示例13: removeMessageListener

import com.hazelcast.core.Message; //导入依赖的package包/类
@Test
    public void removeMessageListener() throws InterruptedException {
        HazelcastClient hClient = getHazelcastClient();
        ITopic<String> topic = hClient.getTopic("removeMessageListener");
        final CountDownLatch latch = new CountDownLatch(2);
        final CountDownLatch cp = new CountDownLatch(1);
//        final String message = "Hazelcast Rocks!";
        MessageListener<String> messageListener = new MessageListener<String>() {
            public void onMessage(Message<String> msg) {
//                if (msg.startsWith(message)) {
                System.out.println("Received " + msg + " at " + this);
                latch.countDown();
                cp.countDown();
//                }
            }
        };
        final String message = "message_" + messageListener.hashCode() + "_";
        topic.addMessageListener(messageListener);
        topic.publish(message + "1");
        cp.await();
        topic.removeMessageListener(messageListener);
        topic.publish(message + "2");
        Thread.sleep(50);
        assertEquals(1, latch.getCount());
    }
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:26,代码来源:HazelcastClientTopicTest.java

示例14: testRemoveMessageListener

import com.hazelcast.core.Message; //导入依赖的package包/类
@Test
public void testRemoveMessageListener() throws Exception {
    MessageListenerManager manager = new MessageListenerManager();
    String name = "default";
    assertTrue(manager.noListenerRegistered(name));
    MessageListener listener = new MessageListener<Object>() {

        public void onMessage(Message<Object> message) {
        }
    };
    manager.registerListener(name, listener);
    assertFalse(manager.noListenerRegistered(name));
    manager.removeListener(name, listener);
    assertTrue(manager.noListenerRegistered(name));
    manager.removeListener(name, listener);
    assertTrue(manager.noListenerRegistered(name));
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:18,代码来源:MessageListenerManagerTest.java

示例15: 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());
}
 
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:19,代码来源:HazelcastClusterService.java


注:本文中的com.hazelcast.core.Message类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。