zeromq / jeromq

JeroMQ is a pure Java implementation of the ZeroMQ messaging library, offering high-performance asynchronous messaging for distributed or concurrent applications.
https://zeromq.org
Mozilla Public License 2.0
2.37k stars 485 forks source link

Draft Methods #867

Open richardwei6 opened 3 years ago

richardwei6 commented 3 years ago

Will Draft methods such as RADIO/DISH ever be implemented into JeroMQ? I originally wanted to use JZMQ but had problems installing it. If it won't be implemented, how would I start adding it to JeroMQ? Thanks.

fredoboulo commented 3 years ago

hi,

RADIO/DISH sockets are already available in zmq package, in the latest SNAPSHOT. I just made a PR to include them in org.zeromq as well.

richardwei6 commented 3 years ago

Thanks for letting me know! Here's the pull request for reference: https://github.com/zeromq/jeromq/pull/868

richardwei6 commented 3 years ago

Ok, so I have a new issue with the draft implmentations. When using the udp protocol, I'm getting the Protocol not supported exception being thrown when trying to connect to this address: udp://224.0.0.1:28650. Is it possible that this is not implmented? If so, how would one go about implementing it? @fredoboulo

fbacchella commented 3 years ago

I wonder if that try could help: https://github.com/fbacchella/jeromq/commits/networkprotocolserviceprovider It allows to provide protocol as Services: https://www.baeldung.com/java-spi

richardwei6 commented 3 years ago

I wonder if that try could help: https://github.com/fbacchella/jeromq/commits/networkprotocolserviceprovider It allows to provide protocol as Services: https://www.baeldung.com/java-spi

Ok, I've merged your branch with the main branch of this repo to create this repo: https://github.com/richardwei6/jeromq. This repo contains your "networkprotocolserviceprovider" branch.

On my android studio project, I'm using jitpack to use external Github libraries from here: https://stackoverflow.com/a/34963958.

However, when trying to compile the repository mentioned above, it's getting a build error found at the end of these logs: https://jitpack.io/com/github/richardwei6/jeromq/master-v0.5.2-g3a23566-182/build.log.

Specifically, here is the small section that describes it:

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/jitpack/build/src/main/java/zmq/socket/Peer.java:[14,27] cannot find symbol
  symbol:   variable ZMQ_PEER
  location: class zmq.ZMQ
[ERROR] /home/jitpack/build/src/main/java/zmq/socket/Peer.java:[22,16] cannot find symbol
  symbol:   variable peerLastRoutingId
  location: variable options of type zmq.Options
[ERROR] /home/jitpack/build/src/main/java/zmq/socket/Raw.java:[12,27] cannot find symbol
  symbol:   variable ZMQ_RAW
  location: class zmq.ZMQ
[ERROR] /home/jitpack/build/src/main/java/zmq/socket/scattergather/Gather.java:[21,27] cannot find symbol
  symbol:   variable ZMQ_GATHER
  location: class zmq.ZMQ
[ERROR] /home/jitpack/build/src/main/java/zmq/socket/Channel.java:[21,27] cannot find symbol
  symbol:   variable ZMQ_CHANNEL
  location: class zmq.ZMQ
[ERROR] /home/jitpack/build/src/main/java/zmq/socket/scattergather/Scatter.java:[21,27] cannot find symbol
  symbol:   variable ZMQ_SCATTER
  location: class zmq.ZMQ
[INFO] 6 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  17.864 s
[INFO] Finished at: 2021-01-03T23:46:21Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project jeromq: Compilation failure: Compilation failure: 
[ERROR] /home/jitpack/build/src/main/java/zmq/socket/Peer.java:[14,27] cannot find symbol
[ERROR]   symbol:   variable ZMQ_PEER
[ERROR]   location: class zmq.ZMQ
[ERROR] /home/jitpack/build/src/main/java/zmq/socket/Peer.java:[22,16] cannot find symbol
[ERROR]   symbol:   variable peerLastRoutingId
[ERROR]   location: variable options of type zmq.Options
[ERROR] /home/jitpack/build/src/main/java/zmq/socket/Raw.java:[12,27] cannot find symbol
[ERROR]   symbol:   variable ZMQ_RAW
[ERROR]   location: class zmq.ZMQ
[ERROR] /home/jitpack/build/src/main/java/zmq/socket/scattergather/Gather.java:[21,27] cannot find symbol
[ERROR]   symbol:   variable ZMQ_GATHER
[ERROR]   location: class zmq.ZMQ
[ERROR] /home/jitpack/build/src/main/java/zmq/socket/Channel.java:[21,27] cannot find symbol
[ERROR]   symbol:   variable ZMQ_CHANNEL
[ERROR]   location: class zmq.ZMQ
[ERROR] /home/jitpack/build/src/main/java/zmq/socket/scattergather/Scatter.java:[21,27] cannot find symbol
[ERROR]   symbol:   variable ZMQ_SCATTER
[ERROR]   location: class zmq.ZMQ
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Build tool exit code: 0
Looking for artifacts...
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
Looking for pom.xml in build directory and ~/.m2
Found artifact: org.zeromq:jeromq:0.5.3-SNAPSHOT
2021-01-03T23:46:24.784944587Z
Exit code: 0

I'm assuming that the reason is that these sockets aren't implemented yet in jeromq?

richardwei6 commented 3 years ago

Ok so I tried manually merging it and I managed to get it to compile without any errors. The version is now v0.5.8. You can find it here: https://jitpack.io/#richardwei6/jeromq and https://github.com/richardwei6/jeromq

The issue is, I'm now still getting Protocol not supported when trying to bind the address.

fbacchella commented 3 years ago

yes, it does not implement protocol, but it reduce the amount of code to written, it's juste a simple class, that can even be added at runtime. So different implementation can be used for Android or server. It also allows to easily add unix sockets for people running on Java 16.

richardwei6 commented 3 years ago

yes, it does not implement protocol, but it reduce the amount of code to written, it's juste a simple class, that can even be added at runtime. So different implementation can be used for Android or server. It also allows to easily add unix sockets for people running on Java 16.

I'm still a little confused, what is this class you're talking about? I've looked up how to implement UDP in Java and found this: https://www.geeksforgeeks.org/working-udp-datagramsockets-java/. Is this the class you're talking about? If so, how would I go about implementing this?

somdoron commented 3 years ago

@richardwei6 UDP is not yet implemented in JeroMQ, what @fbacchella suggests an easier way to add UDP support.

If you want I can try to give you guidelines (and support) on how to port it to JeroMQ (I added the UDP protocol to libzmq)

richardwei6 commented 3 years ago

@richardwei6 UDP is not yet implemented in JeroMQ, what @fbacchella suggests an easier way to add UDP support.

If you want I can try to give you guidelines (and support) on how to port it to JeroMQ (I added the UDP protocol to libzmq)

Yea that would definitely be helpful!