Node.js Client for Hazelcast, using Hazelcast Open Client Protocol 1.0 for Hazelcast 3.6 and higher
mdumandag on master
add missing line to the cluster… (compare)
mdumandag on master
remove member tool section from… (compare)
asimarslan on member-tool
asimarslan on maven_repo_update
Holmistr on master
Maven repository update (compare)
Holmistr on maven_repo_update
Maven repository update (compare)
mdumandag on master
update hazelcast version to use… (compare)
Config config = new Config();
ReliableTopicConfig rtConfig = config.getReliableTopicConfig("scheduleJobUpdate");
rtConfig.addMessageListenerConfig(new ListenerConfig(new ScheduleJobUpdateListener()));
ScheduleJobUpdateListener listener = new ScheduleJobUpdateListener();
HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);
instance.getReliableTopic("scheduleJobUpdate").addMessageListener(listener);
@gAmUssA I am using a XML file to config the Hazelcast instance so I tried adding the topic listener in the configure xml like following:
<reliable-topic name="scheduleJobUpdate">
<read-batch-size>10</read-batch-size>
<topic-overload-policy>DISCARD_OLDEST</topic-overload-policy>
<statistics-enabled>true</statistics-enabled>
<message-listeners>
<message-listener>com.lambdazen.imdg.ScheduleJobUpdateListener</message-listener>
</message-listeners>
</reliable-topic>
But still not be able to receive the message from NodeJS...
@HariLogana_twitter
Hi Guys, I am trying to use the Hazelcast using nodejs client
I have the Hazelcast cluster server running in the 172.30.56.60, 61, 62
(i.e)
[ Member {
address: Address { host: '172.30.56.60', port: 5701, type: 4 },
uuid: 'bd6428f0-e888-453f-872f-6fe8296d751d',
isLiteMember: false,
attributes: {} },
Member {
address: Address { host: '172.30.56.61', port: 5701, type: 4 },
uuid: 'e0cd795a-0ca5-41ab-907a-492b61690a18',
isLiteMember: false,
attributes: {} },
Member {
address: Address { host: '172.30.56.62', port: 5701, type: 4 },
uuid: '0a834ae8-e707-4b5b-945b-362bfea08cf5',
isLiteMember: false,
attributes: {} } ]
I try to implement the Hazelcast distributed locking using nodejs using the following code,
// Initialize the hazelcast client instance.
var HazelcastClient = require('hazelcast-client').Client;
var Config = require('hazelcast-client').Config;
var config = new Config.ClientConfig();
config.networkConfig.addresses = [{host: '172.30.56.60', port: '5701'},{host: '172.30.56.61', port: '5701'}, {host: '172.30.56.62', port: '5701'}];
var lock = {};
var sleep = require('sleep');
HazelcastClient
.newHazelcastClient(config)
.then(function (hazelcastClient) {
lock = hazelcastClient.getLock("lock1");
// do stuff with lock
lock.lock();
console.log('Am locked in node with lock1...will be locked for 20 seconds');
sleep.sleep(20);
console.log('Unlocked now...');
lock.unlock();
process.exit();
});
I started the script node by node, I expected to establish the lock node by node, but instead it locks all the nodes in the same time. So it is not working as a distributed lock, so all the script started and ending in the same time (NOTE : For testing I provided 20 seconds sleep)
Please let me know, How to establish the distributed lock using node js in Hazelcast.
lock.lock().then(function() {
sleep.sleep(20):
return lock().unlock();
}).then(function() {
console.log('unlocked now');
});
Hello, I am trying to read map entries using the nodejs hazelcast client. Reading the same entries from Java or REST clients it works, however, for the nodeJS client, the following error occurs:
Unhandled rejection TypeError: Cannot read property 'read' of undefined
at SerializationServiceV1.toObject (/home/radu/Work/workspaces/rf/road-family-2/tests/integration/node_modules/hazelcast-client/lib/serialization/SerializationService.js:75:27)
at MapProxy.BaseProxy.toObject (/home/radu/Work/workspaces/rf/road-family-2/tests/integration/node_modules/hazelcast-client/lib/proxy/BaseProxy.js:114:54)
at Function.MapGetCodec.decodeResponse (/home/radu/Work/workspaces/rf/road-family-2/tests/integration/node_modules/hazelcast-client/lib/codec/MapGetCodec.js:54:38)
at /home/radu/Work/workspaces/rf/road-family-2/tests/integration/node_modules/hazelcast-client/lib/proxy/BaseProxy.js:33:33
at tryCatcher (/home/radu/Work/workspaces/rf/road-family-2/tests/integration/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/radu/Work/workspaces/rf/road-family-2/tests/integration/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/home/radu/Work/workspaces/rf/road-family-2/tests/integration/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/home/radu/Work/workspaces/rf/road-family-2/tests/integration/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/home/radu/Work/workspaces/rf/road-family-2/tests/integration/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/home/radu/Work/workspaces/rf/road-family-2/tests/integration/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/home/radu/Work/workspaces/rf/road-family-2/tests/integration/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/home/radu/Work/workspaces/rf/road-family-2/tests/integration/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:794:20)
at tryOnImmediate (timers.js:752:5)
at processImmediate [as _immediateCallback] (timers.js:729:5)
int
, long
, String
etc. However if you use custom objects across multiple client languages you need to provide Hazelcast a serialization method. These are either IdentifiedDataSerializable
or Portable
. You can find more information about serialization here: http://docs.hazelcast.org/docs/latest-development/manual/html/Serialization/Overview.html . I short, you need to make your Java objects implement either IdentifiedDataSerializable
or Portable
. Also you need to do the same thing in Node.js client. Here is a sample in Node.js client: https://github.com/hazelcast/hazelcast-nodejs-client/blob/master/code_samples/org-website/IdentifiedDataSerializableSample.js