use of zmq.Ctx in project jeromq by zeromq.
the class XPubTest method testSetNoDrop.
@Test
public void testSetNoDrop() {
Ctx ctx = ZMQ.createContext();
SocketBase pub = null;
try {
pub = ctx.createSocket(ZMQ.ZMQ_XPUB);
boolean rc = pub.setSocketOpt(ZMQ.ZMQ_XPUB_NODROP, 0);
assertThat(rc, is(true));
} finally {
ZMQ.close(pub);
ZMQ.term(ctx);
}
}
use of zmq.Ctx in project jeromq by zeromq.
the class DealerDealerTest method testIssue131.
@Test
public void testIssue131() throws IOException {
Ctx ctx = ZMQ.createContext();
assertThat(ctx, notNullValue());
SocketBase sender = ZMQ.socket(ctx, ZMQ.ZMQ_DEALER);
assertThat(sender, notNullValue());
final int port = Utils.findOpenPort();
final String addr = "tcp://localhost:" + port;
boolean rc = ZMQ.connect(sender, addr);
assertThat(rc, is(true));
byte[] sbuf = msg(255);
int sent = ZMQ.send(sender, sbuf, 0);
assertThat(sent, is(255));
byte[] quit = { 'q' };
sent = ZMQ.send(sender, quit, 0);
assertThat(sent, is(1));
ZMQ.close(sender);
SocketBase receiver = ZMQ.socket(ctx, ZMQ.ZMQ_DEALER);
assertThat(receiver, notNullValue());
rc = ZMQ.bind(receiver, addr);
assertThat(rc, is(true));
int nbytes = 0;
do {
Msg msg = ZMQ.recv(receiver, 0);
nbytes = msg.size();
System.out.println(msg);
} while (nbytes != 1);
ZMQ.close(receiver);
ZMQ.term(ctx);
}
use of zmq.Ctx in project jeromq by zeromq.
the class DealerSpecTest method testSpecFairQueueIn.
@Test
public void testSpecFairQueueIn() throws IOException, InterruptedException {
Ctx ctx = ZMQ.createContext();
List<String> binds = Arrays.asList("inproc://a", "tcp://127.0.0.1:*");
for (String bindAddress : binds) {
// SHALL receive incoming messages from its peers using a fair-queuing
// strategy.
fairQueueIn(ctx, bindAddress, ZMQ.ZMQ_DEALER, ZMQ.ZMQ_DEALER);
}
ZMQ.term(ctx);
}
use of zmq.Ctx in project jeromq by zeromq.
the class ReqSpecTest method testSpecBlockOnSendNoPeers.
@Test
public void testSpecBlockOnSendNoPeers() throws IOException, InterruptedException {
Ctx ctx = ZMQ.createContext();
List<String> binds = Arrays.asList("inproc://a", "tcp://127.0.0.1:*");
for (String bindAddress : binds) {
// SHALL block on sending, or return a suitable error, when it has no
// connected peers.
blockOnSendNoPeers(ctx, bindAddress, ZMQ.ZMQ_REQ);
}
ZMQ.term(ctx);
}
use of zmq.Ctx in project jeromq by zeromq.
the class ReqSpecTest method testSpecOnlyListensToCurrentPeer.
@Test
@Ignore
public void testSpecOnlyListensToCurrentPeer() throws IOException, InterruptedException {
Ctx ctx = ZMQ.createContext();
List<String> binds = Arrays.asList("inproc://a", "tcp://127.0.0.1:*");
for (String bindAddress : binds) {
// SHALL accept an incoming message only from the last peer that it sent a
// request to.
// SHALL discard silently any messages received from other peers.
// PH: this test is still failing; disabled for now to allow build to
// complete.
onlyListensToCurrentPeer(ctx, bindAddress, ZMQ.ZMQ_REQ, ZMQ.ZMQ_ROUTER);
}
ZMQ.term(ctx);
}
Aggregations