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
b3e3da3d
authored
Jul 19, 2016
by
Adi Amir
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
make RMQServer work with a test
parent
b8a6ea54
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
103 additions
and
40 deletions
build.gradle
doc/msg-example.txt
src/main/java/rabbitmq/client/RMQRestClient.java
src/main/java/rabbitmq/common/ConnectionWrapper.java
src/main/java/rabbitmq/common/RMQMessage.java
src/main/java/rabbitmq/common/RMQRestRequest.java
src/main/java/rabbitmq/server/RMQHandler.java
src/main/java/rabbitmq/server/RMQServer.java
src/main/java/rabbitmq/server/RMQThread.java
src/test/java/rabbitmq/impl/Receiver.java
src/test/java/rabbitmq/impl/TestRMQHandler.java
build.gradle
View file @
b3e3da3d
...
...
@@ -9,13 +9,13 @@ sourceCompatibility = 1.8
repositories
{
//mavenCentral()
maven
{
url
"http://172.16.1.132:8081/repository/internal"
}
maven
{
url
"http://mandubian-mvn.googlecode.com/svn/trunk/mandubian-mvn/repository"
}
}
}
dependencies
{
compile
'com.rabbitmq:amqp-client:3.6.0'
//'com.rabbitmq:rabbitmq-client:1.3.0'
//compile 'com.google.gdata:core:1.47.1:core-1.47.1'
compile
'com.rabbitmq:amqp-client:3.6.3'
//'com.rabbitmq:rabbitmq-client:1.3.0'
compile
'com.fasterxml.jackson.core:jackson-databind:2.2.3'
compile
'com.ipgallery.common:utils:1.
0.0
'
compile
'com.ipgallery.common:utils:1.
1.2
'
compile
'com.ipgallery.common:itc:1.0.0'
testCompile
group:
'junit'
,
name:
'junit'
,
version:
'4.11'
}
...
...
doc/msg-example.txt
0 → 100644
View file @
b3e3da3d
{
"oc": 1000,
"key": "key00001",
"APP": "testApp",
"METHOD": "GET",
"ENTITY": "transpotation",
"PARAMS": "/street",
"REQUEST_PARAMS": "ts=0",
"CONTENT": null
}
\ No newline at end of file
src/main/java/rabbitmq/client/RMQRestClient.java
View file @
b3e3da3d
...
...
@@ -11,8 +11,8 @@ import rabbitmq.common.RMQKeyGenerator;
import
rabbitmq.common.RMQMessage
;
import
rabbitmq.common.RMQRestRequest
;
import
rabbitmq.common.RMQTextMessage
;
import
utils.
http.simpleHttpClient.SimpleHttpRequest.Method
;
import
utils.
http.simpleRestClient.SimpleRestResponse
;
import
http.simpleHttpClient.SimpleHttpRequest.Method
;
import
http.simpleRestClient.SimpleRestResponse
;
public
class
RMQRestClient
extends
RMQClient
{
...
...
src/main/java/rabbitmq/common/ConnectionWrapper.java
View file @
b3e3da3d
...
...
@@ -36,7 +36,7 @@ public class ConnectionWrapper
private
Channel
createChannel
(
final
String
queueName
,
final
Connection
connection
)
throws
IOException
{
Channel
channel
=
connection
.
createChannel
();
channel
.
queueDeclare
(
queueName
,
fals
e
,
false
,
false
,
null
);
channel
.
queueDeclare
(
queueName
,
tru
e
,
false
,
false
,
null
);
return
channel
;
}
...
...
src/main/java/rabbitmq/common/RMQMessage.java
View file @
b3e3da3d
...
...
@@ -10,8 +10,9 @@ import com.fasterxml.jackson.core.JsonFactory;
import
com.fasterxml.jackson.core.JsonParseException
;
import
com.fasterxml.jackson.core.JsonParser
;
import
com.fasterxml.jackson.core.JsonToken
;
import
itm.ITMMessage
;
import
rabbitmq.common.RMQId
;
import
utils.itm.ITMMessage
;
//
import utils.itm.ITMMessage;
public
class
RMQMessage
extends
ITMMessage
implements
Serializable
{
...
...
@@ -44,6 +45,17 @@ public class RMQMessage extends ITMMessage implements Serializable {
JsonParser
parser
=
factory
.
createParser
(
textMessage
);
return
doParse
(
parser
);
}
public
String
getParameterByName
(
String
name
)
{
if
(
parameters
!=
null
)
return
parameters
.
get
(
name
);
else
return
null
;
}
public
Map
<
String
,
String
>
getParameters
()
{
return
parameters
;
}
protected
boolean
doParse
(
JsonParser
parser
)
throws
JsonParseException
,
IOException
{
...
...
@@ -84,14 +96,7 @@ public class RMQMessage extends ITMMessage implements Serializable {
}
parameters
.
put
(
name
,
value
);
}
public
String
getParameterByName
(
String
name
)
{
if
(
parameters
!=
null
)
return
parameters
.
get
(
name
);
else
return
null
;
}
protected
String
[]
getNextField
(
JsonParser
parser
)
throws
JsonParseException
,
IOException
{
String
[]
result
=
new
String
[
2
];
...
...
src/main/java/rabbitmq/common/RMQRestRequest.java
View file @
b3e3da3d
...
...
@@ -5,7 +5,7 @@ import java.io.Serializable;
import
java.io.StringWriter
;
import
java.util.Map.Entry
;
import
utils.
http.simpleHttpClient.SimpleHttpRequest.Method
;
import
http.simpleHttpClient.SimpleHttpRequest.Method
;
import
com.fasterxml.jackson.core.JsonFactory
;
import
com.fasterxml.jackson.core.JsonGenerator
;
...
...
src/main/java/rabbitmq/server/RMQHandler.java
View file @
b3e3da3d
...
...
@@ -9,9 +9,7 @@ public abstract class RMQHandler {
protected
RMQId
listenerRmqId
=
null
;
protected
String
apiContextPath
=
null
;
public
RMQHandler
()
{
}
public
RMQHandler
(
RMQId
listenerRmqId
,
String
apiContextPath
)
{
...
...
src/main/java/rabbitmq/server/RMQServer.java
View file @
b3e3da3d
...
...
@@ -32,9 +32,9 @@ import com.rabbitmq.client.ShutdownSignalException;
//import rabbitmq.reciever.RMQMessage;
import
rabbitmq.common.RMQReciever
;
import
rabbitmq.common.RMQTextMessage
;
import
utils.
common.SimpleLogger
;
import
utils.
itm.ITMManager
;
import
utils.
itm.ITMThread
;
import
common.SimpleLogger
;
import
itm.ITMManager
;
import
itm.ITMThread
;
public
class
RMQServer
extends
ITMManager
{
...
...
src/main/java/rabbitmq/server/RMQThread.java
View file @
b3e3da3d
...
...
@@ -7,7 +7,7 @@ import java.util.logging.Level;
import
com.fasterxml.jackson.core.JsonParseException
;
import
rabbitmq.common.*
;
import
utils.
itm.ITMThread
;
import
itm.ITMThread
;
public
class
RMQThread
extends
ITMThread
{
...
...
src/test/java/rabbitmq/impl/Receiver.java
View file @
b3e3da3d
package
rabbitmq
.
impl
;
import
com.rabbitmq.client.ConsumerCancelledException
;
import
com.rabbitmq.client.ShutdownSignalException
;
import
rabbitmq.common.RMQId
;
import
rabbitmq.server.RMQHandler
;
import
rabbitmq.server.RMQServer
;
import
java.io.IOException
;
public
class
Receiver
{
// public static void main(String[] args) throws IOException, ClassNotFoundException, ShutdownSignalException, ConsumerCancelledException, InterruptedException {
//
//// RMQServerWrapper server = new RMQServerWrapper("MyQueue", "localhost");
//// byte[] recieveMessage = server.recieveMessage();
////
//// ByteArrayInputStream bis = new ByteArrayInputStream(recieveMessage);
////
//// ObjectInput in = new ObjectInputStream(bis);
//// Object readObject;
//// try {
//// readObject = in.readObject();
//// } finally {
//// }
////
//// ModelHierarchy deserializedCar = (ModelHierarchy)readObject;
// }
public
static
void
main
(
String
[]
args
)
throws
IOException
,
ClassNotFoundException
,
ShutdownSignalException
,
ConsumerCancelledException
,
InterruptedException
{
int
i
=
0
;
RMQServer
mbiServer
=
new
RMQServer
();
Boolean
bSuccess
=
mbiServer
.
Init
(
"testApp"
,
"/logs"
,
"myFirstQ@localhost"
,
1
,
100
);
if
(
bSuccess
==
false
)
{
System
.
out
.
println
(
"failed to mbiServer.Init()"
);
return
;
}
RMQHandler
rmqHandler
=
new
TestRMQHandler
(
new
RMQId
(
"myFirstQ@localhost"
),
"testApp"
);
mbiServer
.
setHandler
(
rmqHandler
);
mbiServer
.
Run
();
}
}
src/test/java/rabbitmq/impl/TestRMQHandler.java
0 → 100644
View file @
b3e3da3d
package
rabbitmq
.
impl
;
import
rabbitmq.common.RMQId
;
import
rabbitmq.common.RMQMessage
;
import
rabbitmq.server.RMQHandler
;
import
java.util.Iterator
;
import
java.util.Map
;
/**
* Created by adi on 18/07/16.
*/
public
class
TestRMQHandler
extends
RMQHandler
{
public
TestRMQHandler
(
RMQId
listenerRmqId
,
String
apiContextPath
)
{
super
(
listenerRmqId
,
apiContextPath
);
}
public
void
handleRequest
(
RMQMessage
message
)
{
String
msg
=
"Received nsg: "
;
msg
+=
" oc:"
+
message
.
getOpCode
();
msg
+=
" key:"
+
message
.
getKey
();
Map
<
String
,
String
>
paramsMap
=
message
.
getParameters
();
Iterator
it
=
paramsMap
.
entrySet
().
iterator
();
while
(
it
.
hasNext
())
{
Map
.
Entry
entry
=
(
Map
.
Entry
)
it
.
next
();
msg
+=
" "
+
entry
.
getKey
()
+
":"
+
entry
.
getValue
();
}
System
.
out
.
println
(
msg
);
}
}
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