Package com.taobao.meta.test

Source Code of com.taobao.meta.test.TopicBrowserTest

package com.taobao.meta.test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import java.util.Iterator;

import org.junit.Test;

import com.taobao.metamorphosis.Message;
import com.taobao.metamorphosis.client.TopicBrowser;


public class TopicBrowserTest extends BaseMetaTest {

    private final String topic = "test";


    @Test
    public void sendConsume() throws Exception {
        this.createProducer();
        this.producer.publish(this.topic);
        // �����߱���ָ������
        this.createConsumer("group1");

        try {
            // ������Ϣ
            final int count = 100;
            this.sendMessage(count, "hello", this.topic);

            // ���Ľ�����Ϣ����֤������ȷ
            this.subscribe(this.topic, 1024 * 1024, count);
        }
        finally {
            this.producer.shutdown();
            this.consumer.shutdown();
        }

        TopicBrowser topicBrowser = this.sessionFactory.createTopicBrowser(this.topic);
        try {
            Iterator<Message> it = topicBrowser.iterator();
            int n = 0;
            while (it.hasNext()) {
                assertNotNull(it.next());
                n++;
            }
            assertEquals(100, n);
        }
        finally {
            topicBrowser.shutdown();
        }
    }
}
TOP

Related Classes of com.taobao.meta.test.TopicBrowserTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.