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

io.vertx.rxjava.ext.stomp.StompClientConnection 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.ext.stomp;

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;

/**
 * Once a connection to the STOMP server has been made, client receives a {@link io.vertx.rxjava.ext.stomp.StompClientConnection}, that let
 * send and receive STOMP frames.
 *
 * 

* NOTE: This class has been automatically generated from the {@link io.vertx.ext.stomp.StompClientConnection original} non RX-ified interface using Vert.x codegen. */ @RxGen(io.vertx.ext.stomp.StompClientConnection.class) public class StompClientConnection { @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; StompClientConnection that = (StompClientConnection) o; return delegate.equals(that.delegate); } @Override public int hashCode() { return delegate.hashCode(); } public static final TypeArg __TYPE_ARG = new TypeArg<>( obj -> new StompClientConnection((io.vertx.ext.stomp.StompClientConnection) obj), StompClientConnection::getDelegate ); private final io.vertx.ext.stomp.StompClientConnection delegate; public StompClientConnection(io.vertx.ext.stomp.StompClientConnection delegate) { this.delegate = delegate; } public StompClientConnection(Object delegate) { this.delegate = (io.vertx.ext.stomp.StompClientConnection)delegate; } public io.vertx.ext.stomp.StompClientConnection getDelegate() { return delegate; } /** * @return the session id. */ public java.lang.String session() { java.lang.String ret = delegate.session(); return ret; } /** * @return the STOMP protocol version negotiated with the server. */ public java.lang.String version() { java.lang.String ret = delegate.version(); return ret; } /** * Closes the connection without sending the DISCONNECT frame. */ public void close() { delegate.close(); } /** * @return the server name. */ public java.lang.String server() { java.lang.String ret = delegate.server(); return ret; } /** * Sends a SEND frame to the server. * @param headers the headers, must not be null * @param body the body, may be null * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public io.vertx.core.Future send(java.util.Map headers, io.vertx.core.buffer.Buffer body) { io.vertx.core.Future ret = delegate.send(headers, body).map(val -> val); return ret; } /** * Sends a SEND frame to the server. * @param headers the headers, must not be null * @param body the body, may be null * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public rx.Single rxSend(java.util.Map headers, io.vertx.core.buffer.Buffer body) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.send(headers, body).onComplete(fut); })); } /** * Sends a SEND frame to the server to the given destination. The message does not have any other header. * @param destination the destination, must not be null * @param body the body, may be null * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public io.vertx.core.Future send(java.lang.String destination, io.vertx.core.buffer.Buffer body) { io.vertx.core.Future ret = delegate.send(destination, body).map(val -> val); return ret; } /** * Sends a SEND frame to the server to the given destination. The message does not have any other header. * @param destination the destination, must not be null * @param body the body, may be null * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public rx.Single rxSend(java.lang.String destination, io.vertx.core.buffer.Buffer body) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.send(destination, body).onComplete(fut); })); } /** * Sends the given frame to the server. * @param frame the frame * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public io.vertx.core.Future send(io.vertx.ext.stomp.Frame frame) { io.vertx.core.Future ret = delegate.send(frame).map(val -> val); return ret; } /** * Sends the given frame to the server. * @param frame the frame * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public rx.Single rxSend(io.vertx.ext.stomp.Frame frame) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.send(frame).onComplete(fut); })); } /** * Sends a SEND frame to the server to the given destination. * @param destination the destination, must not be null * @param headers the header. The destination header is replaced by the value given to the destination parameter * @param body the body, may be null * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public io.vertx.core.Future send(java.lang.String destination, java.util.Map headers, io.vertx.core.buffer.Buffer body) { io.vertx.core.Future ret = delegate.send(destination, headers, body).map(val -> val); return ret; } /** * Sends a SEND frame to the server to the given destination. * @param destination the destination, must not be null * @param headers the header. The destination header is replaced by the value given to the destination parameter * @param body the body, may be null * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public rx.Single rxSend(java.lang.String destination, java.util.Map headers, io.vertx.core.buffer.Buffer body) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.send(destination, headers, body).onComplete(fut); })); } /** * Subscribes to the given destination. This destination is used as subscription id. * @param destination the destination, must not be null * @param handler the handler invoked when a message is received on the given destination. Must not be null. * @return a future resolved with the subscription id when the RECEIPT frame associated with the sent frame has been received */ public io.vertx.core.Future subscribe(java.lang.String destination, io.vertx.core.Handler handler) { io.vertx.core.Future ret = delegate.subscribe(destination, handler).map(val -> val); return ret; } /** * Subscribes to the given destination. This destination is used as subscription id. * @param destination the destination, must not be null * @param handler the handler invoked when a message is received on the given destination. Must not be null. * @return a future resolved with the subscription id when the RECEIPT frame associated with the sent frame has been received */ public rx.Single rxSubscribe(java.lang.String destination, io.vertx.core.Handler handler) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.subscribe(destination, handler).onComplete(fut); })); } /** * Subscribes to the given destination. * @param destination the destination, must not be null. * @param headers the headers to configure the subscription. It may contain the ack header to configure the acknowledgment policy. If the given set of headers contains the id header, this value is used as subscription id. * @param handler the handler invoked when a message is received on the given destination. Must not be null. * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public io.vertx.core.Future subscribe(java.lang.String destination, java.util.Map headers, io.vertx.core.Handler handler) { io.vertx.core.Future ret = delegate.subscribe(destination, headers, handler).map(val -> val); return ret; } /** * Subscribes to the given destination. * @param destination the destination, must not be null. * @param headers the headers to configure the subscription. It may contain the ack header to configure the acknowledgment policy. If the given set of headers contains the id header, this value is used as subscription id. * @param handler the handler invoked when a message is received on the given destination. Must not be null. * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public rx.Single rxSubscribe(java.lang.String destination, java.util.Map headers, io.vertx.core.Handler handler) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.subscribe(destination, headers, handler).onComplete(fut); })); } /** * Un-subscribes from the given destination. This method only works if the subscription did not specifies a * subscription id (using the id header). * @param destination the destination * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public io.vertx.core.Future unsubscribe(java.lang.String destination) { io.vertx.core.Future ret = delegate.unsubscribe(destination).map(val -> val); return ret; } /** * Un-subscribes from the given destination. This method only works if the subscription did not specifies a * subscription id (using the id header). * @param destination the destination * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public rx.Single rxUnsubscribe(java.lang.String destination) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.unsubscribe(destination).onComplete(fut); })); } /** * Un-subscribes from the given destination. This method computes the subscription id as follows. If the given * headers contains the id header, the header value is used. Otherwise the destination is used. * @param destination the destination * @param headers the headers * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public io.vertx.core.Future unsubscribe(java.lang.String destination, java.util.Map headers) { io.vertx.core.Future ret = delegate.unsubscribe(destination, headers).map(val -> val); return ret; } /** * Un-subscribes from the given destination. This method computes the subscription id as follows. If the given * headers contains the id header, the header value is used. Otherwise the destination is used. * @param destination the destination * @param headers the headers * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public rx.Single rxUnsubscribe(java.lang.String destination, java.util.Map headers) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.unsubscribe(destination, headers).onComplete(fut); })); } /** * Sets a handler notified when an ERROR frame is received by the client. The handler receives the ERROR frame and a reference on the {@link io.vertx.rxjava.ext.stomp.StompClientConnection}. * @param handler the handler * @return the current {@link io.vertx.rxjava.ext.stomp.StompClientConnection} */ public io.vertx.rxjava.ext.stomp.StompClientConnection errorHandler(io.vertx.core.Handler handler) { io.vertx.rxjava.ext.stomp.StompClientConnection ret = io.vertx.rxjava.ext.stomp.StompClientConnection.newInstance((io.vertx.ext.stomp.StompClientConnection)delegate.errorHandler(handler)); return ret; } /** * Sets a handler notified when the STOMP connection is closed. * @param handler the handler * @return the current {@link io.vertx.rxjava.ext.stomp.StompClientConnection} */ public io.vertx.rxjava.ext.stomp.StompClientConnection closeHandler(io.vertx.core.Handler handler) { delegate.closeHandler(new io.vertx.lang.rx.DelegatingHandler<>(handler, event -> io.vertx.rxjava.ext.stomp.StompClientConnection.newInstance((io.vertx.ext.stomp.StompClientConnection)event))); return this; } /** * Sets a handler notified when the server does not respond to a ping request in time. In other * words, this handler is invoked when the heartbeat has detected a connection failure with the server. * The handler can decide to reconnect to the server. * @param handler the handler * @return the current {@link io.vertx.rxjava.ext.stomp.StompClientConnection} receiving the dropped connection. */ public io.vertx.rxjava.ext.stomp.StompClientConnection connectionDroppedHandler(io.vertx.core.Handler handler) { delegate.connectionDroppedHandler(new io.vertx.lang.rx.DelegatingHandler<>(handler, event -> io.vertx.rxjava.ext.stomp.StompClientConnection.newInstance((io.vertx.ext.stomp.StompClientConnection)event))); return this; } /** * Sets a handler that let customize the behavior when a ping needs to be sent to the server. Be aware that * changing the default behavior may break the compliance with the STOMP specification. * @param handler the handler * @return the current {@link io.vertx.rxjava.ext.stomp.StompClientConnection} */ public io.vertx.rxjava.ext.stomp.StompClientConnection pingHandler(io.vertx.core.Handler handler) { delegate.pingHandler(new io.vertx.lang.rx.DelegatingHandler<>(handler, event -> io.vertx.rxjava.ext.stomp.StompClientConnection.newInstance((io.vertx.ext.stomp.StompClientConnection)event))); return this; } /** * Begins a transaction. * @param id the transaction id, must not be null * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public io.vertx.core.Future beginTX(java.lang.String id) { io.vertx.core.Future ret = delegate.beginTX(id).map(val -> val); return ret; } /** * Begins a transaction. * @param id the transaction id, must not be null * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public rx.Single rxBeginTX(java.lang.String id) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.beginTX(id).onComplete(fut); })); } /** * Begins a transaction. * @param id the transaction id, must not be null * @param headers additional headers to send to the server. The transaction header is replaced by the value passed in the @{code id} parameter * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public io.vertx.core.Future beginTX(java.lang.String id, java.util.Map headers) { io.vertx.core.Future ret = delegate.beginTX(id, headers).map(val -> val); return ret; } /** * Begins a transaction. * @param id the transaction id, must not be null * @param headers additional headers to send to the server. The transaction header is replaced by the value passed in the @{code id} parameter * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public rx.Single rxBeginTX(java.lang.String id, java.util.Map headers) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.beginTX(id, headers).onComplete(fut); })); } /** * Commits a transaction. * @param id the transaction id, must not be null * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public io.vertx.core.Future commit(java.lang.String id) { io.vertx.core.Future ret = delegate.commit(id).map(val -> val); return ret; } /** * Commits a transaction. * @param id the transaction id, must not be null * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public rx.Single rxCommit(java.lang.String id) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.commit(id).onComplete(fut); })); } /** * Commits a transaction. * @param id the transaction id, must not be null * @param headers additional headers to send to the server. The transaction header is replaced by the value passed in the @{code id} parameter * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public io.vertx.core.Future commit(java.lang.String id, java.util.Map headers) { io.vertx.core.Future ret = delegate.commit(id, headers).map(val -> val); return ret; } /** * Commits a transaction. * @param id the transaction id, must not be null * @param headers additional headers to send to the server. The transaction header is replaced by the value passed in the @{code id} parameter * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public rx.Single rxCommit(java.lang.String id, java.util.Map headers) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.commit(id, headers).onComplete(fut); })); } /** * Aborts a transaction. * @param id the transaction id, must not be null * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public io.vertx.core.Future abort(java.lang.String id) { io.vertx.core.Future ret = delegate.abort(id).map(val -> val); return ret; } /** * Aborts a transaction. * @param id the transaction id, must not be null * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public rx.Single rxAbort(java.lang.String id) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.abort(id).onComplete(fut); })); } /** * Aborts a transaction. * @param id the transaction id, must not be null * @param headers additional headers to send to the server. The transaction header is replaced by the value passed in the @{code id} parameter * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public io.vertx.core.Future abort(java.lang.String id, java.util.Map headers) { io.vertx.core.Future ret = delegate.abort(id, headers).map(val -> val); return ret; } /** * Aborts a transaction. * @param id the transaction id, must not be null * @param headers additional headers to send to the server. The transaction header is replaced by the value passed in the @{code id} parameter * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public rx.Single rxAbort(java.lang.String id, java.util.Map headers) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.abort(id, headers).onComplete(fut); })); } /** * Disconnects the client. Unlike the {@link io.vertx.rxjava.ext.stomp.StompClientConnection#close} method, this method send the DISCONNECT frame to the * server. * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public io.vertx.core.Future disconnect() { io.vertx.core.Future ret = delegate.disconnect().map(val -> val); return ret; } /** * Disconnects the client. Unlike the {@link io.vertx.rxjava.ext.stomp.StompClientConnection#close} method, this method send the DISCONNECT frame to the * server. * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public rx.Single rxDisconnect() { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.disconnect().onComplete(fut); })); } /** * Disconnects the client. Unlike the {@link io.vertx.rxjava.ext.stomp.StompClientConnection#close} method, this method send the DISCONNECT frame to the * server. This method lets you customize the DISCONNECT frame. * @param frame the DISCONNECT frame. * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public io.vertx.core.Future disconnect(io.vertx.ext.stomp.Frame frame) { io.vertx.core.Future ret = delegate.disconnect(frame).map(val -> val); return ret; } /** * Disconnects the client. Unlike the {@link io.vertx.rxjava.ext.stomp.StompClientConnection#close} method, this method send the DISCONNECT frame to the * server. This method lets you customize the DISCONNECT frame. * @param frame the DISCONNECT frame. * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public rx.Single rxDisconnect(io.vertx.ext.stomp.Frame frame) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.disconnect(frame).onComplete(fut); })); } /** * Sends an acknowledgement for a specific message. It means that the message has been handled and processed by the * client. The id parameter is the message id received in the frame. * @param id the message id of the message to acknowledge * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public io.vertx.core.Future ack(java.lang.String id) { io.vertx.core.Future ret = delegate.ack(id).map(val -> val); return ret; } /** * Sends an acknowledgement for a specific message. It means that the message has been handled and processed by the * client. The id parameter is the message id received in the frame. * @param id the message id of the message to acknowledge * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public rx.Single rxAck(java.lang.String id) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.ack(id).onComplete(fut); })); } /** * Sends a non-acknowledgement for the given message. It means that the message has not been handled by the client. * The id parameter is the message id received in the frame. * @param id the message id of the message to acknowledge * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public io.vertx.core.Future nack(java.lang.String id) { io.vertx.core.Future ret = delegate.nack(id).map(val -> val); return ret; } /** * Sends a non-acknowledgement for the given message. It means that the message has not been handled by the client. * The id parameter is the message id received in the frame. * @param id the message id of the message to acknowledge * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public rx.Single rxNack(java.lang.String id) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.nack(id).onComplete(fut); })); } /** * Sends an acknowledgement for the given frame. It means that the frame has been handled and processed by the * client. The sent acknowledgement is part of the transaction identified by the given id. * @param id the message id of the message to acknowledge * @param txId the transaction id * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public io.vertx.core.Future ack(java.lang.String id, java.lang.String txId) { io.vertx.core.Future ret = delegate.ack(id, txId).map(val -> val); return ret; } /** * Sends an acknowledgement for the given frame. It means that the frame has been handled and processed by the * client. The sent acknowledgement is part of the transaction identified by the given id. * @param id the message id of the message to acknowledge * @param txId the transaction id * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public rx.Single rxAck(java.lang.String id, java.lang.String txId) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.ack(id, txId).onComplete(fut); })); } /** * Sends a non-acknowledgement for the given frame. It means that the frame has not been handled by the client. * The sent non-acknowledgement is part of the transaction identified by the given id. * @param id the message id of the message to acknowledge * @param txId the transaction id * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public io.vertx.core.Future nack(java.lang.String id, java.lang.String txId) { io.vertx.core.Future ret = delegate.nack(id, txId).map(val -> val); return ret; } /** * Sends a non-acknowledgement for the given frame. It means that the frame has not been handled by the client. * The sent non-acknowledgement is part of the transaction identified by the given id. * @param id the message id of the message to acknowledge * @param txId the transaction id * @return a future resolved with the sent frame when the RECEIPT frame associated with the sent frame has been received */ public rx.Single rxNack(java.lang.String id, java.lang.String txId) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.nack(id, txId).onComplete(fut); })); } /** * Configures a received handler that get notified when a STOMP frame is received by the client. * This handler can be used for logging, debugging or ad-hoc behavior. The frame can still be modified by the handler. *

* Unlike {@link io.vertx.rxjava.ext.stomp.StompClient#receivedFrameHandler}, the given handler won't receive the CONNECTED frame. If a received frame handler is set on the {@link io.vertx.rxjava.ext.stomp.StompClient}, it will be used by all * clients connection, so calling this method is useless, except if you want to use a different handler. * @param handler the handler * @return the current {@link io.vertx.rxjava.ext.stomp.StompClientConnection} */ public io.vertx.rxjava.ext.stomp.StompClientConnection receivedFrameHandler(io.vertx.core.Handler handler) { delegate.receivedFrameHandler(handler); return this; } /** * Configures a handler notified when a frame is going to be written on the wire. This handler can be used from * logging, debugging. The handler can modify the received frame. *

* If a writing frame handler is set on the {@link io.vertx.rxjava.ext.stomp.StompClient}, it will be used by all * clients connection, so calling this method is useless, except if you want to use a different handler. * @param handler the handler * @return the current {@link io.vertx.rxjava.ext.stomp.StompClientConnection} */ public io.vertx.rxjava.ext.stomp.StompClientConnection writingFrameHandler(io.vertx.core.Handler handler) { delegate.writingFrameHandler(handler); return this; } /** * Configures the exception handler notified upon TCP-level errors. * @param exceptionHandler the handler * @return the current {@link io.vertx.rxjava.ext.stomp.StompClientConnection} */ public io.vertx.rxjava.ext.stomp.StompClientConnection exceptionHandler(io.vertx.core.Handler exceptionHandler) { delegate.exceptionHandler(exceptionHandler); return this; } /** * Returns whether or not the `CONNECTED` frame has been receive meaning that the Stomp connection is established. * @return true if the connection is established, false otherwise */ public boolean isConnected() { boolean ret = delegate.isConnected(); return ret; } public static StompClientConnection newInstance(io.vertx.ext.stomp.StompClientConnection arg) { return arg != null ? new StompClientConnection(arg) : null; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy