安装和运行ZeroMQ

时间:2017-08-15 07:37:33

标签: java windows zeromq failed-installation jzmq

我正在尝试在我的电脑上安装ZeroMQ,但我不能让我的程序在没有崩溃的情况下运行 安装:

1) install Visual Studio 2017.

2) clone from git jzmq and libzmq

3) install ZMQ version 4.0.4 for windows.

4) run the script build in: \libzmq\builds\msvc\build\build.bat

5) open in Visual Studio 2017: libzmq\builds\msvc\vs2017\libzmq.sln and jzmq\jzmq-jni\builds\msvc\msvc.sln.

6) rebuild in the Visual Studio 2017 the sln files:

+ libzmq.sln : in the properties: configuration: Active(DebugDLL) platform: Active(x64)

+ msvc.sln : in the properties: configuration:Release platform: Active(x64)
label VC++ Directories: update the include directories and Library directories,
label Linker -> Input: update the Additional Dependencies with - C:\git-repo\libzmq\bin\x64\Debug\v141\dynamic\libzmq.lib;%(AdditionalDependencies)

7) put the libzmq.dll and the jzmq.dll in the system32 folder.

完成安装后,我尝试运行简单的Java示例,看看是否一切正常:
java代码:

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>

领事输出:

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 to from CallLongMethodV
at org.zeromq.ZMQ$Socket.construct(Native Method)
at org.zeromq.ZMQ$Socket.<init>(ZMQ.java:1719)
at org.zeromq.ZMQ$Context.socket(ZMQ.java:451)
at 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 with exit code -1073740791 (0xC0000409)
申请人

[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 to from CallLongMethodV
at org.zeromq.ZMQ$Socket.construct(Native Method)
at org.zeromq.ZMQ$Socket.<init>(ZMQ.java:1719)
at org.zeromq.ZMQ$Context.socket(ZMQ.java:451)
at 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]

TestMainClass尝试接收响应并打印后程序崩溃:  处理以退出代码-1073740791(0xC0000409)

结束

我认为导致失败的安装有问题,但我找不到问题。

1 个答案:

答案 0 :(得分:0)

好的,Alea Acta Est:

如何调试根本原因?

等级0:首先发送 int -s,而不是任何 string -s(其中)有不同的附加字符集问题)

等级1 :尝试 .recv() 方法的非阻止模式(从{{1}的非阻止模式返回方法调用最终将证明ZeroMQ-part不是问题)