Package com.taobao.metamorphosis.client.consumer

Examples of com.taobao.metamorphosis.client.consumer.ConsumerConfig


        // subscribed topic
        final String topic = "meta-test";
        // consumer group
        final String group = "meta-example";
        // create consumer,ǿ�ҽ���ʹ�õ���
        ConsumerConfig consumerConfig = new ConsumerConfig(group);
        // Ĭ������ȡ�ӳ�Ϊ5�룬�������ó�100���룬�����ʵ��Ӧ��Ҫ�������á�
        consumerConfig.setMaxDelayFetchTimeInMills(100);
        final MessageConsumer consumer = sessionFactory.createConsumer(consumerConfig);
        // subscribe topic
        consumer.subscribe(topic, 1024 * 1024, new MessageListener() {

            @Override
View Full Code Here


    @Test
    public void sendConsume() throws Exception {
        this.createProducer();
        this.producer.publish(this.topic);
        ConsumerConfig consumerConfig = new ConsumerConfig("group1");
        consumerConfig.setMaxFetchRetries(10);
        this.consumer = this.sessionFactory.createConsumer(consumerConfig);
        final AtomicInteger i = new AtomicInteger(0);
        try {
            // ����֮ǰ�ȷ��ͼ�����Ϣ
            int count = 2;
            final int failTimes = 2;
            assertTrue(failTimes < consumerConfig.getMaxFetchRetries());
            this.sendMessage(count, "hello", this.topic);

            this.consumer.subscribe(topic, 1024 * 1024, new MessageListener() {

                public void recieveMessages(final Message messages) {
View Full Code Here


    @Test
    public void testSubscribeOneTopic() throws Exception {
        Map<MetaqTopic, MyListener> subscribers = new HashMap<MetaqTopic, MyListener>();
        ConsumerConfig consumerConfig = new ConsumerConfig("group1");
        MyListener listener = new MyListener();
        subscribers.put(new MetaqTopic("topic1", 1024, consumerConfig), listener);
        this.container.setSubscribers(subscribers);

        EasyMock.expect(this.sessionFactory.createConsumer(consumerConfig)).andReturn(this.consumer);
View Full Code Here


    @Test
    public void testSubscribeTwoTopics() throws Exception {
        Map<MetaqTopic, MyListener> subscribers = new HashMap<MetaqTopic, MyListener>();
        ConsumerConfig consumerConfig1 = new ConsumerConfig("group1");
        MyListener listener1 = new MyListener();
        subscribers.put(new MetaqTopic("topic1", 1024, consumerConfig1), listener1);
        ConsumerConfig consumerConfig2 = new ConsumerConfig("group1");
        MyListener listener2 = new MyListener();
        subscribers.put(new MetaqTopic("topic2", 1024 * 1024, consumerConfig2), listener2);
        this.container.setSubscribers(subscribers);

        EasyMock.expect(this.sessionFactory.createConsumer(consumerConfig1)).andReturn(this.consumer);
View Full Code Here


    @Test(expected = IllegalArgumentException.class)
    public void testSubscribeTwoTopicsShareConsumerWithoutDefaultTopic() throws Exception {
        Map<MetaqTopic, MyListener> subscribers = new HashMap<MetaqTopic, MyListener>();
        ConsumerConfig consumerConfig1 = new ConsumerConfig("group1");
        MyListener listener1 = new MyListener();
        subscribers.put(new MetaqTopic("topic1", 1024, consumerConfig1), listener1);
        ConsumerConfig consumerConfig2 = new ConsumerConfig("group1");
        MyListener listener2 = new MyListener();
        subscribers.put(new MetaqTopic("topic2", 1024 * 1024, consumerConfig2), listener2);
        this.container.setSubscribers(subscribers);
        this.container.setShareConsumer(true);
        this.control.replay();
View Full Code Here


    @Test
    public void testSubscribeTwoTopicsShareTopic() throws Exception {
        Map<MetaqTopic, MyListener> subscribers = new HashMap<MetaqTopic, MyListener>();
        ConsumerConfig consumerConfig1 = new ConsumerConfig("group1");
        MyListener listener1 = new MyListener();
        subscribers.put(new MetaqTopic("topic1", 1024, consumerConfig1), listener1);
        ConsumerConfig consumerConfig2 = new ConsumerConfig("group1");
        MyListener listener2 = new MyListener();
        this.container.setSubscribers(subscribers);
        this.container.setShareConsumer(true);
        this.container.setDefaultTopic(new MetaqTopic("topic2", 1024 * 1024, consumerConfig2));
        this.container.setDefaultMessageListener(listener2);
View Full Code Here


    @Test(expected = IllegalStateException.class)
    public void testShareConsumerAndProvideDefaultTopic() throws Exception {
        Map<MetaqTopic, MyListener> subscribers = new HashMap<MetaqTopic, MyListener>();
        ConsumerConfig consumerConfig = new ConsumerConfig("group1");
        MyListener listener = new MyListener();
        subscribers.put(new MetaqTopic("topic1", 1024, consumerConfig), listener);
        this.container.setSubscribers(subscribers);
        this.container.setDefaultMessageListener(listener);
        this.control.replay();
View Full Code Here

public class MetaQTopicUnitTest {

    @Test
    public void testAsMapKey() {
        MetaqTopic metaQTopic1 = new MetaqTopic("test", 1024, new ConsumerConfig("test-group"));
        MetaqTopic metaQTopic2 = new MetaqTopic("test", 1024, new ConsumerConfig("test-group"));
        Map<MetaqTopic, Boolean> map = new HashMap<MetaqTopic, Boolean>();
        assertEquals(metaQTopic1, metaQTopic2);
        map.put(metaQTopic1, true);
        assertEquals("test", metaQTopic1.getTopic());
        assertEquals("test-group", metaQTopic1.getConsumerConfig().getGroup());
View Full Code Here

    public MsgReceiver(String serverUrl, MonitorConfig monitorConfig) throws MetaClientException {
        this.serverUrl = serverUrl;
        MetaClientConfig metaClientConfig = monitorConfig.metaClientConfigOf(serverUrl);
        this.sessionFactory = new MetaMessageSessionFactory(metaClientConfig);
        this.consumer = this.sessionFactory.createConsumer(new ConsumerConfig(group));
    }
View Full Code Here


    public static void main(String[] args) {
        TopologyBuilder builder = new TopologyBuilder();
        builder.setSpout("spout",
            new MetaSpout(initMetaConfig(), new ConsumerConfig("storm-spout"), new StringScheme()), 10);
        builder.setBolt("bolt", new FailEveryOther()).shuffleGrouping("spout");

        Config conf = new Config();
        // Set the consume topic
        conf.put(MetaSpout.TOPIC, "neta-test");
View Full Code Here

TOP

Related Classes of com.taobao.metamorphosis.client.consumer.ConsumerConfig

Copyright © 2018 www.massapicom. 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.