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