Re: [zeromq-dev] About of test The Asynchronous Client/Server Pattern

2018-02-22 Thread Brian T. Carcich
On Thu, Feb 22, 2018 at 11:54 PM, Bernardo Augusto García Loaiza <
botib...@gmail.com> wrote:
>
> [...]
> I understand that the process of queuing each received message from all
> peers connected (in ZMQ_DEALER)
> and and *each message sent is round-robined *among all connected peers
>
> What mean round-robined?
>

see  https://en.wikipedia.org/wiki/Round-robin_scheduling
___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
https://lists.zeromq.org/mailman/listinfo/zeromq-dev


[zeromq-dev] Multiple connects with a ZMQ_REQ socket appears not to work

2018-02-22 Thread Mark
Hi all.

According to http://api.zeromq.org/4-2:zmq-socket with a ZMQ_REQ
socket I can connect to multiple endpoints and the semantics of
zmq_send() are:

"Each request sent is round-robined among all services, and
each reply received is matched with the last issued request.

If no services are available, then any send operation on the
socket shall block until at least one service becomes
available. The REQ socket shall not discard messages."

IOWs the message should get to one of the connected endpoints
eventually.

But I'm not seeing that behavior. Rather, the message never arrives at
any of the available endpoints.

To demonstrate this I hacked up the hello world examples such that the
client connects to two endpoints: the first nominates a port that
nothing is listening on and the second nominates a port that the
server is listening on. What I'm seeing is that the message exchange
never occurs.

I have attached both programs as they are minorly different from the
examples on the zmq website.

If I swap the connect order in the client such that the "up" server
comes first, then the message exchange works. After further testing I
deduce that attempting to exchange with second and subsequent connect
endpoints are the problem.

>From a system-call trace I can see the connection being established
and going thru at least some of the 0MQ setup exchange, but the
application messsage never gets sent. My suspicion is that the 0MQ
setup isn't completing for some reason.

I have tried this on macOS, FreeBSD and a recent Debian with the same
results. I have also tried it with zmq versions 4.2.1 and 4.2.3 - also
with the same results.

Am I mis-reading the ZMQ_REQ socket semantics or have I coded up the
client wrongly?

What I'm trying to achieve is running the same REQ/REP server on
multiple systems for redundancy and use 0MQ to automatically find a
working server on behalf of the client.


Mark.
//  Hello World server

#include 
#include 
#include 
#include 
#include 

int main (void)
{
  void *context = zmq_ctx_new();
  void *responder = zmq_socket(context, ZMQ_REP);
  int rc = zmq_bind(responder, "tcp://127.0.0.1:3000");
  assert (rc == 0);

  while (1) {
char buffer [10];
rc = zmq_recv(responder, buffer, 10, 0);
assert(rc > 0);
printf("Received Hello\n");
sleep(1);  //  Do some 'work'
rc = zmq_send(responder, "World", 5, 0);
assert(rc == 5);
  }
  zmq_close(responder);
  zmq_ctx_destroy(context);
  return 0;
}
//  Hello World client
#include 
#include 
#include 
#include 
#include 

int main (void)
{
  int rc;
  printf ("Connecting to hello world server\n");
  void *context = zmq_ctx_new();
  void *requester = zmq_socket(context, ZMQ_REQ);
  rc = zmq_connect(requester, "tcp://127.0.0.1:3002");
  assert(rc == 0);
  rc = zmq_connect(requester, "tcp://127.0.0.1:3001");
  assert(rc == 0);
  rc = zmq_connect(requester, "tcp://127.0.0.1:3000");
  assert(rc == 0);

  int request_nbr;
  for (request_nbr = 0; request_nbr != 3; request_nbr++) {
char buffer [10];
printf("Sending Hello %d\n", request_nbr);
rc = zmq_send(requester, "Hello", 5, 0);
assert(rc == 5);
zmq_recv(requester, buffer, 10, 0);
assert(rc > 0);
printf("Received World %d\n", request_nbr);
  }
  zmq_close(requester);
  zmq_ctx_destroy(context);
  return 0;
}
___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
https://lists.zeromq.org/mailman/listinfo/zeromq-dev


[zeromq-dev] About of test The Asynchronous Client/Server Pattern

2018-02-22 Thread Bernardo Augusto García Loaiza
Hi ZMQ people

I am understanding the different socket and patterns types due to I am
interested in have several clients which talk between them of a
collaborative way, having may be a server broker or middleware .which be
useful to receive and forward messages beetween entities related.

My study/situation case is the following:
I've want denote the workflow via step numbers interaction in my diagram. I
hope not to be inconvenient with my diagram, I only refer it to better
illustrate my situation

[image: Inline image 1]


What do would be an appropriate pattern to achieve bidirectional,
asynchronous messages between two client nodes which exchange messages
?


Due to this previously mentioned ... I have been reading and the ZMQ_ROUTER
and ZMQ_DEALER sockets they seem to be a good option due to the ongoing and
incoming routing strategy.

I understand that the process of queuing each received message from all
peers connected (in ZMQ_DEALER)
and and *each message sent is round-robined *among all connected peers

What mean round-robined?

With the ZMQ_ROUTER happen somethng similar in relation to incoming routing
strategy ...

I have been test the Shared Queue Dealer and Router sockets

samples
but the process is synchronous, due to  I've used it in a
REQ-ROUTER-DEALER-REP set up but in that case the REQ -> ROUTER send does
not target a particular handler on the other side, it just goes to an
arbitrary one and the ROUTER makes sure the reply goes back to the original
sender.

I think that my situation is similar to this Jake's question



The broker approach ROUTER-DEALER ... is right think about it?
Or the communication may be client to client directly?

I write to this mail list with the order to share my considerations and
learn and receive some orientation of you ZMQ people in relation to
the appropriate
pattern to achieve bidirectional, asynchronous messages between two client
nodes.

Bernardo Augusto García Loaiza
Ingeniero de Sistemas
Estudiante de Maestría en Ingeniería Informática - Universidad EAFIT
http://about.me/bgarcial
___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
https://lists.zeromq.org/mailman/listinfo/zeromq-dev