Package com.taobao.metamorphosis

Examples of com.taobao.metamorphosis.Message


            private void innerRecover(final Store store, final MessageRecoverer recoverer, final AtomicLong count,
                    final String name) throws IOException, Exception {
                final Iterator<byte[]> it = store.iterator();
                while (it.hasNext()) {
                    final byte[] key = it.next();
                    final Message msg =
                            (Message) LocalMessageStorageManager.this.deserializer.decodeObject(store.get(key));
                    recoverer.handle(msg);
                    try {
                        store.remove(key);
                        count.incrementAndGet();
View Full Code Here


            private int innerRecover(Store store, final MessageRecoverer recoverer) throws IOException, Exception {
                Iterator<byte[]> it = store.iterator();
                int count = 0;
                while (it.hasNext()) {
                    byte[] key = it.next();
                    Message msg =
                            (Message) OrderedLocalMessageStorageManager.this.deserializer.decodeObject(store.get(key));
                    recoverer.handle(msg);
                    try {
                        store.remove(key);
                        count++;
View Full Code Here

    }


    public SendResultWrapper sendMessage(long timeout) {
        SendResultWrapper result = new SendResultWrapper();
        Message message = this.nextMessage();
        result.setMessage(message);
        try {
            SendResult sendResult = this.producer.sendMessage(message, timeout, TimeUnit.MILLISECONDS);
            result.setSendResult(sendResult);
        }
View Full Code Here

        return statsResult;
    }


    private Message nextMessage() {
        return new Message(this.topic, this.data, String.valueOf(System.currentTimeMillis()));
    }
View Full Code Here

                // ��ֹ��һ�δ�0-offset����̫�������.
                if (i++ >= 3) {
                    break;
                }
                while (it.hasNext()) {
                    final Message msg = it.next();
                    result.addMessage(msg);
                    // System.out.println("Receive message " + new
                    // String(msg.getData()));
                }
                offset += it.getOffset();
View Full Code Here

            final List<DecodeMessage> msgList = new ArrayList<DecodeMessage>();
            // ������Ϣ
            long msgOffset = 0;
            while (it.hasNext()) {
                try {
                    final Message msg = it.next();
                    msgList.add(new DecodeMessage(msg.getId(), startOffset + it.getOffset()));
                    msgOffset = it.getOffset();
                }
                catch (final InvalidMessageException e) {
                    // �����ϲ����������������Ԥ����һ���Ǵ�ӡ��־
                    log.error("Message was corrupted,partition=" + store.getDescription() + ",offset=" + msgOffset);
View Full Code Here

            int count = 0;
            List<Long> inTransactionMsgIds = new ArrayList<Long>();
            while (it.hasNext()) {
                final int prevOffset = it.getOffset();
                try {
                    final Message msg = it.next();
                    // If the message is processed before,don't process it
                    // again.
                    if (this.isProcessed(msg.getId(), group)) {
                        continue;
                    }
                    MessageAccessor.setPartition(msg, partition);
                    boolean accept = this.isAcceptable(request, filter, group, msg);
                    if (accept) {
                        currentTopicRegInfo.set(request.getTopicPartitionRegInfo().clone(it));
                        try {
                            listener.recieveMessages(msg);
                        }
                        finally {
                            currentTopicRegInfo.remove();
                        }
                    }
                    // rollback message if it is in rollback only state.
                    if (MessageAccessor.isRollbackOnly(msg)) {
                        it.setOffset(prevOffset);
                        break;
                    }
                    if (partition.isAutoAck()) {
                        count++;
                        this.markProcessed(msg.getId(), group);
                    }
                    else {
                        // �ύ���߻ع�����������ѭ��
                        if (partition.isAcked()) {
                            count++;
                            // mark all in transaction messages were processed.
                            for (Long msgId : inTransactionMsgIds) {
                                this.markProcessed(msgId, group);
                            }
                            this.markProcessed(msg.getId(), group);
                            break;
                        }
                        else if (partition.isRollback()) {
                            break;
                        }
                        else {
                            inTransactionMsgIds.add(msg.getId());
                            // �����ύҲ���ǻع�������������
                            count++;
                        }
                    }
                }
View Full Code Here


        private boolean processWhenRetryTooMany(final FetchRequest request, final MessageIterator it) {
            if (SimpleFetchManager.this.isRetryTooMany(request)) {
                try {
                    final Message couldNotProecssMsg = it.next();
                    MessageAccessor.setPartition(couldNotProecssMsg, request.getPartitionObject());
                    MetaStatLog.addStat(null, StatConstants.SKIP_MSG_COUNT, couldNotProecssMsg.getTopic());
                    SimpleFetchManager.this.consumer.appendCouldNotProcessMessage(couldNotProecssMsg);
                }
                catch (final InvalidMessageException e) {
                    MetaStatLog.addStat(null, StatConstants.INVALID_MSG_STAT, request.getTopic());
                    // ��Ϣ��Ƿ�����ȡ��Чoffset�����·����ѯ
View Full Code Here

        }

        if (payload == null) {
            throw new IllegalArgumentException("Empty payload");
        }
        return new Message(this.topic, payload, this.attribute);
    }
View Full Code Here

                                RecoverStorageManager.this.subscribeInfoManager.getMessageListener(topic, group);
                        final Iterator<byte[]> it = store.iterator();
                        int count = 0;
                        while (it.hasNext()) {
                            final byte[] key = it.next();
                            final Message msg =
                                    (Message) RecoverStorageManager.this.deserializer.decodeObject(store.get(key));
                            if (msg != null) {
                                RecoverStorageManager.this.receiveMessage(store, key, msg, listener);
                            }
                            count++;
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.