All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vertx.rxjava.amqp.AmqpSender Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2014 Red Hat, Inc.
 *
 * Red Hat licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package io.vertx.rxjava.amqp;

import rx.Observable;
import rx.Single;
import io.vertx.rx.java.RxHelper;
import io.vertx.rx.java.WriteStreamSubscriber;
import io.vertx.rx.java.SingleOnSubscribeAdapter;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.Iterator;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import io.vertx.core.Handler;
import io.vertx.core.AsyncResult;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import io.vertx.lang.rx.RxGen;
import io.vertx.lang.rx.TypeArg;
import io.vertx.lang.rx.MappingIterator;

/**
 * AMQP Sender interface used to send messages.
 *
 * 

* NOTE: This class has been automatically generated from the {@link io.vertx.amqp.AmqpSender original} non RX-ified interface using Vert.x codegen. */ @RxGen(io.vertx.amqp.AmqpSender.class) public class AmqpSender implements io.vertx.rxjava.core.streams.WriteStream { @Override public String toString() { return delegate.toString(); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; AmqpSender that = (AmqpSender) o; return delegate.equals(that.delegate); } @Override public int hashCode() { return delegate.hashCode(); } public static final TypeArg __TYPE_ARG = new TypeArg<>( obj -> new AmqpSender((io.vertx.amqp.AmqpSender) obj), AmqpSender::getDelegate ); private final io.vertx.amqp.AmqpSender delegate; public AmqpSender(io.vertx.amqp.AmqpSender delegate) { this.delegate = delegate; } public AmqpSender(Object delegate) { this.delegate = (io.vertx.amqp.AmqpSender)delegate; } public io.vertx.amqp.AmqpSender getDelegate() { return delegate; } private WriteStreamSubscriber subscriber; public synchronized WriteStreamSubscriber toSubscriber() { if (subscriber == null) { Function conv = io.vertx.rxjava.amqp.AmqpMessage::getDelegate; subscriber = RxHelper.toSubscriber(getDelegate(), conv); } return subscriber; } private static final TypeArg TYPE_ARG_0 = new TypeArg(o1 -> io.vertx.rxjava.amqp.AmqpMessage.newInstance((io.vertx.amqp.AmqpMessage)o1), o1 -> o1.getDelegate()); /** * Write some data to the stream. * *

The data is usually put on an internal write queue, and the write actually happens * asynchronously. To avoid running out of memory by putting too much on the write queue, * check the {@link io.vertx.rxjava.core.streams.WriteStream#writeQueueFull} method before writing. This is done automatically if * using a . * *

When the data is moved from the queue to the actual medium, the returned * will be completed with the write result, e.g the future is succeeded * when a server HTTP response buffer is written to the socket and failed if the remote * client has closed the socket while the data was still pending for write. * @param data the data to write * @return a future completed with the write result */ public io.vertx.core.Future write(io.vertx.rxjava.amqp.AmqpMessage data) { io.vertx.core.Future ret = delegate.write(data.getDelegate()).map(val -> val); return ret; } /** * Write some data to the stream. * *

The data is usually put on an internal write queue, and the write actually happens * asynchronously. To avoid running out of memory by putting too much on the write queue, * check the {@link io.vertx.rxjava.core.streams.WriteStream#writeQueueFull} method before writing. This is done automatically if * using a . * *

When the data is moved from the queue to the actual medium, the returned * will be completed with the write result, e.g the future is succeeded * when a server HTTP response buffer is written to the socket and failed if the remote * client has closed the socket while the data was still pending for write. * @param data the data to write * @return a future completed with the write result */ public rx.Single rxWrite(io.vertx.rxjava.amqp.AmqpMessage data) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.write(data).onComplete(fut); })); } /** * Ends the stream. *

* Once the stream has ended, it cannot be used any more. * @return a future completed with the result */ public io.vertx.core.Future end() { io.vertx.core.Future ret = delegate.end().map(val -> val); return ret; } /** * Ends the stream. *

* Once the stream has ended, it cannot be used any more. * @return a future completed with the result */ public rx.Single rxEnd() { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.end().onComplete(fut); })); } /** * Same as {@link io.vertx.rxjava.core.streams.WriteStream#end} but writes some data to the stream before ending. * @param data the data to write * @return a future completed with the result */ public io.vertx.core.Future end(io.vertx.rxjava.amqp.AmqpMessage data) { io.vertx.core.Future ret = delegate.end(data.getDelegate()).map(val -> val); return ret; } /** * Same as {@link io.vertx.rxjava.core.streams.WriteStream#end} but writes some data to the stream before ending. * @param data the data to write * @return a future completed with the result */ public rx.Single rxEnd(io.vertx.rxjava.amqp.AmqpMessage data) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.end(data).onComplete(fut); })); } /** * This will return true if there are more bytes in the write queue than the value set using {@link io.vertx.rxjava.amqp.AmqpSender#setWriteQueueMaxSize} * @return true if write queue is full */ public boolean writeQueueFull() { boolean ret = delegate.writeQueueFull(); return ret; } /** * Set a drain handler on the stream. If the write queue is full, then the handler will be called when the write * queue is ready to accept buffers again. See for an example of this being used. * *

The stream implementation defines when the drain handler, for example it could be when the queue size has been * reduced to maxSize / 2. * @param handler the handler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.core.streams.WriteStream drainHandler(io.vertx.core.Handler handler) { delegate.drainHandler(handler); return this; } public io.vertx.rxjava.amqp.AmqpSender exceptionHandler(io.vertx.core.Handler handler) { delegate.exceptionHandler(handler); return this; } public io.vertx.rxjava.amqp.AmqpSender setWriteQueueMaxSize(int maxSize) { delegate.setWriteQueueMaxSize(maxSize); return this; } /** * Sends an AMQP message. The destination the configured sender address or the address configured in the message. * @param message the message, must not be null * @return the current sender */ public io.vertx.rxjava.amqp.AmqpSender send(io.vertx.rxjava.amqp.AmqpMessage message) { delegate.send(message.getDelegate()); return this; } /** * Sends an AMQP message and waits for an acknowledgement. It returns a future marked as failed if the message * has been rejected or re-routed. If the message has been accepted, the handler is called with a success. * @param message the message, must not be null * @return a future notified with the acknowledgement */ public io.vertx.core.Future sendWithAck(io.vertx.rxjava.amqp.AmqpMessage message) { io.vertx.core.Future ret = delegate.sendWithAck(message.getDelegate()).map(val -> val); return ret; } /** * Sends an AMQP message and waits for an acknowledgement. It returns a future marked as failed if the message * has been rejected or re-routed. If the message has been accepted, the handler is called with a success. * @param message the message, must not be null * @return a future notified with the acknowledgement */ public rx.Single rxSendWithAck(io.vertx.rxjava.amqp.AmqpMessage message) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.sendWithAck(message).onComplete(fut); })); } /** * Closes the sender. * @return a future notified when the sender has been closed */ public io.vertx.core.Future close() { io.vertx.core.Future ret = delegate.close().map(val -> val); return ret; } /** * Closes the sender. * @return a future notified when the sender has been closed */ public rx.Single rxClose() { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.close().onComplete(fut); })); } /** * @return the configured address. */ public java.lang.String address() { java.lang.String ret = delegate.address(); return ret; } /** * Gets the connection having created the sender. Cannot be null * @return the connection having created the sender. */ public io.vertx.rxjava.amqp.AmqpConnection connection() { io.vertx.rxjava.amqp.AmqpConnection ret = io.vertx.rxjava.amqp.AmqpConnection.newInstance((io.vertx.amqp.AmqpConnection)delegate.connection()); return ret; } /** * @return the remaining credit, 0 is none. */ public long remainingCredits() { long ret = delegate.remainingCredits(); return ret; } /** * @return the underlying ProtonSender. */ public io.vertx.proton.ProtonSender unwrap() { io.vertx.proton.ProtonSender ret = delegate.unwrap(); return ret; } public static AmqpSender newInstance(io.vertx.amqp.AmqpSender arg) { return arg != null ? new AmqpSender(arg) : null; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy