Commit 653e792e authored by legoc's avatar legoc
Browse files

Continue with the replacement of tryRequest calls

parent c169861e
......@@ -472,12 +472,15 @@ public class ApplicationImpl extends ServicesImpl {
int requesterId = RequesterImpl.newRequesterId();
String requesterPortName = RequesterImpl.getRequesterPortName(name, responderId, requesterId);
// Create the responder socket that will be called twice.
RequestSocket responderSocket = createRequestSocket(responderEndpoint);
try {
// First connect to the responder
Zmq.Msg request = createConnectPortRequest(responderId, responderPortName);
Zmq.Msg reply = tryRequest(request, responderEndpoint);
Zmq.Msg reply = responderSocket.request(request);
byte[] messageData = reply.getFirstData();
RequestResponse requestResponse = RequestResponse.parseFrom(messageData);
......@@ -490,7 +493,7 @@ public class ApplicationImpl extends ServicesImpl {
// Retry to connect
request = createConnectPortRequest(responderId, responderPortName);
reply = tryRequest(request, responderEndpoint);
reply = responderSocket.request(request);
messageData = reply.getFirstData();
requestResponse = RequestResponse.parseFrom(messageData);
......@@ -516,6 +519,9 @@ public class ApplicationImpl extends ServicesImpl {
} catch (InvalidProtocolBufferException e) {
throw new UnexpectedException("Cannot parse response");
} finally {
responderSocket.terminate();
}
}
......
......@@ -649,22 +649,6 @@ public class ServerImpl extends ServicesImpl {
return subscriber;
}
void subscribeToPublisher(String endpoint) throws ConnectionTimeout {
Zmq.Msg request = createSubscribePublisherRequest();
Zmq.Msg reply = tryRequest(request, endpoint);
byte[] messageData = reply.getFirstData();
RequestResponse requestResponse = null;
try {
requestResponse = RequestResponse.parseFrom(messageData);
} catch (InvalidProtocolBufferException e) {
throw new UnexpectedException("Cannot parse response");
}
}
/**
* create isAlive request
*
......
......@@ -114,12 +114,12 @@ public class ServicesImpl {
return false;
}
protected void sendInit(String endpoint) {
protected void sendInit() {
Zmq.Msg request = createInitRequest();
Zmq.Msg reply = null;
try {
reply = tryRequest(request, endpoint);
reply = requestSocket.request(request);
reply.destroy();
request.destroy();
......@@ -128,10 +128,6 @@ public class ServicesImpl {
}
}
protected void sendInit() {
sendInit(serverEndpoint);
}
/**
*
* @throws ConnectionTimeout
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment