Skip to content

Commit

Permalink
#4 使用Eclipse代码样式格式化
Browse files Browse the repository at this point in the history
  • Loading branch information
vintagewang committed Jul 29, 2013
1 parent 53bd2c7 commit 9e91d72
Show file tree
Hide file tree
Showing 16 changed files with 274 additions and 149 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
package com.alibaba.rocketmq.test.producer;

import java.io.File;
import java.util.List;

import junit.framework.Assert;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import com.alibaba.rocketmq.client.exception.MQBrokerException;
import com.alibaba.rocketmq.client.exception.MQClientException;
import com.alibaba.rocketmq.client.producer.*;
import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
import com.alibaba.rocketmq.client.producer.MQProducer;
import com.alibaba.rocketmq.client.producer.MessageQueueSelector;
import com.alibaba.rocketmq.client.producer.SendCallback;
import com.alibaba.rocketmq.client.producer.SendResult;
import com.alibaba.rocketmq.client.producer.SendStatus;
import com.alibaba.rocketmq.common.message.Message;
import com.alibaba.rocketmq.common.message.MessageQueue;
import com.alibaba.rocketmq.remoting.exception.RemotingException;
import com.alibaba.rocketmq.test.BaseTest;
import junit.framework.Assert;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import java.io.File;
import java.util.List;


