use of com.hazelcast.core.Message in project hazelcast by hazelcast.
the class ClientReliableTopicTest method testRemoveListener.
@Test
public void testRemoveListener() {
ITopic topic = client.getReliableTopic(randomString());
MessageListener listener = new MessageListener() {
public void onMessage(Message message) {
}
};
String id = topic.addMessageListener(listener);
assertTrue(topic.removeMessageListener(id));
}
use of com.hazelcast.core.Message in project camel by apache.
the class HazelcastTopicConsumerTest method receive.
@Test
@SuppressWarnings("unchecked")
public void receive() throws InterruptedException {
MockEndpoint out = getMockEndpoint("mock:received");
out.expectedMessageCount(1);
final Message<String> msg = new Message<String>("foo", "foo", new java.util.Date().getTime(), null);
argument.getValue().onMessage(msg);
assertMockEndpointsSatisfied(2000, TimeUnit.MILLISECONDS);
this.checkHeaders(out.getExchanges().get(0).getIn().getHeaders(), HazelcastConstants.RECEIVED);
}
use of com.hazelcast.core.Message in project camel by apache.
the class HazelcastReliableTopicConsumerTest method receive.
@Test
@SuppressWarnings("unchecked")
public void receive() throws InterruptedException {
MockEndpoint out = getMockEndpoint("mock:received");
out.expectedMessageCount(1);
final Message<String> msg = new Message<String>("foo", "foo", new java.util.Date().getTime(), null);
argument.getValue().onMessage(msg);
assertMockEndpointsSatisfied(2000, TimeUnit.MILLISECONDS);
this.checkHeaders(out.getExchanges().get(0).getIn().getHeaders(), HazelcastConstants.RECEIVED);
}
use of com.hazelcast.core.Message in project hazelcast by hazelcast.
the class AllTest method loadTopicOperations.
private List<Runnable> loadTopicOperations() {
ITopic topic = hazelcast.getTopic("myTopic");
topic.addMessageListener(new MessageListener() {
public void onMessage(Message message) {
messagesReceived.incrementAndGet();
}
});
List<Runnable> operations = new ArrayList<Runnable>();
addOperation(operations, new Runnable() {
public void run() {
ITopic topic = hazelcast.getTopic("myTopic");
topic.publish(String.valueOf(random.nextInt(100000000)));
messagesSend.incrementAndGet();
}
}, 10);
return operations;
}
use of com.hazelcast.core.Message in project hazelcast by hazelcast.
the class ReliableMessageListenerRunner method toMessage.
private Message<E> toMessage(ReliableTopicMessage m) {
MemberImpl member = clusterService.getMember(m.getPublisherAddress());
E payload = serializationService.toObject(m.getPayload());
return new Message<E>(topicName, payload, m.getPublishTime(), member);
}
Aggregations