[zeromq-dev] Problems with PUB/SUB sockets and OpenPGM

Jens Mehnert jens.mehnert at smeet.com
Wed Jun 30 14:30:19 CEST 2010


Hello Steve, thanks for the quick answer. What about my other problem. 
Isn't it possible to bind /connect a sender/receiver
to two different sockets on the same interface like this:

private static final ZMQ.Context CONTEXT = ZMQ.context (1);
private static final ZMQ.Socket PRODUCER_SOCKET = CONTEXT.socket(ZMQ.PUB);
private static final ZMQ.Socket CONSUMER_SOCKET = CONTEXT.socket(ZMQ.SUB);
...

PRODUCER_SOCKET.bind("tcp://127.0.0.1:5555");
CONSUMER_SOCKET.setsockopt(ZMQ.SUBSCRIBE, "");
CONSUMER_SOCKET.connect("tcp://127.0.0.1:5555");
...

Producer Thread:

while(!Thread.currentThread().interrupted()) {
     try {
         String value = TinyUUID.randomTinyUUID().toString();
         LOG.debug("Send " + value);
         PRODUCER_SOCKET.send(value.getBytes(), 0);
         Thread.sleep(1000);
     } catch (Exception e) {
         throw new RuntimeException(e);
     }
}

Consumer Thread (Runnable scheduled via ExecutorService):

while (!Thread.currentThread().isInterrupted()) {
     try {
         LOG.debug("Receiving ...");
         byte[] rawMessage = CONSUMER_SOCKET.recv(0);
         LOG.debug("Received %s", new String(rawMessage));
     } catch (Exception e) {
         LOG.error("An error occured handling zmq message ...");
     }
}

The problem is that the send thread using the producer socket blocks on 
send.  If I don't
start the consumer send() does not block. Furthermore, If I use the two 
different VMs (
one producer, one consumer main app) it works splendidly too.

What am I doing wrong?

Best regards, Jens


Am 30.06.2010 11:58, schrieb Steven McCoy:
> On 30 June 2010 17:44, Jens Mehnert <jens.mehnert at smeet.com 
> <mailto:jens.mehnert at smeet.com>> wrote:
>
>     The second problem I've is that if I'm using two contexts I'm
>     running into troubles when I'm changing
>     the protocol to epgm. Because in that case I'm getting following
>     error: Assertion failed: !pgm_supported () (zmq.cpp:239)
>
>
>     //  Unfortunately, OpenPGM doesn't support refcounted 
> init/shutdown, thus,
>     //  let's fail if it was initialised beforehand.
>     zmq_assert (!pgm_supported ());
>
> i.e. ZeroMQ only allows one PGM session per process.  OpenPGM v3 has 
> implemented reference counting to resolve such issues.
>
> -- 
> Steve-o
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>    


-- 
Jens Mehnert

sMeet Communications GmbH
Gipsstrasse 5
D-10119 Berlin

Fon:    +49 -30- 2887 88963
Fax:    +49 -30- 9700 5359
E-Mail: jens.mehnert at smeet.com

smeet.com
see.meet.talk

Sitz der Gesellschaft: Birmingham, UK
Handelsregister Berlin Charlottenburg: HRB 104503 B
Geschäftsführer: Reinhard Köhn, Sebastian Funke

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20100630/586b6bdc/attachment.htm>


More information about the zeromq-dev mailing list