ZeroMQ - OSX installation

$ brew install libtool
$ brew install pkg-config
$ brew install autoconf
$ brew install automake

After the installation check what is on the $PATH. Make sure that /usr/local/bin is first. If not run:

$ export PATH=/usr/local/bin:$PATH
$ which autoconf
/usr/local/bin/autoconf
$ which automake
/usr/local/bin/automake
$ which aclocal
/usr/local/bin/aclocal

If there are other versions of aclocal installed, you can get errors like Unknown symbol (TODO).

Download latest version of 0MQ (in my case it was 4.1.5)

$ curl -O http://download.zeromq.org/zeromq-4.1.5.tar.gz
$ tar zxf zeromq-4.1.4.tar.gz
$ cd zeromq-4.1.5
$ ./configure --without-libsodium
$ make
$ sudo make install

Clone jzmq - binding for java.

$ git clone https://github.com/zeromq/jzmq.git
$ cd jzmq

Build jni libraries.

$ cd jzmq-jni
$ ./autogen.sh
$ ./configure
$ make
$ sudo make install

Build java dependenies and install them in local maven repository.

$ cd ..
$ mvn clean package

Before installing java libraries you have to install gpg - software for encrypting files.

$ brew install gnupg
$ gpg --gen-key

Install libraries in local maven repository:

$ mvn install

jzmq in gradle

jzmq installs all libraries in /usr/local/lib path. So set it as java.library.path system property.

Gradle configuration

Add dependency to 0MQ library (installed in local maven repo a few commands ago).

dependencies {
  // ZeroMQ dependency
  compile "org.zeromq:jzmq:3.1.1-SNAPSHOT"
}

Add java.library.path system property in run task:

test {
  systemProperty "java.library/path", "/usr/local/lib"
}
run {
  systemProperty "java.library/path", "/usr/local/lib"
}

== ZMQ and JZMQ in Apache Flink
JZMQ statically loads `JNI` libraries. If you want to call ZMQ services from inside Apache Flink jobs you have to load them once per JVM instance. In fact you have to load them once per Task Manager instance. To do it just put `jzmq.jar` in `$FLINK_HOME/lib` folder on every Task Manager node. In the same time exclude `jzmq` dependencies from your build.
If you use `gradle` `shadow` plugin you can do it like follows:

Define new configuration in your `build.gradle`

[source, groovy]

configurations { jzmq }

dependencies { …​ jzmq("org.zeromq:jzmq:3.1.1-SNAPSHOT") }

Exclude ZMQ dependencies from the shadow jar:

[source, groovy]

shadowJar { dependencies { exclude(dependency { it.moduleGroup == "org.zeromq" }) } }

Add new task for building `JZMQ` jar:

[source, groovy]

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar task jzmqJar(type: ShadowJar) { baseName = "jzmq" version = "3.1.1-SNAPSHOT" configurations = [project.configurations.jzmq] }

Build `JZMQ` jar:

$ ./gradlew jzmqJar

and copy generated jar file to `$FLINK_HOME/lib` on every Task Manager.

Add configuration of local libraries to `$FLINK_HOME/conf/flink-conf.yaml`

Java options

env.java.opts: "-Djava.library.path=/usr/local/lib"


results matching ""

    No results matching ""