Intro
This tutorial I have been a long time thinking about doing. This will come in handy: Rod Hot Client Guide
Before start
Download and install the client and install it:
npm install /path/to/jboss-datagrid-7.0.0-nodejs-client/infinispan-0.2.0.Final-redhat-1.tgz
It will also require vorpal js lib =|===>
Deploying
[fdemeloj@fdemeloj hotrod-endpoint-js]$ node football-manager.js
football-manager >
Core
As the guide mentions, the main part is done after the connection, then the functions are added after, but they use vorpal – bsically all in football-manager.js:
var infinispan = require(‘infinispan’);
var vorpal = require(‘vorpal’)();infinispan.client({port: 11222, host: ‘127.0.0.1’}).then(function(client)
Commands in Vorpal:
vorpal
.command(‘at [teamName]’, ‘Add a team.’)
.action(addTeam(client));
addPlayer:
function addPlayer(client) {
return function(args, callback) {
var teamName = args.teamName;
var playerName = args.playerName;var getTeam = client.get(teamName);
var putPlayer = getTeam.then(function(t) {
return client.put(teamName, appendPlayer(t, playerName));
});return putPlayer.then(callback);
Printing value with `p`
football-manager > at “Holand”
Add Team
truefootball-manager > p
Add Team
=== Team: Holand ===
Interesting facts
- If you do `tree command` the list of files is huge, cause all the js scripts from the libs are there, apparently.
- Deploying in version JDG 7.2 gives an exception, but version JDG 7.3 works perfectly.
-
ERROR [org.infinispan.server.hotrod.CacheDecodeContext]ISPN005003: Exception reported: org.infinispan.server.hotrod.InvalidMagicIdException: Error reading magic byte or message id: 13 at org.infinispan.server.hotrod.HotRodDecoder.readHeader(HotRodDecoder.java:184)
-
- Using vorpal makes the example pretty easy, with help and everything – tutorial here
- The package.json` has the dependencies and others info about the project
`hotrod-client.properties
` is not used.