Commit 6fbbf406 by Adi Amir

general improvements in server side

parent b3e3da3d
group 'com.ipgallery.common'
version '1.0.0'
version '1.0.x'
apply plugin: 'java'
apply plugin: 'maven-publish'
......
{
"oc": 1000,
"key": "key00001",
"APP": "testApp",
"oId": "respQ@localhost",
"APP": "test",
"METHOD": "GET",
"ENTITY": "transpotation",
"PARAMS": "/street",
"REQUEST_PARAMS": "ts=0",
"CONTENT": null
}
\ No newline at end of file
}
\ No newline at end of file
......@@ -36,8 +36,11 @@ import common.SimpleLogger;
import itm.ITMManager;
import itm.ITMThread;
import static java.lang.Thread.sleep;
public class RMQServer extends ITMManager {
private final static Integer CONNECTION_RETRY_TIMEOUT = 10000;
protected RMQReciever mRMQReciever = null;
protected RMQId listenRMQId = null;
protected SimpleLogger logger = null;
......@@ -96,15 +99,17 @@ public class RMQServer extends ITMManager {
mRMQReciever.purge();
}
logger.log(Level.INFO, "Connected successfully to: " + listenRMQId.getDescriptor());
} catch (IOException e) {
e.printStackTrace();
logSevere("RMQServer::InitListenQ", "InitListenQ() failed", e);
logSevere("RMQServer::InitListenQ", "failed on rmqId: " + listenRMQId.getDescriptor() + " e:", e);
return false;
}
catch (TimeoutException e) {
e.printStackTrace();
logSevere("RMQServer::InitListenQ", "InitListenQ() failed on timeout", e);
logSevere("RMQServer::InitListenQ", "failed on rmqId: "+ listenRMQId.getDescriptor() + " e:", e);
return false;
}
return true;
......@@ -132,7 +137,17 @@ public class RMQServer extends ITMManager {
public void HandleMsg() throws ClassNotFoundException, IOException
{
try {
// wait for message to arrive
if (mRMQReciever == null) {
// failed to create a receiver at initialization stage
// retry untill we succeeded
logger.log(Level.INFO, "Trying to connect to: " + listenRMQId.getDescriptor() + "...");
if (InitListenQ() == false) {
sleep(CONNECTION_RETRY_TIMEOUT);
return;
}
}
// wait for message to arrive ...
RMQTextMessage rmqMsg = mRMQReciever.recieveTextMessageWithProps(0);
// parse the message, but only the basic fields needed for routing
......
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 sign in to comment