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 module hunt.amqp.client.AmqpSender;
12 
13 import hunt.amqp.Handler;
14 import hunt.amqp.client.WriteStream;
15 import hunt.amqp.client.AmqpMessage;
16 import hunt.amqp.client.AmqpConnection;
17 
18 import hunt.String;
19 import hunt.Object;
20 import hunt.concurrency.Future;
21 
22 /**
23  * AMQP Sender interface used to send messages.
24  */
25 interface AmqpSender : WriteStream!AmqpMessage {
26 
27 
28   AmqpSender exceptionHandler(Handler!Throwable handler);
29 
30 
31   AmqpSender setWriteQueueMaxSize(int maxSize);
32 
33   /**
34    * Sends an AMQP message. The destination the configured sender address or the address configured in the message.
35    *
36    * @param message the message, must not be {@code null}
37    * @return the current sender
38    */
39 //  @Fluent
40   AmqpSender send(AmqpMessage message);
41 
42   /**
43    * Sends an AMQP message and waits for an acknowledgement. The acknowledgement handler is called with an
44    * {@link AsyncResult} marked as failed if the message has been rejected or re-routed. If the message has been accepted,
45    * the handler is called with a success.
46    *
47    * @param message                the message, must not be {@code null}
48    * @param acknowledgementHandler the acknowledgement handler, must not be {@code null}
49    * @return the current sender
50    */
51   AmqpSender sendWithAck(AmqpMessage message, VoidAsyncHandler acknowledgementHandler);
52 
53   /**
54    * Like {@link #sendWithAck(AmqpMessage, Handler)} but returns a {@code Future} of the asynchronous result
55    */
56   //Future<Void> sendWithAck(AmqpMessage message);
57 
58   /**
59    * Closes the sender.
60    *
61    * @param handler called when the sender has been closed, must not be {@code null}
62    */
63   void close(VoidAsyncHandler handler);
64 
65   /**
66    * Like {@link #close(Handler)} but returns a {@code Future} of the asynchronous result
67    */
68   Future!Void close();
69 
70   /**
71    * @return the configured address.
72    */
73   string address();
74 
75   /**
76    * Gets the connection having created the sender. Cannot be {@code null}
77    *
78    * @return the connection having created the sender.
79    */
80   AmqpConnection connection();
81 }