/*
* 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.reactivex.amqpbridge;
import java.util.Map;
import io.reactivex.Observable;
import io.reactivex.Flowable;
import io.reactivex.Single;
import io.reactivex.Completable;
import io.reactivex.Maybe;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
import io.vertx.amqpbridge.AmqpBridgeOptions;
Vert.x AMQP Bridge. Facilitates sending and receiving AMQP 1.0 messages.
NOTE: This class has been automatically generated from the original
non RX-ified interface using Vert.x codegen. /**
* Vert.x AMQP Bridge. Facilitates sending and receiving AMQP 1.0 messages.
*
* <p/>
* NOTE: This class has been automatically generated from the {@link io.vertx.amqpbridge.AmqpBridge original} non RX-ified interface using Vert.x codegen.
*/
@io.vertx.lang.rx.RxGen(io.vertx.amqpbridge.AmqpBridge.class)
public class AmqpBridge {
@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;
AmqpBridge that = (AmqpBridge) o;
return delegate.equals(that.delegate);
}
@Override
public int hashCode() {
return delegate.hashCode();
}
public static final io.vertx.lang.rx.TypeArg<AmqpBridge> __TYPE_ARG = new io.vertx.lang.rx.TypeArg<>( obj -> new AmqpBridge((io.vertx.amqpbridge.AmqpBridge) obj),
AmqpBridge::getDelegate
);
private final io.vertx.amqpbridge.AmqpBridge delegate;
public AmqpBridge(io.vertx.amqpbridge.AmqpBridge delegate) {
this.delegate = delegate;
}
public io.vertx.amqpbridge.AmqpBridge getDelegate() {
return delegate;
}
Creates a Bridge.
Params: - vertx – the vertx instance to use
Returns: the (not-yet-started) bridge.
/**
* Creates a Bridge.
* @param vertx the vertx instance to use
* @return the (not-yet-started) bridge.
*/
public static io.vertx.reactivex.amqpbridge.AmqpBridge create(io.vertx.reactivex.core.Vertx vertx) {
io.vertx.reactivex.amqpbridge.AmqpBridge ret = io.vertx.reactivex.amqpbridge.AmqpBridge.newInstance(io.vertx.amqpbridge.AmqpBridge.create(vertx.getDelegate()));
return ret;
}
Creates a Bridge with the given options.
Params: - vertx – the vertx instance to use
- options – the options
Returns: the (not-yet-started) bridge.
/**
* Creates a Bridge with the given options.
* @param vertx the vertx instance to use
* @param options the options
* @return the (not-yet-started) bridge.
*/
public static io.vertx.reactivex.amqpbridge.AmqpBridge create(io.vertx.reactivex.core.Vertx vertx, AmqpBridgeOptions options) {
io.vertx.reactivex.amqpbridge.AmqpBridge ret = io.vertx.reactivex.amqpbridge.AmqpBridge.newInstance(io.vertx.amqpbridge.AmqpBridge.create(vertx.getDelegate(), options));
return ret;
}
Starts the bridge, establishing the underlying connection.
Params: - hostname – the host name to connect to
- port – the port to connect to
- username – the username
- password – the password
- resultHandler – the result handler
/**
* Starts the bridge, establishing the underlying connection.
* @param hostname the host name to connect to
* @param port the port to connect to
* @param username the username
* @param password the password
* @param resultHandler the result handler
*/
public void start(String hostname, int port, String username, String password, Handler<AsyncResult<io.vertx.reactivex.amqpbridge.AmqpBridge>> resultHandler) {
delegate.start(hostname, port, username, password, new Handler<AsyncResult<io.vertx.amqpbridge.AmqpBridge>>() {
public void handle(AsyncResult<io.vertx.amqpbridge.AmqpBridge> ar) {
if (ar.succeeded()) {
resultHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.reactivex.amqpbridge.AmqpBridge.newInstance(ar.result())));
} else {
resultHandler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
}
}
});
}
Starts the bridge, establishing the underlying connection.
Params: - hostname – the host name to connect to
- port – the port to connect to
- username – the username
- password – the password
Returns:
/**
* Starts the bridge, establishing the underlying connection.
* @param hostname the host name to connect to
* @param port the port to connect to
* @param username the username
* @param password the password
* @return
*/
public Single<io.vertx.reactivex.amqpbridge.AmqpBridge> rxStart(String hostname, int port, String username, String password) {
return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> {
start(hostname, port, username, password, handler);
});
}
Starts the bridge, establishing the underlying connection.
Params: - hostname – the host name to connect to
- port – the port to connect to
- resultHandler – the result handler
/**
* Starts the bridge, establishing the underlying connection.
* @param hostname the host name to connect to
* @param port the port to connect to
* @param resultHandler the result handler
*/
public void start(String hostname, int port, Handler<AsyncResult<io.vertx.reactivex.amqpbridge.AmqpBridge>> resultHandler) {
delegate.start(hostname, port, new Handler<AsyncResult<io.vertx.amqpbridge.AmqpBridge>>() {
public void handle(AsyncResult<io.vertx.amqpbridge.AmqpBridge> ar) {
if (ar.succeeded()) {
resultHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.reactivex.amqpbridge.AmqpBridge.newInstance(ar.result())));
} else {
resultHandler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
}
}
});
}
Starts the bridge, establishing the underlying connection.
Params: - hostname – the host name to connect to
- port – the port to connect to
Returns:
/**
* Starts the bridge, establishing the underlying connection.
* @param hostname the host name to connect to
* @param port the port to connect to
* @return
*/
public Single<io.vertx.reactivex.amqpbridge.AmqpBridge> rxStart(String hostname, int port) {
return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> {
start(hostname, port, handler);
});
}
Creates a consumer on the given AMQP address.
This method MUST be called from the bridge Context thread, as used in the result handler callback from the start
methods. The bridge MUST be successfully started before the method is called.
Params: - amqpAddress – the address to consume from
Returns: the consumer
/**
* Creates a consumer on the given AMQP address.
*
* This method MUST be called from the bridge Context thread, as used in the result handler callback from the start
* methods. The bridge MUST be successfully started before the method is called.
* @param amqpAddress the address to consume from
* @return the consumer
*/
public <T> io.vertx.reactivex.core.eventbus.MessageConsumer<T> createConsumer(String amqpAddress) {
io.vertx.reactivex.core.eventbus.MessageConsumer<T> ret = io.vertx.reactivex.core.eventbus.MessageConsumer.newInstance(delegate.createConsumer(amqpAddress), io.vertx.lang.rx.TypeArg.unknown());
return ret;
}
Creates a producer to the given AMQP address.
This method MUST be called from the bridge Context thread, as used in the result handler callback from the start
methods. The bridge MUST be successfully started before the method is called.
Params: - amqpAddress – the address to produce to
Returns: the producer
/**
* Creates a producer to the given AMQP address.
*
* This method MUST be called from the bridge Context thread, as used in the result handler callback from the start
* methods. The bridge MUST be successfully started before the method is called.
* @param amqpAddress the address to produce to
* @return the producer
*/
public <T> io.vertx.reactivex.core.eventbus.MessageProducer<T> createProducer(String amqpAddress) {
io.vertx.reactivex.core.eventbus.MessageProducer<T> ret = io.vertx.reactivex.core.eventbus.MessageProducer.newInstance(delegate.createProducer(amqpAddress), io.vertx.lang.rx.TypeArg.unknown());
return ret;
}
Shuts the bridge down, closing the underlying connection.
Params: - resultHandler – the result handler
/**
* Shuts the bridge down, closing the underlying connection.
* @param resultHandler the result handler
*/
public void close(Handler<AsyncResult<Void>> resultHandler) {
delegate.close(resultHandler);
}
Shuts the bridge down, closing the underlying connection.
Returns:
/**
* Shuts the bridge down, closing the underlying connection.
* @return
*/
public Completable rxClose() {
return io.vertx.reactivex.impl.AsyncResultCompletable.toCompletable(handler -> {
close(handler);
});
}
Set an end handler. This will fire if the underlying connection is unexpectedly disconnected or remotely closed.
Params: - endHandler – the handler
/**
* Set an end handler. This will fire if the underlying connection is unexpectedly disconnected or remotely closed.
* @param endHandler the handler
*/
public void endHandler(Handler<Void> endHandler) {
delegate.endHandler(endHandler);
}
public static AmqpBridge newInstance(io.vertx.amqpbridge.AmqpBridge arg) {
return arg != null ? new AmqpBridge(arg) : null;
}
}