1 /*
2  * Copyright 2002-2018 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 module hunt.stomp.core.MessageRequestReplyOperations;
18 
19 import hunt.collection.Map;
20 
21 
22 import hunt.stomp.Message;
23 import hunt.stomp.MessagingException;
24 
25 /**
26  * Operations for sending messages to and receiving the reply from a destination.
27  *
28  * @author Mark Fisher
29  * @author Rossen Stoyanchev
30  * @since 4.0
31  * @param (T) the type of destination
32  * @see GenericMessagingTemplate
33  */
34 interface MessageRequestReplyOperations(T) {
35 
36 	/**
37 	 * Send a request message and receive the reply from a default destination.
38 	 * @param requestMessage the message to send
39 	 * @return the reply, possibly {@code null} if the message could not be received,
40 	 * for example due to a timeout
41 	 */
42 	
43 	Message!(T) sendAndReceive(Message!(T) requestMessage);
44 
45 	/**
46 	 * Send a request message and receive the reply from the given destination.
47 	 * @param destination the target destination
48 	 * @param requestMessage the message to send
49 	 * @return the reply, possibly {@code null} if the message could not be received,
50 	 * for example due to a timeout
51 	 */
52 	
53 	Message!(T) sendAndReceive(T destination, Message!(T) requestMessage);
54 
55 	/**
56 	 * Convert the given request Object to serialized form, possibly using a
57 	 * {@link hunt.stomp.converter.MessageConverter}, send
58 	 * it as a {@link Message} to a default destination, receive the reply and convert
59 	 * its body of the specified target class.
60 	 * @param request payload for the request message to send
61 	 * @param targetClass the target type to convert the payload of the reply to
62 	 * @return the payload of the reply message, possibly {@code null} if the message
63 	 * could not be received, for example due to a timeout
64 	 */
65 	
66 	// <T> T convertSendAndReceive(Object request, Class!(T) targetClass);
67 
68 	/**
69 	 * Convert the given request Object to serialized form, possibly using a
70 	 * {@link hunt.stomp.converter.MessageConverter}, send
71 	 * it as a {@link Message} to the given destination, receive the reply and convert
72 	 * its body of the specified target class.
73 	 * @param destination the target destination
74 	 * @param request payload for the request message to send
75 	 * @param targetClass the target type to convert the payload of the reply to
76 	 * @return the payload of the reply message, possibly {@code null} if the message
77 	 * could not be received, for example due to a timeout
78 	 */
79 	
80 	// <T> T convertSendAndReceive(T destination, Object request, Class!(T) targetClass);
81 
82 	/**
83 	 * Convert the given request Object to serialized form, possibly using a
84 	 * {@link hunt.stomp.converter.MessageConverter}, send
85 	 * it as a {@link Message} with the given headers, to the specified destination,
86 	 * receive the reply and convert its body of the specified target class.
87 	 * @param destination the target destination
88 	 * @param request payload for the request message to send
89 	 * @param headers headers for the request message to send
90 	 * @param targetClass the target type to convert the payload of the reply to
91 	 * @return the payload of the reply message, possibly {@code null} if the message
92 	 * could not be received, for example due to a timeout
93 	 */
94 	
95 	// <T> T convertSendAndReceive(
96 	// 		T destination, Object request, Map!(string, Object) headers, Class!(T) targetClass);
97 
98 	/**
99 	 * Convert the given request Object to serialized form, possibly using a
100 	 * {@link hunt.stomp.converter.MessageConverter},
101 	 * apply the given post processor and send the resulting {@link Message} to a
102 	 * default destination, receive the reply and convert its body of the given
103 	 * target class.
104 	 * @param request payload for the request message to send
105 	 * @param targetClass the target type to convert the payload of the reply to
106 	 * @param requestPostProcessor post process to apply to the request message
107 	 * @return the payload of the reply message, possibly {@code null} if the message
108 	 * could not be received, for example due to a timeout
109 	 */
110 	
111 	// <T> T convertSendAndReceive(
112 	// 		Object request, Class!(T) targetClass, MessagePostProcessor requestPostProcessor);
113 
114 	/**
115 	 * Convert the given request Object to serialized form, possibly using a
116 	 * {@link hunt.stomp.converter.MessageConverter},
117 	 * apply the given post processor and send the resulting {@link Message} to the
118 	 * given destination, receive the reply and convert its body of the given
119 	 * target class.
120 	 * @param destination the target destination
121 	 * @param request payload for the request message to send
122 	 * @param targetClass the target type to convert the payload of the reply to
123 	 * @param requestPostProcessor post process to apply to the request message
124 	 * @return the payload of the reply message, possibly {@code null} if the message
125 	 * could not be received, for example due to a timeout
126 	 */
127 	
128 	// <T> T convertSendAndReceive(T destination, Object request, Class!(T) targetClass,
129 	// 		MessagePostProcessor requestPostProcessor);
130 
131 	/**
132 	 * Convert the given request Object to serialized form, possibly using a
133 	 * {@link hunt.stomp.converter.MessageConverter},
134 	 * wrap it as a message with the given headers, apply the given post processor
135 	 * and send the resulting {@link Message} to the specified destination, receive
136 	 * the reply and convert its body of the given target class.
137 	 * @param destination the target destination
138 	 * @param request payload for the request message to send
139 	 * @param targetClass the target type to convert the payload of the reply to
140 	 * @param requestPostProcessor post process to apply to the request message
141 	 * @return the payload of the reply message, possibly {@code null} if the message
142 	 * could not be received, for example due to a timeout
143 	 */
144 	
145 	// <T> T convertSendAndReceive(
146 	// 		T destination, Object request, Map!(string, Object) headers, Class!(T) targetClass,
147 	// 		MessagePostProcessor requestPostProcessor);
148 
149 }