java - Installing and running ZeroMQ -
i trying install zeromq on pc can not make program run without crashing.
installation:
1) install visual studio 2017. 2) clone git jzmq , libzmq 3) install zmq version 4.0.4 windows. 4) run script build in: \libzmq\builds\msvc\build\build.bat 5) open in visual studio 2017: libzmq\builds\msvc\vs2017\libzmq.sln , jzmq\jzmq-jni\builds\msvc\msvc.sln. 6) rebuild in visual studio 2017 sln files: + libzmq.sln : in properties: configuration: active(debugdll) platform: active(x64) + msvc.sln : in properties: configuration:release platform: active(x64) label vc++ directories: update include directories , library directories, label linker -> input: update additional dependencies - c:\git-repo\libzmq\bin\x64\debug\v141\dynamic\libzmq.lib;%(additionaldependencies) 7) put libzmq.dll , jzmq.dll in system32 folder.
after finished installation, try run simple java example see if working:
java code:
import org.zeromq.zmq; import java.nio.charset.charset; public class testmainclass { public static void main(string[] args){ try { zmq.context context = zmq.context(1); zmq.socket replier = context.socket(zmq.rep); replier.bind("tcp://*:5559"); while (true) { string gwsource = replier.recvstr(charset.defaultcharset()); replier.send("ok"); system.out.println(gwsource); } }catch (throwable e) { system.out.println(e); } } }
import org.zeromq.zmq; public class requester { public static void main(string[] args){ zmq.context context = zmq.context(1); zmq.socket replier = context.socket(zmq.req); replier.connect("tcp://localhost:5559"); while (true) { replier.send("public"); system.out.println(new string(replier.recv())); } } }
<?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <groupid>com.test.hagar</groupid> <artifactid>hagartestrealtick</artifactid> <version>current-snapshot</version> <dependencies> <dependency> <groupid>org.zeromq</groupid> <artifactid>jzmq</artifactid> <version>3.1.0</version> </dependency> </dependencies> </project>
the consul output:
for testmainclass :
"c:\program files\java\jdk1.8.0_121\bin\java" -xcheck:jni -verbose:jni "-javaagent:c:\program files\jetbrains\intellij idea community edition 2017.2.1\lib\idea_rt.jar=57531:c:\program files\jetbrains\intellij idea community edition 2017.2.1\bin" -dfile.encoding=utf-8 -classpath "c:\program files\java\jdk1.8.0_121\jre\lib\charsets.jar;c:\program files\java\jdk1.8.0_121\jre\lib\deploy.jar;c:\program files\java\jdk1.8.0_121\jre\lib\ext\access-bridge-64.jar;c:\program fil warning in native method: jni call made without checking exceptions when required calllongmethodv @ org.zeromq.zmq$socket.construct(native method) @ org.zeromq.zmq$socket.<init>(zmq.java:1719) @ org.zeromq.zmq$context.socket(zmq.java:451) @ testmainclass.main(testmainclass.java:11) [dynamic-linking native method org.zeromq.zmq$socket.bind ... jni] [dynamic-linking native method org.zeromq.zmq$socket.recv ... jni] process finished exit code -1073740791 (0xc0000409)
for requester :
[registering jni native method java.lang.system.arraycopy] [dynamic-linking native method java.lang.thread.registernatives ... jni] [registering jni native method java.lang.thread.start0] warning in native method: jni call made without checking exceptions when required calllongmethodv @ org.zeromq.zmq$socket.construct(native method) @ org.zeromq.zmq$socket.<init>(zmq.java:1719) @ org.zeromq.zmq$context.socket(zmq.java:451) @ requester.main(requester.java:8) [dynamic-linking native method org.zeromq.zmq$socket.connect ... jni] [dynamic-linking native method org.zeromq.zmq$socket.send ... jni] [dynamic-linking native method org.zeromq.zmq$socket.recv ... jni]
the program crash after testmainclass try receive response , print: process finished exit code -1073740791 (0xc0000409)
i think wrong in installation causes fail, can not find problem.
ok, alea acta est:
how debugging root-cause?
level 0: send first int
-s, instead of string
-s ( having different add-on charset-issues )
level 1: try non-blocking mode of .recv()
method ( return non-blocking mode of .recv()
method call prove zeromq-part not problem )
Comments
Post a Comment