yangyoupeng

P2PProducer中createQueue方法进行判空操作

......@@ -132,6 +132,8 @@ public class P2PProducer implements ProducerInt<MessageObject,Message>{
}
public void createQueue(){
if(!queue.isQueueExist()){
queue.create();
}
}
}
......
......@@ -80,8 +80,8 @@ public class TestCloudPullTopicConsumer {
//创建一个topic,并且他包含一个testQueue1;
CloudPullTopicProducer topicProducer2=builder.buildCloudTopic(topicName,true, testQueue1);
topicProducer2.send("hellow world1");
topic=builder.buildTopic(topicName);
topic.send("hellow world1");
CloudPullTopicConsumer consumer1=builder.buildTopicPullConsumer(topicName, testQueue1);
Message msg1=consumer1.popMessage();
......
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();
}
}