com.hazelcast.core.Message类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中com.hazelcast.core.Message类的一些代码示例,展示了Message类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message类的具体详情如下:
包路径:com.hazelcast.core.Message
类名称:Message

Message介绍

[英]Message for ITopic.
[中]给ITopic的留言。

代码示例

代码示例来源:origin: mrniko/netty-socketio

  1. @Override
  2. public void onMessage(Message<T> message) {
  3. PubSubMessage msg = message.getMessageObject();
  4. if (!nodeId.equals(msg.getNodeId())) {
  5. listener.onMessage(message.getMessageObject());
  6. }
  7. }
  8. });

代码示例来源:origin: io.snamp/internal-services

  1. private static HazelcastNodeInfo getHazelcastNodeInfo(final Message<TransferObject> hzMessage){
  2. return new HazelcastNodeInfo(hzMessage.getPublishingMember(), hzMessage.getMessageObject().isSenderActive, hzMessage.getMessageObject().senderName);
  3. }

代码示例来源:origin: spring-projects/spring-integration-extensions

  1. @Override
  2. protected org.springframework.messaging.Message<?> toMessage(Message<E> event) {
  3. Assert.notNull(event.getMessageObject(), "message must not be null");
  4. final Map<String, Object> headers = new HashMap<>();
  5. headers.put(HazelcastHeaders.MEMBER, event.getPublishingMember().getSocketAddress());
  6. headers.put(HazelcastHeaders.CACHE_NAME, event.getSource());
  7. headers.put(HazelcastHeaders.PUBLISHING_TIME, event.getPublishTime());
  8. return getMessageBuilderFactory().withPayload(event.getMessageObject()).copyHeaders(headers).build();
  9. }

代码示例来源:origin: tfredrich/Domain-Eventing

  1. @Override
  2. public void onMessage(Message<Object> message)
  3. {
  4. System.out.println("Message received: " + message.toString());
  5. if (handler.handles(message.getMessageObject().getClass()))
  6. {
  7. processEvent(message.getMessageObject());
  8. }
  9. }

代码示例来源:origin: hazelcast/hazelcast-jet

  1. @Override
  2. public void onMessage(Message message) {
  3. if (!endpoint.isAlive()) {
  4. return;
  5. }
  6. if (!(message instanceof DataAwareMessage)) {
  7. throw new IllegalArgumentException("Expecting: DataAwareMessage, Found: "
  8. + message.getClass().getSimpleName());
  9. }
  10. DataAwareMessage dataAwareMessage = (DataAwareMessage) message;
  11. Data messageData = dataAwareMessage.getMessageData();
  12. String publisherUuid = message.getPublishingMember().getUuid();
  13. ClientMessage eventMessage = TopicAddMessageListenerCodec.encodeTopicEvent(messageData,
  14. message.getPublishTime(), publisherUuid);
  15. boolean isMultithreaded = nodeEngine.getConfig().findTopicConfig(parameters.name).isMultiThreadingEnabled();
  16. if (isMultithreaded) {
  17. int key = rand.nextInt();
  18. int partitionId = hashToIndex(key, nodeEngine.getPartitionService().getPartitionCount());
  19. eventMessage.setPartitionId(partitionId);
  20. sendClientMessage(eventMessage);
  21. } else {
  22. sendClientMessage(partitionKey, eventMessage);
  23. }
  24. }
  25. }

代码示例来源:origin: spring-projects/spring-integration-extensions

  1. @Override
  2. protected void processEvent(Message<E> event) {
  3. sendMessage(event, event.getPublishingMember().getSocketAddress(), getCacheListeningPolicy());
  4. if (logger.isDebugEnabled()) {
  5. logger.debug("Received Message : " + event);
  6. }
  7. }

代码示例来源:origin: io.snamp/internal-services

  1. /**
  2. * Gets publication time of this message in Unix time format.
  3. *
  4. * @return Publication time of this message in Unix time format.
  5. */
  6. @Override
  7. public long getTimeStamp() {
  8. return hzMessage.getPublishTime();
  9. }

代码示例来源:origin: kaazing/gateway

  1. @Override
  2. public void publish(E o) {
  3. if (isPublishing.get()) {
  4. throw new UnsupportedOperationException("Cannot nest publishing operations");
  5. }
  6. isPublishing.set(true);
  7. Message<E> m = new Message<>(this.getName(), o, System.nanoTime(), null);
  8. if (LOGGER.isTraceEnabled()) {
  9. LOGGER.trace("Publishing message on topic: " + MemoryTopic.this.getName() + ", notifying " + messageListenerHolders.size() + " listener(s).");
  10. }
  11. for (MessageListenerHolder holder : messageListenerHolders) {
  12. try {
  13. if (LOGGER.isTraceEnabled()) {
  14. LOGGER.trace("Publishing message on topic: " + MemoryTopic.this.getName() + ", notifying listener: " + holder.key + ".");
  15. }
  16. localTopicStats.incrementReceives();
  17. holder.listener.onMessage(m);
  18. } catch (Exception e) {
  19. LOGGER.debug("Message listener: " + holder.key + " failed.", e);
  20. }
  21. }
  22. localTopicStats.incrementPublishes();
  23. isPublishing.set(false);
  24. }

