Le 11/03/2011 20:57, chuntz a écrit :
hello,
i push some corrections about the java sample, and i implement some
not already written sample;
I hope that will be usefull for you,
regards,
Christophe Huntzinger
___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
Hello,
I have no answer to mail first e-mail, so may I make some mistakes on
the way of working with ZMQ dev team. If it is, can you explain me what
I makes wrong. I apologize whatever.
The patch pushed is for sure under license LGPL and contains some new
implementations of the java samples:
/ examples/Java/msgqueue.java
examples/Java/mtserver.java
examples/Java/rrbroker.java
examples/Java/rrclient.java
examples/Java/rrserver.java
examples/Java/syncpub.java
examples/Java/syncsub.java
examples/Java/wuproxy.java/
and a correction of /MultiThreadedHelloWorldServer /sample.
I focus on the fact that a lot of java samples classes names doesn't
follow the java naming rules, and may they shall be renamed:
/msgqueue.java//-> /at least///MsgQueue.java/ and the class it contains
shall be named as well.
Regards,
Christophe Huntzinger
From d2e7113f37a6ce57b44c6c6b31bebc51f9324dd2 Mon Sep 17 00:00:00 2001
From: unknown
Date: Fri, 11 Mar 2011 20:42:11 +0100
Subject: [PATCH] Signed-off-by: C. Huntzinger
Correction of some issue in MultiThreadedHelloWorldServer.
New implementation of missing ZMQ java samples.
---
examples/Java/msgqueue.java | 42 ++--
examples/Java/mtserver.java | 51 -
examples/Java/rrbroker.java | 75 +--
examples/Java/rrclient.java | 40 +--
examples/Java/rrserver.java | 50 +++--
examples/Java/syncpub.java | 66 --
examples/Java/syncsub.java | 53 --
examples/Java/wuproxy.java | 56 ++--
8 files changed, 312 insertions(+), 121 deletions(-)
delete mode 100644 examples/Java/mtserver.java
diff --git a/examples/Java/msgqueue.java b/examples/Java/msgqueue.java
index 16bdba5..4535491 100644
--- a/examples/Java/msgqueue.java
+++ b/examples/Java/msgqueue.java
@@ -1,13 +1,35 @@
-No-one has translated the msgqueue example into Java yet. Be the first to
create
-msgqueue in Java and get one free Internet! If you're the author of the Java
-binding, this is a great way to get people to use 0MQ in Java.
+import org.zeromq.ZMQ;
+import org.zeromq.ZMQ.Context;
+import org.zeromq.ZMQ.Socket;
+import org.zeromq.ZMQQueue;
-To submit a new translation email it to zeromq-dev@lists.zeromq.org. Please:
+/**
+ * Simple message queuing broker
+ * Same as request-reply broker but using QUEUE device.
+ *
+ * Christophe Huntzinger
+ */
+public class MsgQueue{
-* Stick to identical functionality and naming used in examples so that readers
- can easily compare languages.
-* You MUST place your name as author in the examples so readers can contact
you.
-* You MUST state in the email that you license your code under the MIT/X11
- license.
+ public static void main (String[] args) {
+ // Prepare our context and sockets
+ Context context = ZMQ.context(1);
-Subscribe to this list at http://lists.zeromq.org/mailman/listinfo/zeromq-dev.
+ // Socket facing clients
+ Socket frontend = context.socket(ZMQ.XREP);
+ frontend.bind("tcp://*:5559");
+
+ // Socket facing services
+ Socket backend = context.socket(ZMQ.XREQ);
+ backend.bind("tcp://*:5560");
+
+ // Start built-in device
+ ZMQQueue queue = new ZMQQueue(context, frontend, backend);
+ // have fun!
+
+ // We never get here but clean up anyhow
+ frontend.close();
+ backend.close();
+ context.term();
+ }
+}
diff --git a/examples/Java/mtserver.java b/examples/Java/mtserver.java
deleted file mode 100644
index 206160f..000
--- a/examples/Java/mtserver.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
-Multithreaded Hello World server in Java
-
-Naveen Chawla
-*/
-import org.zeromq.ZMQ;
-
-public class MultiThreadedHelloWorldServer {
-public static void main(String[] args) {
-// Prepare our context and sockets
-final ZMQ.Context context = ZMQ.context(1);
-ZMQ.Socket clients = context.socket(ZMQ.XREP);
-clients.bind ("tcp://*:");
-ZMQ.Socket workers = context.socket(ZMQ.XREQ);
-workers.bind ("inproc://workers");
-
-// Launch pool of worker threads
-for (int thread_nbr = 0; thread_nbr != 5; thread_nbr++) {
-Thread worker_routine = new Thread(){
-public void run(){
-