Package com.taobao.metamorphosis

Examples of com.taobao.metamorphosis.Message


    @Test
    public void testBuildMessageWithPayload() throws Exception {
        MessageBuilder mb = MessageBuilder.withTopic("test");
        mb.withAttribute("a attribute").withPayload(new byte[128]);

        Message msg = mb.build();
        assertNotNull(msg);
        assertEquals("test", msg.getTopic());
        assertEquals("a attribute", msg.getAttribute());
        assertTrue(msg.hasAttribute());
        byte[] data = msg.getData();
        assertEquals(128, data.length);
    }
View Full Code Here


    }


    @Test
    public void testSendMessage_swichToNomal() throws Exception {
        final Message message = this.createDefaultMessage();
        // �����Ѿ�����,���ػ������Ϣ����Ϊ0���л�Ϊ��������ģʽ�����ѱ�����Ϣд�������

        EasyMock.expect(this.producer.getLocalMessageCount(message.getTopic(), this.partition)).andReturn(0);
        EasyMock.expect(this.producer.selectPartition(message)).andReturn(new Partition("0-0"));
        EasyMock.expect(this.producer.sendMessageToServer(message, 10000, TimeUnit.MILLISECONDS, true)).andReturn(null);

        this.mocksControl.replay();
        this.sender.sendMessage(message, 10000, TimeUnit.MILLISECONDS);
View Full Code Here

    @Test
    public void testSendMessage_PartitionNumRight_butHaveFewLocalMessage() throws Exception {
        // �����Ѿ�����,���ػ�������������Ϣ��ͣ��һ���ټ��,����n�κ󻹽�������·���Ļ�,������Ϣд����

        final Message message = this.createDefaultMessage();
        EasyMock.expect(this.producer.getLocalMessageCount(message.getTopic(), this.partition)).andReturn(10).times(3);
        EasyMock.expect(this.producer.selectPartition(message)).andReturn(new Partition("0-0")).times(3);
        EasyMock.expect(this.producer.saveMessageToLocal(message, this.partition, 10000, TimeUnit.MILLISECONDS))
            .andReturn(null);
        this.producer.tryRecoverMessage(message.getTopic(), this.partition);
        EasyMock.expectLastCall().times(3);
        this.mocksControl.replay();
        this.sender.sendMessage(message, 10000, TimeUnit.MILLISECONDS);
        this.mocksControl.verify();
    }
View Full Code Here

    @Test
    public void testSendMessage_PartitionNumRight_butHaveFewLocalMessage2() throws Exception {
        // �����Ѿ�����,���ػ�������������Ϣ��ͣ��һ���ټ��,�ڶ��μ�⵽������Ϣ�ָ����,������Ϣд������,�л�����������ģʽ

        final Message message = this.createDefaultMessage();
        EasyMock.expect(this.producer.getLocalMessageCount(message.getTopic(), this.partition)).andReturn(10);
        EasyMock.expect(this.producer.getLocalMessageCount(message.getTopic(), this.partition)).andReturn(0);
        EasyMock.expect(this.producer.selectPartition(message)).andReturn(new Partition("0-0")).times(2);
        EasyMock.expect(this.producer.sendMessageToServer(message, 10000, TimeUnit.MILLISECONDS, true)).andReturn(null);
        this.producer.tryRecoverMessage(message.getTopic(), this.partition);
        EasyMock.expectLastCall().times(1);
        this.mocksControl.replay();
        this.sender.sendMessage(message, 10000, TimeUnit.MILLISECONDS);
        this.mocksControl.verify();
    }
View Full Code Here


    private Message createDefaultMessage() {
        final String topic = "topic1";
        final byte[] data = "hello".getBytes();
        final Message message = new Message(topic, data);
        return message;
    }
View Full Code Here

            }
        });
        this.mockFilterAndGroup(topic);
        final FetchRequestRunner runner = this.fetchManager.new FetchRequestRunner();
        // EasyMock.expect(this.fetchManager.isRetryTooMany(request)).andReturn(true);
        final Message message = new Message(topic, "hello".getBytes());
        MessageAccessor.setId(message, 1111);
        this.consumer.appendCouldNotProcessMessage(message);
        EasyMock.expectLastCall();

        // offset��������Ϊ������ǰ��Ϣ
View Full Code Here

    @Test
    public void testHandle() throws Exception {
        String topic = "test-topic";
        Partition partition = new Partition(0, 0);
        Message message = new Message(topic, "test".getBytes());
        MessageAccessor.setPartition(message, partition);
        processor.setStorageManager(messageRecoverManager);
        EasyMock.expect(messageRecoverManager.getMessageCount(topic, partition)).andReturn(499999);
        messageRecoverManager.append(message, partition);
        EasyMock.expectLastCall();
View Full Code Here


    @Test
    public void testHandle_unknowPartition() throws Exception {
        String topic = "test-topic";
        Message message = new Message(topic, "test".getBytes());
        processor.setStorageManager(messageRecoverManager);
        EasyMock.expect(messageRecoverManager.getMessageCount(topic, Partition.RandomPartiton)).andReturn(499999);
        messageRecoverManager.append(message, Partition.RandomPartiton);
        EasyMock.expectLastCall();
        mocksControl.replay();
View Full Code Here


    @Test
    public void testHandle_haveTooManyLocalMessages() throws Exception {
        String topic = "test-topic";
        Message message = new Message(topic, "test".getBytes());
        processor.setStorageManager(messageRecoverManager);
        EasyMock.expect(messageRecoverManager.getMessageCount(topic, Partition.RandomPartiton)).andReturn(500001);
        EasyMock.expectLastCall();
        mocksControl.replay();
View Full Code Here

     */
    private synchronized void logObject(final byte[] content) throws IOException {
        this.initMeta();
        if (this.producer != null) {
            this.producer.publish(this.topic);
            this.producer.asyncSendMessage(new Message(this.topic, content));
        }
        else {
            throw new IOException("Null producer");
        }
    }
View Full Code Here

TOP

Related Classes of com.taobao.metamorphosis.Message

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.