Examples of MessageIterator


Examples of com.bloomberglp.blpapi.MessageIterator

    return _ticksCollector.isTickWriterAlive();
  }

  private void processMiscEvents(Event event, Session session) throws Exception {
    s_logger.info("Processing {}", event.eventType());
    MessageIterator msgIter = event.messageIterator();
    while (msgIter.hasNext()) {
      Message msg = msgIter.next();
      s_logger.debug("{}: {}\n", _dateFormat
          .format(Calendar.getInstance().getTime()), msg.messageType());
    }
  }
View Full Code Here

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

                        + "&group=" + this.config.getGroup() + "&maxsize=" + fetchRequest.getMaxSize();
        final GetMethod httpget = new GetMethod(uri);
        try {
            this.httpclient.executeMethod(httpget);
            if (httpget.getStatusCode() == HttpStatus.Success) {
                return new MessageIterator(fetchRequest.getTopic(), httpget.getResponseBody());
            }
            else if (httpget.getStatusCode() == HttpStatus.NotFound) {
                return null;
            }
            else {
View Full Code Here

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

    @Test
    public void testSyncConsume() throws MetaClientException, InterruptedException {
        final SimpleHttpConsumer client = new SimpleHttpConsumer(new HttpClientConfig("localhost", 8080));

        MessageIterator it = null;
        // get messages
        long syncOffSet = this.offset;
        while ((it = client.get("meta-test", new Partition(1, 1), syncOffSet, 99999)) != null) {
            while (it.hasNext()) {
                final Message msg = it.next();
                logger.info("Receive message:" + new String(msg.getData()));
                logger.info("message attribute:" + msg.getAttribute());
            }

            syncOffSet += it.getOffset();
        }

    }
View Full Code Here

Examples of com.taobao.metamorphosis.consumer.MessageIterator

    private void assertMessages(final MessageStore store) throws IOException, InvalidMessageException {
        final FileMessageSet msgSet = (FileMessageSet) store.slice(0, 1024);
        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

Examples of com.taobao.metamorphosis.consumer.MessageIterator

    @Test
    public void testIteratorInSamePartition() throws Exception {
        EasyMock
        .expect(
            this.consumer.get(this.topic, new Partition("0-0"), 0L, this.maxSize, this.timeoutInMills,
                TimeUnit.MILLISECONDS)).andReturn(new MessageIterator(this.topic, this.createMessageBuffer()))
                .once();
        EasyMock
        .expect(
            this.consumer.get(this.topic, new Partition("0-0"), 25L, this.maxSize, this.timeoutInMills,
                TimeUnit.MILLISECONDS)).andReturn(new MessageIterator(this.topic, this.createMessageBuffer()))
                .once();
        this.control.replay();
        Iterator<Message> it = this.browser.iterator();
        if (it.hasNext()) {
            this.assertMsg(it.next());
View Full Code Here

Examples of com.taobao.metamorphosis.consumer.MessageIterator

    @Test
    public void testIteratorMoveOnPartition() throws Exception {
        EasyMock
        .expect(
            this.consumer.get(this.topic, new Partition("0-0"), 0L, this.maxSize, this.timeoutInMills,
                TimeUnit.MILLISECONDS)).andReturn(new MessageIterator(this.topic, this.createMessageBuffer()))
                .once();
        EasyMock.expect(
            this.consumer.get(this.topic, new Partition("0-0"), 25L, this.maxSize, this.timeoutInMills,
                TimeUnit.MILLISECONDS)).andReturn(null);
        EasyMock
        .expect(
            this.consumer.get(this.topic, new Partition("0-1"), 0L, this.maxSize, this.timeoutInMills,
                TimeUnit.MILLISECONDS)).andReturn(new MessageIterator(this.topic, this.createMessageBuffer()))
                .once();
        this.control.replay();
        Iterator<Message> it = this.browser.iterator();
        if (it.hasNext()) {
            this.assertMsg(it.next());
View Full Code Here

Examples of com.taobao.metamorphosis.consumer.MessageIterator

    @Test
    public void testIteratorToEnd() throws Exception {
        EasyMock
        .expect(
            this.consumer.get(this.topic, new Partition("0-0"), 0L, this.maxSize, this.timeoutInMills,
                TimeUnit.MILLISECONDS)).andReturn(new MessageIterator(this.topic, this.createMessageBuffer()))
                .once();
        EasyMock.expect(
            this.consumer.get(this.topic, new Partition("0-0"), 25L, this.maxSize, this.timeoutInMills,
                TimeUnit.MILLISECONDS)).andReturn(null);
        EasyMock
        .expect(
            this.consumer.get(this.topic, new Partition("0-1"), 0L, this.maxSize, this.timeoutInMills,
                TimeUnit.MILLISECONDS)).andReturn(new MessageIterator(this.topic, this.createMessageBuffer()))
                .once();
        EasyMock
        .expect(
            this.consumer.get(this.topic, new Partition("0-1"), 25L, this.maxSize, this.timeoutInMills,
                TimeUnit.MILLISECONDS)).andReturn(null).once();
        EasyMock
        .expect(
            this.consumer.get(this.topic, new Partition("0-2"), 0L, this.maxSize, this.timeoutInMills,
                TimeUnit.MILLISECONDS)).andReturn(new MessageIterator(this.topic, this.createMessageBuffer()))
                .once();
        EasyMock
        .expect(
            this.consumer.get(this.topic, new Partition("0-2"), 25L, this.maxSize, this.timeoutInMills,
                TimeUnit.MILLISECONDS)).andReturn(null).once();
View Full Code Here

Examples of com.taobao.metamorphosis.consumer.MessageIterator

        final FetchRequest request =
                new FetchRequest(broker, 0, new TopicPartitionRegInfo(topic, partition, offset), maxSize);

        final FetchRequestRunner runner = this.fetchManager.new FetchRequestRunner();

        EasyMock.expect(this.consumer.fetch(request, -1, null)).andReturn(new MessageIterator(topic, data));
        final AtomicReference<Message> msg = new AtomicReference<Message>();
        EasyMock.expect(this.consumer.getMessageListener(topic)).andReturn(new MessageListener() {

            @Override
            public void recieveMessages(final Message message) {
View Full Code Here

Examples of com.taobao.metamorphosis.consumer.MessageIterator

        final FetchRequest request =
                new FetchRequest(broker, 0, new TopicPartitionRegInfo(topic, partition, offset), maxSize);

        final FetchRequestRunner runner = this.fetchManager.new FetchRequestRunner();

        EasyMock.expect(this.consumer.fetch(request, -1, null)).andReturn(new MessageIterator(topic, data));
        final AtomicReference<Message> msg = new AtomicReference<Message>();
        EasyMock.expect(this.consumer.getMessageListener(topic)).andReturn(new MessageListener() {

            @Override
            public void recieveMessages(final Message message) {
View Full Code Here

Examples of com.taobao.metamorphosis.consumer.MessageIterator

        final FetchRequest request =
                new FetchRequest(broker, 0, new TopicPartitionRegInfo(topic, partition, offset), maxSize);

        final FetchRequestRunner runner = this.fetchManager.new FetchRequestRunner();

        EasyMock.expect(this.consumer.fetch(request, -1, null)).andReturn(new MessageIterator(topic, data));
        final AtomicReference<Message> msg = new AtomicReference<Message>();
        EasyMock.expect(this.consumer.getMessageListener(topic)).andReturn(new MessageListener() {

            @Override
            public void recieveMessages(final Message message) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.