In my last posting I wrote, that I was investigating MessagePak-RPC as a solution for my service network.
I stopped work on that, because I implemented MessagePak-RPC in Smalltalk in a way all the other programming language bindings did not do. I made it more powerful, but the reference implementation showed me, that I interpreted the protocol in a more powerful – but wrong – way. They are considering to extend their protocol into the directon of my interpretation, but up to now it does not fullfill my needs.
Then I found ZMQ and wrote a wrapper for that c communication library – and I like this library very much.
I wanted to implement the example of this video.
I found a GnuSmalltalk implementation at the zmq home page, but I have to admit, that I did not like that and wrote my own wrapper – and it showed me, how much more powerful VASmalltalk could be/is.
The demos in that video are presented using Lua in two different windows. Due to the asynchronous support in VA the example can be executed in the same image, but the sending code has to be forked in a specific Smalltalk thread.
Here is my first demo code.This one is executes in a first workspace (its the server).
context := ZMQCore newContext: 1. socket := context downstreamSocket. socket bindTo: 'tcp://127.0.0.1:12345'. [ socket send: 'Hello' ] fork
…and this code is executed in a second workspace (its a client):
context := ZMQCore newContext: 1. socket := context upstreamSocket. socket connectTo: 'tcp://127.0.0.1:12345'. [ [ true ] whileTrue:[ Transcript cr; show: '1: ',socket receive ] ] fork
The best thing here is, that you actually even do not need the socket library of VASmalltalk and most of the communication are done in external OS threads – therefore leaving much more CPU execution time to Smalltalk code itselfs and you may be even using several cores of your CPU.