Package com.taobao.metamorphosis

Examples of com.taobao.metamorphosis.Message


        final ByteBuffer buf = ByteBuffer.allocate((int) msgSet.getSizeInBytes());
        msgSet.read(buf, 0);
        final MessageIterator it = new MessageIterator("topic1", buf.array());
        int count = 0;
        while (it.hasNext()) {
            final Message msg = it.next();
            assertTrue(new String(msg.getData()).startsWith("msg"));
            count++;
        }
        assertEquals(2, count);
    }
View Full Code Here


            buf.flip();

            final DecodedMessage decodedMessage1 = MessageUtils.decodeMessage(this.topic, buf.array(), 0);
            final DecodedMessage decodedMessage2 =
                    MessageUtils.decodeMessage(this.topic, buf.array(), decodedMessage1.newOffset);
            final Message msg1 = new Message(this.topic, "hello".getBytes());
            MessageAccessor.setId(msg1, id1);
            final Message msg2 = new Message(this.topic, "world".getBytes());
            MessageAccessor.setId(msg2, id2);
            assertEquals(msg1, decodedMessage1.message);
            assertEquals(msg2, decodedMessage2.message);
        }
        finally {
View Full Code Here

            buf.flip();

            final DecodedMessage decodedMessage1 = MessageUtils.decodeMessage(this.topic, buf.array(), 0);
            final DecodedMessage decodedMessage2 =
                    MessageUtils.decodeMessage(this.topic, buf.array(), decodedMessage1.newOffset);
            final Message msg1 = new Message(this.topic, "hello".getBytes());
            MessageAccessor.setId(msg1, id1);
            final Message msg2 = new Message(this.topic, "world".getBytes());
            MessageAccessor.setId(msg2, id2);
            assertEquals(msg1, decodedMessage1.message);
            assertEquals(msg2, decodedMessage2.message);
        }
        finally {
View Full Code Here

            payLoadLen = msgLen - 4 - attrLen;
        }
        // ��ȡpayload
        final byte[] payload = new byte[payLoadLen];
        System.arraycopy(data, payLoadOffset, payload, 0, payLoadLen);
        final Message msg = new Message(topic, payload);
        MessageAccessor.setFlag(msg, flag);
        msg.setAttribute(attribute);
        MessageAccessor.setId(msg, id);
        return new DecodedMessage(payLoadOffset + payLoadLen, msg, ByteBuffer.wrap(data, offset, payLoadOffset
            + payLoadLen - offset));
    }
View Full Code Here

        final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line = null;
        while ((line = readLine(reader)) != null) {
            // send message
            try {
                producer.sendMessage(new Message(topic, line.getBytes()), new SendMessageCallback() {

                    @Override
                    public void onMessageSent(final SendResult result) {
                        if (result.isSuccess()) {
                            System.out.println("Send message successfully,sent to " + result.getPartition());
View Full Code Here

        final String topic = "meta-test";
        final TopicBrowser browser = sessionFactory.createTopicBrowser(topic);

        Iterator<Message> it = browser.iterator();
        while (it.hasNext()) {
            Message msg = it.next();
            System.out.println("message body:" + new String(msg.getData()));
        }

        browser.shutdown();
        sessionFactory.shutdown();
    }
View Full Code Here

        final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line = null;
        while ((line = readLine(reader)) != null) {
            // send message
            final SendResult sendResult = producer.sendMessage(new Message(topic, line.getBytes()));
            // check result
            if (!sendResult.isSuccess()) {
                System.err.println("Send message failed,error message:" + sendResult.getErrorMessage());
            }
            else {
View Full Code Here

        final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line = null;
        while ((line = readLine(reader)) != null) {
            // send message
            try {
                producer.sendMessage(new Message(topic, line.getBytes()), new SendMessageCallback() {

                    @Override
                    public void onMessageSent(final SendResult result) {
                        if (result.isSuccess()) {
                            System.out.println("Send message successfully,sent to " + result.getPartition());
View Full Code Here

        while ((line = readLine(reader)) != null) {
            try {
                // ��ʼ����
                producer.beginTransaction();
                // �������ڷ���������Ϣ
                if (!producer.sendMessage(new Message(topic, line.getBytes())).isSuccess()) {
                    // ����ʧ�ܣ������ع�
                    producer.rollback();
                    continue;
                }
                if (!producer.sendMessage(new Message(topic, line.getBytes())).isSuccess()) {
                    producer.rollback();
                    continue;
                }
                // �ύ
                producer.commit();
View Full Code Here

        final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line = null;
        while ((line = readLine(reader)) != null) {
            // send message
            final SendResult sendResult = producer.sendMessage(new Message(topic, line.getBytes()));
            // check result
            if (!sendResult.isSuccess()) {
                System.err.println("Send message failed,error message:" + sendResult.getErrorMessage());
            }
            else {
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.