Examples of MessageStream


Examples of groovyx.gpars.actor.impl.MessageStream

    }

    @Override
    public final DataflowWriteChannel<T> leftShift(final DataflowReadChannel<T> ref) {
        updateHead().leftShift(ref);
        ref.getValAsync(new MessageStream() {
            @Override
            public MessageStream send(Object message) {
                if (!(message instanceof Throwable))
                    notifyRemote((T)message);
                return this;
View Full Code Here

Examples of groovyx.gpars.actor.impl.MessageStream

     *
     * @param ref The DataflowVariable to check for value
     * @return The rest of the stream
     */
    public final StreamCore<T> leftShift(final DataflowReadChannel<T> ref) {
        ref.getValAsync(new MessageStream() {
            @Override
            public MessageStream send(final Object message) {
                first.bind((T) message);
                return null;
            }
View Full Code Here

Examples of groovyx.gpars.actor.impl.MessageStream

        throw new UnsupportedOperationException();
    }

    @Override
    public DataflowWriteChannel<T> leftShift(DataflowReadChannel<T> ref) {
        ref.getValAsync(new MessageStream() {
            @Override
            public MessageStream send(Object message) {
                enqueueValue((T) message);
                return this;
            }
View Full Code Here

Examples of org.apache.james.util.stream.MessageStream

                Long uid = uidList.get(num - 1);
                if (deletedUidList.contains(uid) == false) {
                    FetchGroupImpl fetchGroup = new FetchGroupImpl(FetchGroup.BODY_CONTENT);
                    fetchGroup.or(FetchGroup.HEADERS);
                    Iterator<MessageResult> results = session.getUserMailbox().getMessages(MessageRange.one(uid), fetchGroup, mailboxSession);
                    MessageStream stream = new MessageStream();
                    OutputStream out = stream.getOutputStream();
                    OutputStream extraDotOut = new ExtraDotOutputStream(out);
                   
                    out.write((POP3Response.OK_RESPONSE + " Message follows\r\n").getBytes());
                    out.flush();
                    // response = new POP3Response(POP3Response.OK_RESPONSE,
                    // "Message follows");
                    try {
                        MessageResult result = results.next();

                        WritableByteChannel outChannel = Channels.newChannel(extraDotOut);

                        // write headers
                        Iterator<Header> headers = result.headers();
                        while (headers.hasNext()) {
                            headers.next().writeTo(outChannel);

                            // we need to write out the CRLF after each header
                            extraDotOut.write("\r\n".getBytes());

                        }
                        // headers and body are seperated by a CRLF
                        extraDotOut.write("\r\n".getBytes());

                        // write body
                        result.getBody().writeTo(Channels.newChannel(new CountingBodyOutputStream(extraDotOut, lines)));

                    } finally {
                        extraDotOut.flush();
                        // write a single dot to mark message as complete
                        out.write((".\r\n").getBytes());
                        out.flush();
                       
                        extraDotOut.close();
                        out.close();
                    }
                    session.writeStream(stream.getInputStream());

                    return null;

                } else {
                    StringBuilder responseBuffer = new StringBuilder(64).append("Message (").append(num).append(") already deleted.");
View Full Code Here

Examples of org.apache.james.util.stream.MessageStream

                MailboxSession mailboxSession = (MailboxSession) session.getState().get(POP3Session.MAILBOX_SESSION);
                Long uid = uidList.get(num - 1);
                if (deletedUidList.contains(uid) == false) {
                    Iterator<MessageResult> results = session.getUserMailbox().getMessages(MessageRange.one(uid), new FetchGroupImpl(FetchGroup.FULL_CONTENT), mailboxSession);
                    MessageStream stream = new MessageStream();
                    OutputStream out = stream.getOutputStream();
                    OutputStream extraDotOut = new ExtraDotOutputStream(out);
                   
                    out.write((POP3Response.OK_RESPONSE + " Message follows\r\n").getBytes());
                    out.flush();
                   
                    // response = new POP3Response(POP3Response.OK_RESPONSE,
                    // "Message follows");
                    try {
                        MessageResult result = results.next();
                        result.getFullContent().writeTo(Channels.newChannel(extraDotOut));

                    } finally {
                        extraDotOut.flush();
                       
                        // write a single dot to mark message as complete
                        out.write((".\r\n").getBytes());
                        out.flush();
                       
                        extraDotOut.close();
                        out.close();
                    }

                    session.writeStream(stream.getInputStream());

                    return null;
                } else {

                    StringBuilder responseBuffer = new StringBuilder(64).append("Message (").append(num).append(") already deleted.");
View Full Code Here

Examples of org.jclouds.openstack.marconi.v1.domain.MessageStream

   @Test(dependsOnMethods = { "createQueues" })
   public void streamZeroPagesOfMessages() throws Exception {
      for (String zoneId : zones) {
         MessageApi messageApi = api.getMessageApiForZoneAndClientAndQueue(zoneId, CLIENT_ID, "jclouds-test");

         MessageStream messageStream = messageApi.stream(echo(true));

         assertTrue(Iterables.isEmpty(messageStream));
         assertFalse(messageStream.nextMarker().isPresent());
      }
   }
View Full Code Here

Examples of org.jclouds.openstack.marconi.v1.domain.MessageStream

   @Test(dependsOnMethods = { "createMessage" })
   public void streamOnePageOfMessages() throws Exception {
      for (String zoneId : zones) {
         MessageApi messageApi = api.getMessageApiForZoneAndClientAndQueue(zoneId, CLIENT_ID, "jclouds-test");

         MessageStream messageStream = messageApi.stream(echo(true));

         while (messageStream.nextMarker().isPresent()) {
            assertEquals(Iterables.size(messageStream), 1);

            messageStream = messageApi.stream(messageStream.nextStreamOptions());
         }

         assertFalse(messageStream.nextMarker().isPresent());
      }
   }
View Full Code Here

Examples of org.jclouds.openstack.marconi.v1.domain.MessageStream

   public void streamManyPagesOfMessages() throws Exception {
      for (String zoneId : zones) {
         MessageApi messageApi = api.getMessageApiForZoneAndClientAndQueue(zoneId, CLIENT_ID, "jclouds-test");
         messageIds.put(zoneId, new ArrayList<String>());

         MessageStream messageStream = messageApi.stream(echo(true).limit(2));

         while (messageStream.nextMarker().isPresent()) {
            assertEquals(Iterables.size(messageStream), 2);

            for (Message message : messageStream) {
               messageIds.get(zoneId).add(message.getId());
            }

            messageStream = messageApi.stream(messageStream.nextStreamOptions());
         }

         assertFalse(messageStream.nextMarker().isPresent());
      }
   }
View Full Code Here

Examples of org.jclouds.openstack.marconi.v1.domain.MessageStream

      try {
         MarconiApi api = api(server.getUrl("/").toString(), "openstack-marconi");
         MessageApi messageApi = api.getMessageApiForZoneAndClientAndQueue("DFW", CLIENT_ID, "jclouds-test");

         MessageStream messageStream = messageApi.stream();

         assertTrue(Iterables.isEmpty(messageStream));
         assertFalse(messageStream.nextMarker().isPresent());

         assertEquals(server.getRequestCount(), 2);
         assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
         assertEquals(server.takeRequest().getRequestLine(), "GET /v1/123123/queues/jclouds-test/messages HTTP/1.1");
      }
View Full Code Here

Examples of org.jclouds.openstack.marconi.v1.domain.MessageStream

      try {
         MarconiApi api = api(server.getUrl("/").toString(), "openstack-marconi");
         MessageApi messageApi = api.getMessageApiForZoneAndClientAndQueue("DFW", CLIENT_ID, "jclouds-test");

         MessageStream messageStream = messageApi.stream();

         while (messageStream.nextMarker().isPresent()) {
            assertEquals(Iterables.size(messageStream), 6);

            messageStream = messageApi.stream(messageStream.nextStreamOptions());
         }

         assertFalse(messageStream.nextMarker().isPresent());

         assertEquals(server.getRequestCount(), 3);
         assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
         assertEquals(server.takeRequest().getRequestLine(), "GET /v1/123123/queues/jclouds-test/messages HTTP/1.1");
         assertEquals(server.takeRequest().getRequestLine(), "GET /v1/123123/queues/jclouds-test/messages?marker=4512 HTTP/1.1");
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.