1 /*
2 * hunt-amqp-client: AMQP Client Library for D Programming Language. Support for RabbitMQ and other AMQP Server.
3 *
4 * Copyright (C) 2018-2019 HuntLabs
5 *
6 * Website: https://www.huntlabs.net
7 *
8 * Licensed under the Apache-2.0 License.
9 *
10 */11 modulehunt.amqp.client.AmqpConnection;
12 13 //import hunt.codegen.annotations.Fluent;14 //import hunt.codegen.annotations.VertxGen;15 //import hunt.core.AsyncResult;16 //import hunt.core.Future;17 importhunt.amqp.Handler;
18 importhunt.Object;
19 importhunt.amqp.client.AmqpReceiver;
20 importhunt.amqp.client.AmqpSender;
21 importhunt.amqp.client.AmqpReceiverOptions;
22 importhunt.amqp.client.AmqpSenderOptions;
23 24 25 /**
26 * Once connected to the broker or router, you get a connection. This connection is automatically opened.
27 */28 interfaceAmqpConnection {
29 30 boolisClosed();
31 32 /**
33 * Registers a handler called on disconnection.
34 *
35 * @param handler the exception handler.
36 */37 AmqpConnectionexceptionHandler(Handler!Throwablehandler);
38 39 /**
40 * Closes the AMQP connection, i.e. allows the Close frame to be emitted.
41 *
42 * @param done the close handler notified when the connection is closed. May be {@code null}.
43 * @return the connection
44 */45 AmqpConnectionclose(AsyncResultHandler!Voiddone);
46 47 /**
48 * Like {@link #close(Handler)} but returns a {@code Future} of the asynchronous result
49 */50 // Future<Void> close();51 52 /**
53 * Creates a receiver used to consume messages from the given address. The receiver has no handler and won't
54 * start receiving messages until a handler is explicitly configured.
55 *
56 * @param address The source address to attach the consumer to, must not be {@code null}
57 * @param completionHandler the handler called with the receiver. The receiver has been opened.
58 * @return the connection.
59 */60 AmqpConnectioncreateReceiver(stringaddress, Handler!AmqpReceivercompletionHandler);
61 62 /**
63 * Like {@link #createReceiver(string, Handler)} but returns a {@code Future} of the asynchronous result
64 */65 //Future<AmqpReceiver> createReceiver(string address);66 67 /**
68 * Creates a receiver used to consumer messages from the given address.
69 *
70 * @param address The source address to attach the consumer to.
71 * @param receiverOptions The options for this receiver.
72 * @param completionHandler The handler called with the receiver, once opened. Note that the {@code messageHandler}
73 * can be called before the {@code completionHandler} if messages are awaiting delivery.
74 * @return the connection.
75 */76 AmqpConnectioncreateReceiver(stringaddress, AmqpReceiverOptionsreceiverOptions,
77 Handler!AmqpReceivercompletionHandler);
78 79 /**
80 * Like {@link #createReceiver(string, AmqpReceiverOptions, Handler)} but returns a {@code Future} of the asynchronous result
81 */82 // Future<AmqpReceiver> createReceiver(string address, AmqpReceiverOptions receiverOptions);83 84 /**
85 * Creates a dynamic receiver. The address is provided by the broker and is available in the {@code completionHandler},
86 * using the {@link AmqpReceiver#address()} method. this method is useful for request-reply to generate a unique
87 * reply address.
88 *
89 * @param completionHandler the completion handler, called when the receiver has been created and opened.
90 * @return the connection.
91 */92 AmqpConnectioncreateDynamicReceiver(Handler!AmqpReceivercompletionHandler);
93 94 /**
95 * Like {@link #createDynamicReceiver(Handler)} but returns a {@code Future} of the asynchronous result
96 */97 // Future<AmqpReceiver> createDynamicReceiver();98 99 /**
100 * Creates a sender used to send messages to the given address. The address must be set. For anonymous sender, check
101 * {@link #createAnonymousSender(Handler)}.
102 *
103 * @param address The target address to attach to, must not be {@code null}
104 * @param completionHandler The handler called with the sender, once opened
105 * @return the connection.
106 * @see #createAnonymousSender(Handler)
107 */108 AmqpConnectioncreateSender(stringaddress, Handler!AmqpSendercompletionHandler);
109 110 /**
111 * Like {@link #createSender(string, Handler)} but returns a {@code Future} of the asynchronous result
112 */113 // Future<AmqpSender> createSender(string address);114 115 /**
116 * Creates a sender used to send messages to the given address. The address must be set. For anonymous sender, check
117 * {@link #createAnonymousSender(Handler)}.
118 *
119 * @param address The target address to attach to, allowed to be {@code null} if the {@code options}
120 * configures the sender to be attached to a dynamic address (provided by the broker).
121 * @param options The AMQP sender options
122 * @param completionHandler The handler called with the sender, once opened
123 * @return the connection.
124 * @see #createAnonymousSender(Handler)
125 */126 AmqpConnectioncreateSender(stringaddress, AmqpSenderOptionsoptions,
127 Handler!AmqpSendercompletionHandler);
128 129 /**
130 * Like {@link #createSender(string, AmqpSenderOptions, Handler)} but returns a {@code Future} of the asynchronous result
131 */132 //Future<AmqpSender> createSender(string address, AmqpSenderOptions options);133 134 /**
135 * Creates an anonymous sender.
136 * <p>
137 * Unlike "regular" sender, this sender is not associated to a specific address, and each message sent must provide
138 * an address. This method can be used in request-reply scenarios where you create a sender to send the reply,
139 * but you don't know the address, as the reply address is passed into the message you are going to receive.
140 *
141 * @param completionHandler The handler called with the created sender, once opened
142 * @return the connection.
143 */144 AmqpConnectioncreateAnonymousSender(Handler!AmqpSendercompletionHandler);
145 146 /**
147 * Like {@link #createAnonymousSender(Handler)} but returns a {@code Future} of the asynchronous result
148 */149 // Future<AmqpSender> createAnonymousSender();150 151 }