Skip to content

Commit

Permalink
JzmqDummyServer.java works with zmqtest.py. So something's wrong with…
Browse files Browse the repository at this point in the history
… our current camel-zeromq implementation. must fix quickly!
  • Loading branch information
ceefour committed Aug 27, 2015
1 parent e53d060 commit a300472
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/main/java/org/opencog/atomspace/zmq/JzmqDummyServer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.opencog.atomspace.zmq;

import org.apache.commons.io.HexDump;
import org.zeromq.ZMQ;

/**
* Created by ceefour on 8/27/15.
*/
public class JzmqDummyServer {

public static void main(String... args) throws Exception {
try (final ZMQ.Context context = ZMQ.context(1)) {
try (final ZMQ.Socket socket = context.socket(ZMQ.REP)) {
socket.bind("tcp://127.0.0.1:5555");
while (!Thread.currentThread ().isInterrupted()) {
byte[] request = socket.recv(0);
HexDump.dump(request, 0, System.out, 0);

String response = "World";
socket.send(response.getBytes(), 0);
Thread.sleep(1000); // Do some 'work'
}
}
}
}
}
41 changes: 41 additions & 0 deletions zmqtest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python
import sys
import time
import zmq
#import TZmqClient
#import thrift.protocol.TBinaryProtocol
#import storage.ttypes
#import storage.Storage

def main(args):
endpoint = "tcp://127.0.0.1:5555"
socktype = zmq.REQ
# incr = 0
# if len(args) > 1:
# incr = int(args[1])
# if incr:
# socktype = zmq.DOWNSTREAM
# endpoint = "tcp://127.0.0.1:9091"

ctx = zmq.Context()
socket = ctx.socket(socktype)
socket.connect(endpoint)
request = "HELLO"
print "Sending ", request, " ..."
socket.send(request)
message = socket.recv()
print "Received reply: ", message

#transport = TZmqClient.TZmqClient(ctx, endpoint, socktype)
# protocol = thrift.protocol.TBinaryProtocol.TBinaryProtocolAccelerated(transport)
# client = storage.Storage.Client(protocol)
#transport.open()
# if incr:
# client.incr(incr)
# time.sleep(0.05)
# else:
# value = client.get()
# print value

if __name__ == "__main__":
main(sys.argv)

0 comments on commit a300472

Please sign in to comment.