public class ProducerTest extends BaseTest {
Expand All @@ -32,15 +39,18 @@ public void testInit() throws Exception {


@Test
public void testProducerMsg() throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
Message msg = new Message("TopicTest", "TagA", "TESTKEY", ("Hello RocketMQ from producerMsg").getBytes());
public void testProducerMsg() throws MQClientException, RemotingException, MQBrokerException,
InterruptedException {
Message msg =
new Message("TopicTest", "TagA", "TESTKEY", ("Hello RocketMQ from producerMsg").getBytes());
SendResult sendResult = producer.send(msg);
Assert.assertEquals(SendStatus.SEND_OK, sendResult.getSendStatus());
}


@Test
public void testProducerOrderMsg() throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
public void testProducerOrderMsg() throws MQClientException, RemotingException, MQBrokerException,
InterruptedException {
MessageQueueSelector selector = new MessageQueueSelector() {
@Override
public MessageQueue select(List<MessageQueue> mqs, Message msg, Object arg) {
Expand All @@ -49,7 +59,8 @@ public MessageQueue select(List<MessageQueue> mqs, Message msg, Object arg) {
return mqs.get(index);
}
};
Message msg = new Message("TopicTest", "TagA", "TESTKEY", ("Hello RocketMQ from producerMsg").getBytes());
Message msg =
new Message("TopicTest", "TagA", "TESTKEY", ("Hello RocketMQ from producerMsg").getBytes());
SendResult sendResult = producer.send(msg, selector, 1);
Assert.assertEquals(SendStatus.SEND_OK, sendResult.getSendStatus());
}
Expand All @@ -60,17 +71,21 @@ public MessageQueue select(List<MessageQueue> mqs, Message msg, Object arg) {
// // TODO Auto-generated constructor stub
// }
@Test
public void testProducerDelayMsg() throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
Message msg = new Message("TopicTest", "TagA", "TESTKEY", ("Hello RocketMQ from producerMsg").getBytes());
public void testProducerDelayMsg() throws MQClientException, RemotingException, MQBrokerException,
InterruptedException {
Message msg =
new Message("TopicTest", "TagA", "TESTKEY", ("Hello RocketMQ from producerMsg").getBytes());
msg.setDelayTimeLevel(4);
SendResult sendResult = producer.send(msg);
Assert.assertEquals(SendStatus.SEND_OK, sendResult.getSendStatus());
}


@Test
public void testProducerMsgAndCreateTopic() throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
Message msg = new Message("TopicTest1", "TagA", "TESTKEY", ("Hello RocketMQ from producerMsg").getBytes());
public void testProducerMsgAndCreateTopic() throws MQClientException, RemotingException,
MQBrokerException, InterruptedException {
Message msg =
new Message("TopicTest1", "TagA", "TESTKEY", ("Hello RocketMQ from producerMsg").getBytes());
SendResult sendResult = producer.send(msg);
Assert.assertEquals(SendStatus.SEND_OK, sendResult.getSendStatus());
}
Expand All @@ -95,8 +110,10 @@ public void testClientCreateTopicNoOrder() throws MQClientException {
// }
@Test
// 发送消息API支持三种通信方式
public void testProducerSynMsg() throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
Message msg = new Message("TopicTest", "TagA", "TESTKEY", ("Hello RocketMQ from producerMsg").getBytes());
public void testProducerSynMsg() throws MQClientException, RemotingException, MQBrokerException,
InterruptedException {
Message msg =
new Message("TopicTest", "TagA", "TESTKEY", ("Hello RocketMQ from producerMsg").getBytes());
SendResult sendResult = producer.send(msg);
Assert.assertEquals(SendStatus.SEND_OK, sendResult.getSendStatus());
}
Expand All @@ -119,15 +136,17 @@ public void onException(Throwable e) {
}

};
Message msg = new Message("TopicTest", "TagA", "TESTKEY", ("Hello RocketMQ from producerMsg").getBytes());
Message msg =
new Message("TopicTest", "TagA", "TESTKEY", ("Hello RocketMQ from producerMsg").getBytes());
producer.send(msg, sendCallback);
}


@Test
// 发送消息API支持三种通信方式
public void testProducerOneWayMsg() throws MQClientException, RemotingException, InterruptedException {
Message msg = new Message("TopicTest", "TagA", "TESTKEY", ("Hello RocketMQ from producerMsg").getBytes());
Message msg =
new Message("TopicTest", "TagA", "TESTKEY", ("Hello RocketMQ from producerMsg").getBytes());
producer.sendOneway(msg);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

/**
* 所有运维接口都在这里实现
*
*
* @author shijia.wxr<[email protected]>
* @since 2013-7-14
*/
Expand All @@ -49,113 +49,140 @@ public DefaultMQAdminExt(final String adminExtGroup) {
this.adminExtGroup = adminExtGroup;
}


@Override
public void createTopic(String key, String newTopic, int queueNum) throws MQClientException {
defaultMQAdminExtImpl.createTopic(key, newTopic, queueNum);
}


@Override
public long searchOffset(MessageQueue mq, long timestamp) throws MQClientException {
return defaultMQAdminExtImpl.searchOffset(mq, timestamp);
}


@Override
public long maxOffset(MessageQueue mq) throws MQClientException {
return defaultMQAdminExtImpl.maxOffset(mq);
}


@Override
public long minOffset(MessageQueue mq) throws MQClientException {
return defaultMQAdminExtImpl.minOffset(mq);
}


@Override
public long earliestMsgStoreTime(MessageQueue mq) throws MQClientException {
return defaultMQAdminExtImpl.earliestMsgStoreTime(mq);
}


@Override
public MessageExt viewMessage(String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
public MessageExt viewMessage(String msgId) throws RemotingException, MQBrokerException,
InterruptedException, MQClientException {
return defaultMQAdminExtImpl.viewMessage(msgId);
}


@Override
public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end) throws MQClientException, InterruptedException {
public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
throws MQClientException, InterruptedException {
return defaultMQAdminExtImpl.queryMessage(topic, key, maxNum, begin, end);
}


@Override
public void start() throws MQClientException {
defaultMQAdminExtImpl.start();
}


@Override
public void shutdown() {
defaultMQAdminExtImpl.shutdown();
}


@Override
public void createAndUpdateTopicConfigByCluster(String cluster, TopicConfig config) {
defaultMQAdminExtImpl.createAndUpdateTopicConfigByCluster(cluster, config);
}


@Override
public void createAndUpdateTopicConfigByAddr(String addr, TopicConfig config) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
public void createAndUpdateTopicConfigByAddr(String addr, TopicConfig config) throws RemotingException,
MQBrokerException, InterruptedException, MQClientException {
defaultMQAdminExtImpl.createAndUpdateTopicConfigByAddr(addr, config);
}


@Override
public void createAndUpdateSubscriptionGroupConfigByCluster(String cluster, SubscriptionGroupConfig config) {
defaultMQAdminExtImpl.createAndUpdateSubscriptionGroupConfigByCluster(cluster, config);
}


@Override
public void createAndUpdateSubscriptionGroupConfigByAddr(String addr, SubscriptionGroupConfig config) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
public void createAndUpdateSubscriptionGroupConfigByAddr(String addr, SubscriptionGroupConfig config)
throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
defaultMQAdminExtImpl.createAndUpdateSubscriptionGroupConfigByAddr(addr, config);
}


@Override
public SubscriptionGroupConfig examineSubscriptionGroupConfig(String addr, String group) {
return defaultMQAdminExtImpl.examineSubscriptionGroupConfig(addr, group);
}


@Override
public TopicConfig examineTopicConfig(String addr, String topic) {
return defaultMQAdminExtImpl.examineTopicConfig(addr, topic);
}


@Override
public TopicOffsetTable examineTopicOffset(String topic) {
return defaultMQAdminExtImpl.examineTopicOffset(topic);
}


@Override
public ConsumerProgress examineConsumerProgress(String consumerGroup, String topic) {
return defaultMQAdminExtImpl.examineConsumerProgress(consumerGroup, topic);
}


@Override
public void putKVConfig(String namespace, String key, String value) {
defaultMQAdminExtImpl.putKVConfig(namespace, key, value);
}


@Override
public String getKVConfig(String namespace, String key) {
return defaultMQAdminExtImpl.getKVConfig(namespace, key);
}


public String getAdminExtGroup() {
return adminExtGroup;
}


public void setAdminExtGroup(String adminExtGroup) {
this.adminExtGroup = adminExtGroup;
}


public String getCreateTopicKey() {
return createTopicKey;
}


public void setCreateTopicKey(String createTopicKey) {
this.createTopicKey = createTopicKey;
}
Expand Down
Loading

0 comments on commit 9e91d72

Please sign in to comment.