代码示例来源:origin: com.jtbdevelopment.core-games/games-hazelcast

  1. @Override
  2. public void onMessage(final Message<ClusterMessage> message) {
  3. if (message != null && !message.getPublishingMember().localMember()) {
  4. ClusterMessage clusterMessage = message.getMessageObject();
  5. if (clusterMessage != null) {
  6. receiveClusterMessage(clusterMessage);
  7. }
  8. }
  9. }
  10. }

代码示例来源:origin: com.hazelcast/hazelcast-all

  1. @Override
  2. public void onMessage(Message message) {
  3. if (!endpoint.isAlive()) {
  4. return;
  5. }
  6. if (!(message instanceof DataAwareMessage)) {
  7. throw new IllegalArgumentException("Expecting: DataAwareMessage, Found: "
  8. + message.getClass().getSimpleName());
  9. }
  10. DataAwareMessage dataAwareMessage = (DataAwareMessage) message;
  11. Data messageData = dataAwareMessage.getMessageData();
  12. String publisherUuid = message.getPublishingMember().getUuid();
  13. ClientMessage eventMessage = TopicAddMessageListenerCodec.encodeTopicEvent(messageData,
  14. message.getPublishTime(), publisherUuid);
  15. boolean isMultithreaded = nodeEngine.getConfig().findTopicConfig(parameters.name).isMultiThreadingEnabled();
  16. if (isMultithreaded) {
  17. int key = rand.nextInt();
  18. int partitionId = hashToIndex(key, nodeEngine.getPartitionService().getPartitionCount());
  19. eventMessage.setPartitionId(partitionId);
  20. sendClientMessage(eventMessage);
  21. } else {
  22. sendClientMessage(partitionKey, eventMessage);
  23. }
  24. }
  25. }

代码示例来源:origin: com.atlassian.cache/atlassian-cache-hazelcast

  1. @Override
  2. public void onMessage(Message<ReferenceKey> message) {
  3. CachedReference<?> localReference = localReferenceRef.get();
  4. if (localReference == null)
  5. {
  6. // cache has been gc-d
  7. destroy();
  8. return;
  9. }
  10. if (!message.getPublishingMember().localMember())
  11. {
  12. localReference.reset();
  13. }
  14. }

代码示例来源:origin: hazelcast/hazelcast-jet

  1. private Message<E> toMessage(ReliableTopicMessage m) {
  2. Member member = getMember(m);
  3. E payload = serializationService.toObject(m.getPayload());
  4. return new Message<E>(topicName, payload, m.getPublishTime(), member);
  5. }

代码示例来源:origin: rancher/cattle

  1. @Override
  2. public void onMessage(Message<String> message) {
  3. String eventString = message.getMessageObject();
  4. if (eventString != null) {
  5. onEvent(null, eventName, eventString);
  6. }
  7. }
  8. };

代码示例来源:origin: com.hazelcast/hazelcast-hibernate4

  1. public void onMessage(final Message<Object> message) {
  2. if (!message.getPublishingMember().localMember()) {
  3. maybeInvalidate(message.getMessageObject());
  4. }
  5. }
  6. };

代码示例来源:origin: com.hazelcast/hazelcast-all

  1. private Message<E> toMessage(ReliableTopicMessage m) {
  2. Member member = getMember(m);
  3. E payload = serializationService.toObject(m.getPayload());
  4. return new Message<E>(topicName, payload, m.getPublishTime(), member);
  5. }

代码示例来源:origin: io.snamp/internal-services

  1. /**
  2. * Gets type of this message.
  3. *
  4. * @return Type of this message.
  5. */
  6. @Override
  7. public Communicator.MessageType getType() {
  8. return hzMessage.getMessageObject().messageType;
  9. }

代码示例来源:origin: org.geoserver.community/gs-hz-cluster

  1. @Override
  2. public void onMessage(Message<UUID> message) {
  3. UUID eventId = message.getMessageObject();
  4. AtomicInteger countDown = expectedAckCounters.get(eventId);
  5. if (countDown != null) {
  6. countDown.decrementAndGet();
  7. String originAddr = null;
  8. Member publishingMember = message.getPublishingMember();
  9. if (publishingMember != null) {
  10. InetSocketAddress socketAddress = publishingMember.getSocketAddress();
  11. if (socketAddress != null) {
  12. originAddr = addressString(socketAddress);
  13. }
  14. }
  15. LOGGER.finer(
  16. format("%s - Got ack on event %s from %s", nodeId(), eventId, originAddr));
  17. }
  18. }
  19. }

代码示例来源:origin: Atmosphere/atmosphere-extensions

  1. @Override
  2. public void onMessage(Message<String> message) {
  3. broadcastReceivedMessage(message.getMessageObject());
  4. }
  5. });

代码示例来源:origin: com.atlassian.cache/atlassian-cache-hazelcast

  1. @Override
  2. public void onMessage(Message<K> message) {
  3. Cache<K, ?> localCache = localCacheRef.get();
  4. if (localCache == null)
  5. {
  6. // cache has been gc-d
  7. destroy();
  8. return;
  9. }
  10. if (!message.getPublishingMember().localMember())
  11. {
  12. K key = message.getMessageObject();
  13. if (key == null)
  14. {
  15. localCache.removeAll();
  16. }
  17. else
  18. {
  19. localCache.remove(key);
  20. }
  21. }
  22. }

代码示例来源:origin: io.snamp/internal-services

  1. /**
  2. * Gets payload of the message.
  3. *
  4. * @return Payload of the message.
  5. */
  6. @Override
  7. public Serializable getPayload() {
  8. return hzMessage.getMessageObject().payload;
  9. }

相关文章