本文整理了Java中com.hazelcast.core.Message
类的一些代码示例,展示了Message
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message
类的具体详情如下:
包路径:com.hazelcast.core.Message
类名称:Message
[英]Message for ITopic.
[中]给ITopic的留言。
代码示例来源:origin: mrniko/netty-socketio
@Override
public void onMessage(Message<T> message) {
PubSubMessage msg = message.getMessageObject();
if (!nodeId.equals(msg.getNodeId())) {
listener.onMessage(message.getMessageObject());
}
}
});
代码示例来源:origin: io.snamp/internal-services
private static HazelcastNodeInfo getHazelcastNodeInfo(final Message<TransferObject> hzMessage){
return new HazelcastNodeInfo(hzMessage.getPublishingMember(), hzMessage.getMessageObject().isSenderActive, hzMessage.getMessageObject().senderName);
}
代码示例来源:origin: spring-projects/spring-integration-extensions
@Override
protected org.springframework.messaging.Message<?> toMessage(Message<E> event) {
Assert.notNull(event.getMessageObject(), "message must not be null");
final Map<String, Object> headers = new HashMap<>();
headers.put(HazelcastHeaders.MEMBER, event.getPublishingMember().getSocketAddress());
headers.put(HazelcastHeaders.CACHE_NAME, event.getSource());
headers.put(HazelcastHeaders.PUBLISHING_TIME, event.getPublishTime());
return getMessageBuilderFactory().withPayload(event.getMessageObject()).copyHeaders(headers).build();
}
代码示例来源:origin: tfredrich/Domain-Eventing
@Override
public void onMessage(Message<Object> message)
{
System.out.println("Message received: " + message.toString());
if (handler.handles(message.getMessageObject().getClass()))
{
processEvent(message.getMessageObject());
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
@Override
public void onMessage(Message message) {
if (!endpoint.isAlive()) {
return;
}
if (!(message instanceof DataAwareMessage)) {
throw new IllegalArgumentException("Expecting: DataAwareMessage, Found: "
+ message.getClass().getSimpleName());
}
DataAwareMessage dataAwareMessage = (DataAwareMessage) message;
Data messageData = dataAwareMessage.getMessageData();
String publisherUuid = message.getPublishingMember().getUuid();
ClientMessage eventMessage = TopicAddMessageListenerCodec.encodeTopicEvent(messageData,
message.getPublishTime(), publisherUuid);
boolean isMultithreaded = nodeEngine.getConfig().findTopicConfig(parameters.name).isMultiThreadingEnabled();
if (isMultithreaded) {
int key = rand.nextInt();
int partitionId = hashToIndex(key, nodeEngine.getPartitionService().getPartitionCount());
eventMessage.setPartitionId(partitionId);
sendClientMessage(eventMessage);
} else {
sendClientMessage(partitionKey, eventMessage);
}
}
}
代码示例来源:origin: spring-projects/spring-integration-extensions
@Override
protected void processEvent(Message<E> event) {
sendMessage(event, event.getPublishingMember().getSocketAddress(), getCacheListeningPolicy());
if (logger.isDebugEnabled()) {
logger.debug("Received Message : " + event);
}
}
代码示例来源:origin: io.snamp/internal-services
/**
* Gets publication time of this message in Unix time format.
*
* @return Publication time of this message in Unix time format.
*/
@Override
public long getTimeStamp() {
return hzMessage.getPublishTime();
}
代码示例来源:origin: kaazing/gateway
@Override
public void publish(E o) {
if (isPublishing.get()) {
throw new UnsupportedOperationException("Cannot nest publishing operations");
}
isPublishing.set(true);
Message<E> m = new Message<>(this.getName(), o, System.nanoTime(), null);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Publishing message on topic: " + MemoryTopic.this.getName() + ", notifying " + messageListenerHolders.size() + " listener(s).");
}
for (MessageListenerHolder holder : messageListenerHolders) {
try {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Publishing message on topic: " + MemoryTopic.this.getName() + ", notifying listener: " + holder.key + ".");
}
localTopicStats.incrementReceives();
holder.listener.onMessage(m);
} catch (Exception e) {
LOGGER.debug("Message listener: " + holder.key + " failed.", e);
}
}
localTopicStats.incrementPublishes();
isPublishing.set(false);
}
代码示例来源:origin: com.jtbdevelopment.core-games/games-hazelcast
@Override
public void onMessage(final Message<ClusterMessage> message) {
if (message != null && !message.getPublishingMember().localMember()) {
ClusterMessage clusterMessage = message.getMessageObject();
if (clusterMessage != null) {
receiveClusterMessage(clusterMessage);
}
}
}
}
代码示例来源:origin: com.hazelcast/hazelcast-all
@Override
public void onMessage(Message message) {
if (!endpoint.isAlive()) {
return;
}
if (!(message instanceof DataAwareMessage)) {
throw new IllegalArgumentException("Expecting: DataAwareMessage, Found: "
+ message.getClass().getSimpleName());
}
DataAwareMessage dataAwareMessage = (DataAwareMessage) message;
Data messageData = dataAwareMessage.getMessageData();
String publisherUuid = message.getPublishingMember().getUuid();
ClientMessage eventMessage = TopicAddMessageListenerCodec.encodeTopicEvent(messageData,
message.getPublishTime(), publisherUuid);
boolean isMultithreaded = nodeEngine.getConfig().findTopicConfig(parameters.name).isMultiThreadingEnabled();
if (isMultithreaded) {
int key = rand.nextInt();
int partitionId = hashToIndex(key, nodeEngine.getPartitionService().getPartitionCount());
eventMessage.setPartitionId(partitionId);
sendClientMessage(eventMessage);
} else {
sendClientMessage(partitionKey, eventMessage);
}
}
}
代码示例来源:origin: com.atlassian.cache/atlassian-cache-hazelcast
@Override
public void onMessage(Message<ReferenceKey> message) {
CachedReference<?> localReference = localReferenceRef.get();
if (localReference == null)
{
// cache has been gc-d
destroy();
return;
}
if (!message.getPublishingMember().localMember())
{
localReference.reset();
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
private Message<E> toMessage(ReliableTopicMessage m) {
Member member = getMember(m);
E payload = serializationService.toObject(m.getPayload());
return new Message<E>(topicName, payload, m.getPublishTime(), member);
}
代码示例来源:origin: rancher/cattle
@Override
public void onMessage(Message<String> message) {
String eventString = message.getMessageObject();
if (eventString != null) {
onEvent(null, eventName, eventString);
}
}
};
代码示例来源:origin: com.hazelcast/hazelcast-hibernate4
public void onMessage(final Message<Object> message) {
if (!message.getPublishingMember().localMember()) {
maybeInvalidate(message.getMessageObject());
}
}
};
代码示例来源:origin: com.hazelcast/hazelcast-all
private Message<E> toMessage(ReliableTopicMessage m) {
Member member = getMember(m);
E payload = serializationService.toObject(m.getPayload());
return new Message<E>(topicName, payload, m.getPublishTime(), member);
}
代码示例来源:origin: io.snamp/internal-services
/**
* Gets type of this message.
*
* @return Type of this message.
*/
@Override
public Communicator.MessageType getType() {
return hzMessage.getMessageObject().messageType;
}
代码示例来源:origin: org.geoserver.community/gs-hz-cluster
@Override
public void onMessage(Message<UUID> message) {
UUID eventId = message.getMessageObject();
AtomicInteger countDown = expectedAckCounters.get(eventId);
if (countDown != null) {
countDown.decrementAndGet();
String originAddr = null;
Member publishingMember = message.getPublishingMember();
if (publishingMember != null) {
InetSocketAddress socketAddress = publishingMember.getSocketAddress();
if (socketAddress != null) {
originAddr = addressString(socketAddress);
}
}
LOGGER.finer(
format("%s - Got ack on event %s from %s", nodeId(), eventId, originAddr));
}
}
}
代码示例来源:origin: Atmosphere/atmosphere-extensions
@Override
public void onMessage(Message<String> message) {
broadcastReceivedMessage(message.getMessageObject());
}
});
代码示例来源:origin: com.atlassian.cache/atlassian-cache-hazelcast
@Override
public void onMessage(Message<K> message) {
Cache<K, ?> localCache = localCacheRef.get();
if (localCache == null)
{
// cache has been gc-d
destroy();
return;
}
if (!message.getPublishingMember().localMember())
{
K key = message.getMessageObject();
if (key == null)
{
localCache.removeAll();
}
else
{
localCache.remove(key);
}
}
}
代码示例来源:origin: io.snamp/internal-services
/**
* Gets payload of the message.
*
* @return Payload of the message.
*/
@Override
public Serializable getPayload() {
return hzMessage.getMessageObject().payload;
}
内容来源于网络,如有侵权,请联系作者删除!