Package com.taobao.metamorphosis

Examples of com.taobao.metamorphosis.Message



    @Test(expected = AvailablePartitionNumException.class)
    public void testGetPartition_availablePartitionsEmpty() throws MetaClientException {
        // ���÷���sΪ��
        Message message = this.createDefaultMessage();
        this.selector.getPartition(message.getTopic(), new ArrayList<Partition>(), message);
    }
View Full Code Here



    @Test
    public void testGetPartition_availablePartitionsChanged_butSelectedPartitionAvailable() throws MetaClientException {
        // ���÷��������˱仯������û��(0-1 -> 1-0),ѡ������ķ�����0-0����������������������������д��
        Message message = this.createDefaultMessage();
        Partition partition =
                this.selector.getPartition(message.getTopic(),
                    Arrays.asList(new Partition("0-0"), new Partition("1-0"), new Partition("2-0")), message);
        Assert.assertEquals(new Partition("0-0"), partition);
    }
View Full Code Here


    @Test(expected = AvailablePartitionNumException.class)
    public void testGetPartition_availablePartitionsChanged_andSelectedPartitionInvalid() throws MetaClientException {
        // ���÷�����������,����ѡ�����ķ�����0-0�����������ڿ��÷�����������û���д�˲����ڵ�һ��������
        Message message = this.createDefaultMessage();
        this.selector.getPartition(message.getTopic(),
            Arrays.asList(new Partition("1-0"), new Partition("2-0"), new Partition("3-0")), message);
    }
View Full Code Here

        // �������÷����˱仯,���÷�������,ѡ������ķ�����0-0������д
        Map<String, List<Partition>> map = new HashMap<String, List<Partition>>();
        map.put(testTopic, Arrays.asList(new Partition("1-0"), new Partition("1-1"), new Partition("2-0")));
        this.selector.setConfigPartitions(map);

        Message message = this.createDefaultMessage();
        Partition partition =
                this.selector.getPartition(message.getTopic(),
                    Arrays.asList(new Partition("0-0"), new Partition("1-0"), new Partition("2-0")), message);
        Assert.assertEquals(new Partition("0-0"), partition);
    }
View Full Code Here

    @Test
    public void testGetPartition_availablePartitionsChanged_butSelectedPartitionAvailable2() throws MetaClientException {
        // ���÷���������(1-0),�������õķ���ѡ��,ѡ�����ķ���(0-0)�����ڿ��÷�����,��������������������������д��

        Message message = this.createDefaultMessage();
        Partition partition =
                this.selector.getPartition(message.getTopic(),
                    Arrays.asList(new Partition("0-0"), new Partition("0-1")), message);
        Assert.assertEquals(new Partition("0-0"), partition);
    }
View Full Code Here

    @Test(expected = AvailablePartitionNumException.class)
    public void testGetPartition_availablePartitionsChanged_butSelectedPartitionAvailable_expception()
            throws MetaClientException {
        // ���÷��������ˣ�0-0��,�������õķ���ѡ��,ѡ�����ķ�����0-0���������ڿ��÷�����

        Message message = this.createDefaultMessage();
        this.selector.getPartition(message.getTopic(), Arrays.asList(new Partition("0-1"), new Partition("1-0")),
            message);
    }
View Full Code Here


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

            final XAMessageProducer messageProducer = (XAMessageProducer) this.producerList.get(j);
            messageProducer.publish(topic);

            for (int i = 0; i < count; i++) {
                final byte[] data = ("hello" + j + i).getBytes();
                final Message msg = new Message(topic, data);
                final XAResource xares = messageProducer.getXAResource();
                final Xid xid =
                        XIDGenerator.createXID(this.formatIdIdGenerator.incrementAndGet(), this.UNIQUE_QUALIFIER);
                xares.start(xid, XAResource.TMNOFLAGS);
                final SendResult result = messageProducer.sendMessage(msg);
View Full Code Here

                    if (filter != null) {
                        MessageIterator it = new MessageIterator(topic, bytes);
                        // reuse the buffer.
                        byteBuffer.clear();
                        while (it.hasNext()) {
                            Message msg = it.next();
                            try {
                                if (filter.accept(group, msg)) {
                                    ByteBuffer msgBuf = it.getCurrentMsgBuf();
                                    // Append current message buffer to result
                                    // buffer.
View Full Code Here

        try {
            this.producer = ((XAMessageSessionFactory) this.sessionFactory).createXAProducer();
            this.producer.publish(this.topic);

            final byte[] data = "hello world".getBytes();
            final Message msg = new Message(this.topic, data);
            final String uniqueQualifier = "testTxTimeout";
            final XAResource xares = ((XAMessageProducer) this.producer).getXAResource();
            final Xid xid = XIDGenerator.createXID(this.formatIdIdGenerator.incrementAndGet(), uniqueQualifier);
            // ��������ʱΪ2��
            xares.setTransactionTimeout(2);
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.