Toggle navigation
Toggle navigation
This project
Loading...
Sign in
yangyoupeng
/
microservice
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
yangyoupeng
2016-12-06 13:24:46 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d43d2a5d0ed5b9bc8636a19953e760680293a5fa
d43d2a5d
1 parent
b738cb14
P2PProducer中createQueue方法进行判空操作
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
2 deletions
src/microservice-parent/microservice-msq/src/main/java/com/zhaoonline/message/queue/P2PProducer.java
src/microservice-parent/microservice-msq/src/test/java/com/zhaoonline/message/queue/TestCloudPullTopicConsumer.java
src/microservice-parent/microservice-msq/src/test/java/com/zhaoonline/message/queue/TestUseCloudTopicProducerBuilder.java
src/microservice-parent/microservice-msq/src/main/java/com/zhaoonline/message/queue/P2PProducer.java
View file @
d43d2a5
...
...
@@ -132,6 +132,8 @@ public class P2PProducer implements ProducerInt<MessageObject,Message>{
}
public
void
createQueue
(){
if
(!
queue
.
isQueueExist
()){
queue
.
create
();
}
}
}
...
...
src/microservice-parent/microservice-msq/src/test/java/com/zhaoonline/message/queue/TestCloudPullTopicConsumer.java
View file @
d43d2a5
...
...
@@ -80,8 +80,8 @@ public class TestCloudPullTopicConsumer {
//创建一个topic,并且他包含一个testQueue1;
CloudPullTopicProducer
topicProducer2
=
builder
.
buildCloudTopic
(
topicName
,
true
,
testQueue1
);
topic
Producer2
.
send
(
"hellow world1"
);
topic
=
builder
.
buildTopic
(
topicName
);
topic
.
send
(
"hellow world1"
);
CloudPullTopicConsumer
consumer1
=
builder
.
buildTopicPullConsumer
(
topicName
,
testQueue1
);
Message
msg1
=
consumer1
.
popMessage
();
...
...
src/microservice-parent/microservice-msq/src/test/java/com/zhaoonline/message/queue/TestUseCloudTopicProducerBuilder.java
0 → 100644
View file @
d43d2a5
package
com
.
zhaoonline
.
message
.
queue
;
import
org.junit.Assert
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.aliyun.mns.model.Message
;
public
class
TestUseCloudTopicProducerBuilder
{
@Autowired
CloudTopicProducerBuilder
builder
;
public
void
createTopic
()
throws
Exception
{
String
topicName
=
"testTopic1"
;
String
testQueue1
=
"testQu1eue"
;
TopicProducer
topic
=
builder
.
buildTopic
(
topicName
);
//发送消息
topic
.
send
(
"hellow world1"
);
CloudPullTopicConsumer
consumer1
=
builder
.
buildTopicPullConsumer
(
topicName
,
testQueue1
);
//pop消息
Message
msg1
=
consumer1
.
popMessage
();
Assert
.
assertEquals
(
"hellow world1"
,
msg1
.
getMessageBodyAsRawString
());
//topic删除方法,会连同topci对应queue都删除
topic
.
deleteTopic
();
topic
.
close
();
consumer1
.
close
();
}
}
Please
register
or
login
to post a comment