Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
ipgallery.common.java
/
rabbitmq
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6fbbf406
authored
Aug 04, 2016
by
Adi Amir
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
general improvements in server side
parent
b3e3da3d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
16 deletions
build.gradle
doc/msg-example.txt
src/main/java/rabbitmq/server/RMQServer.java
build.gradle
View file @
6fbbf406
group
'com.ipgallery.common'
group
'com.ipgallery.common'
version
'1.0.
0
'
version
'1.0.
x
'
apply
plugin:
'java'
apply
plugin:
'java'
apply
plugin:
'maven-publish'
apply
plugin:
'maven-publish'
...
...
doc/msg-example.txt
View file @
6fbbf406
{
{
"oc": 1000,
"oc": 1000,
"key": "key00001",
"key": "key00001",
"APP": "testApp",
"oId": "respQ@localhost",
"METHOD": "GET",
"APP": "test",
"ENTITY": "transpotation",
"METHOD": "GET",
"PARAMS": "/street",
"ENTITY": "transpotation",
"REQUEST_PARAMS": "ts=0",
"PARAMS": "/street",
"CONTENT": null
"REQUEST_PARAMS": "ts=0",
}
"CONTENT": null
\ No newline at end of file
}
\ No newline at end of file
src/main/java/rabbitmq/server/RMQServer.java
View file @
6fbbf406
...
@@ -36,8 +36,11 @@ import common.SimpleLogger;
...
@@ -36,8 +36,11 @@ import common.SimpleLogger;
import
itm.ITMManager
;
import
itm.ITMManager
;
import
itm.ITMThread
;
import
itm.ITMThread
;
import
static
java
.
lang
.
Thread
.
sleep
;
public
class
RMQServer
extends
ITMManager
{
public
class
RMQServer
extends
ITMManager
{
private
final
static
Integer
CONNECTION_RETRY_TIMEOUT
=
10000
;
protected
RMQReciever
mRMQReciever
=
null
;
protected
RMQReciever
mRMQReciever
=
null
;
protected
RMQId
listenRMQId
=
null
;
protected
RMQId
listenRMQId
=
null
;
protected
SimpleLogger
logger
=
null
;
protected
SimpleLogger
logger
=
null
;
...
@@ -95,16 +98,18 @@ public class RMQServer extends ITMManager {
...
@@ -95,16 +98,18 @@ public class RMQServer extends ITMManager {
if
(
isEmptyQueueOnLoad
)
{
if
(
isEmptyQueueOnLoad
)
{
mRMQReciever
.
purge
();
mRMQReciever
.
purge
();
}
}
logger
.
log
(
Level
.
INFO
,
"Connected successfully to: "
+
listenRMQId
.
getDescriptor
());
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
logSevere
(
"RMQServer::InitListenQ"
,
"
InitListenQ() failed
"
,
e
);
logSevere
(
"RMQServer::InitListenQ"
,
"
failed on rmqId: "
+
listenRMQId
.
getDescriptor
()
+
" e:
"
,
e
);
return
false
;
return
false
;
}
}
catch
(
TimeoutException
e
)
{
catch
(
TimeoutException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
logSevere
(
"RMQServer::InitListenQ"
,
"
InitListenQ() failed on timeout
"
,
e
);
logSevere
(
"RMQServer::InitListenQ"
,
"
failed on rmqId: "
+
listenRMQId
.
getDescriptor
()
+
" e:
"
,
e
);
return
false
;
return
false
;
}
}
return
true
;
return
true
;
...
@@ -132,9 +137,19 @@ public class RMQServer extends ITMManager {
...
@@ -132,9 +137,19 @@ public class RMQServer extends ITMManager {
public
void
HandleMsg
()
throws
ClassNotFoundException
,
IOException
public
void
HandleMsg
()
throws
ClassNotFoundException
,
IOException
{
{
try
{
try
{
// wait for message to arrive
if
(
mRMQReciever
==
null
)
{
RMQTextMessage
rmqMsg
=
mRMQReciever
.
recieveTextMessageWithProps
(
0
);
// 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
// parse the message, but only the basic fields needed for routing
// the message to a worker thread
// the message to a worker thread
RMQMessage
baseMsg
=
new
RMQMessage
();
RMQMessage
baseMsg
=
new
RMQMessage
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment