T
- as payload Object to send over HazelCastpublic class SendOnHazelCast<T> extends Object implements Consumer<T>, org.apache.commons.collections.Transformer, UpdatableContext<Supplier<com.hazelcast.core.HazelcastInstance>>
ListenItemOnHazelCast<TestObj> listener = new ListenItemOnHazelCast(hazelcastInstance, "tracking-data"); //Send listen on different instances (NON CLUSTERED)
final Count count = new Count();
listener.setConsumer(new Consumer<TestObj>() {
public void accept(TestObj t) {
log.info("[LISTENER] " + listener.getContainerName() + " > " + t);
count.pass++;
Assert.assertEquals("xy"+t.i, t.s); //Simply check pattern matches x<vlaue of i>
count.pass++;
}
});
listener.init(); //bind listener to HZ
SendOnHazelCast<TestObj> send = new SendOnHazelCast(hazelcastInstance, "tracking-data");
send.accept(new TestObj("x1", 1)); //Pattern of data x<vlaue of i>
send.accept(new TestObj("x2", 2));
send.accept(new TestObj("x3", 3));
SetupHazelCastInstance
,
Serialized FormConstructor and Description |
---|
SendOnHazelCast() |
SendOnHazelCast(com.hazelcast.core.HazelcastInstance vmInstance,
String containerName) |
SendOnHazelCast(Supplier<com.hazelcast.core.HazelcastInstance> vmInstance,
String containerName) |
Modifier and Type | Method and Description |
---|---|
void |
accept(T t)
|
String |
getContainerName()
Name of the Distributed List or Map
Note: Dont confuse containerName for groupName |
Function<T,String> |
getGetKey()
For the input t, get the key name; if t has to be put on a Distributed Map.
|
Supplier<com.hazelcast.core.HazelcastInstance> |
getVmInstance()
Context
Supplier of HazelcastInstance .This allows us to pass a instance via context in a more dynamic multi instance environment or one configured directly into this instance. |
void |
put(com.hazelcast.core.HazelcastInstance vmInstance,
String key,
T t) |
void |
put(String key,
T t) |
void |
send(com.hazelcast.core.HazelcastInstance vmInstance,
T t)
Send payload to a particular
HazelcastInstance |
void |
setContainerName(String containerName)
Name of the Distributed List or Map
Note: Dont confuse containerName for groupName |
void |
setGetKey(Function<T,String> getKey)
For the input t, get the key name; if t has to be put on a Distributed Map.
|
void |
setVmInstance(Supplier<com.hazelcast.core.HazelcastInstance> vmInstance)
Context
Supplier of HazelcastInstance .This allows us to pass a instance via context in a more dynamic multi instance environment or one configured directly into this instance. |
Object |
transform(Object input) |
void |
updateContext(Supplier<com.hazelcast.core.HazelcastInstance> context) |
public SendOnHazelCast()
public SendOnHazelCast(Supplier<com.hazelcast.core.HazelcastInstance> vmInstance, String containerName)
public SendOnHazelCast(com.hazelcast.core.HazelcastInstance vmInstance, String containerName)
public Object transform(Object input)
transform
in interface org.apache.commons.collections.Transformer
public void send(com.hazelcast.core.HazelcastInstance vmInstance, T t)
HazelcastInstance
vmInstance
- as HazelcastInstance
t
- as type public Supplier<com.hazelcast.core.HazelcastInstance> getVmInstance()
Supplier
of HazelcastInstance
.public void setVmInstance(Supplier<com.hazelcast.core.HazelcastInstance> vmInstance)
Supplier
of HazelcastInstance
.public String getContainerName()
HazelcastInstance.getMap(String)
,
if Map or List will be used.
public void setContainerName(String containerName)
HazelcastInstance.getMap(String)
,
if Map or List will be used.
public Function<T,String> getGetKey()
t
- as public void setGetKey(Function<T,String> getKey)
t
- as public void updateContext(Supplier<com.hazelcast.core.HazelcastInstance> context)
updateContext
in interface UpdatableContext<Supplier<com.hazelcast.core.HazelcastInstance>>
Copyright © 2018. All rights reserved.