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.MessageSendingOperations; 18 19 import hunt.stomp.core.MessagePostProcessor; 20 import hunt.stomp.Message; 21 import hunt.stomp.MessagingException; 22 23 import hunt.collection.Map; 24 25 /** 26 * Operations for sending messages to a destination. 27 * 28 * @author Mark Fisher 29 * @author Rossen Stoyanchev 30 * @since 4.0 31 * @param (T) the destination type 32 */ 33 interface MessageSendingOperations(T) { 34 35 /** 36 * Send a message to a default destination. 37 * @param message the message to send 38 */ 39 void send(MessageBase message); 40 41 /** 42 * Send a message to the given destination. 43 * @param destination the target destination 44 * @param message the message to send 45 */ 46 void send(T destination, MessageBase message); 47 48 /** 49 * Convert the given Object to serialized form, possibly using a 50 * {@link hunt.stomp.converter.MessageConverter}, 51 * wrap it as a message and send it to a default destination. 52 * @param payload the Object to use as payload 53 */ 54 void convertAndSend(Object payload); 55 56 /** 57 * Convert the given Object to serialized form, possibly using a 58 * {@link hunt.stomp.converter.MessageConverter}, 59 * wrap it as a message and send it to the given destination. 60 * @param destination the target destination 61 * @param payload the Object to use as payload 62 */ 63 void convertAndSend(T destination, Object payload); 64 65 /** 66 * Convert the given Object to serialized form, possibly using a 67 * {@link hunt.stomp.converter.MessageConverter}, 68 * wrap it as a message with the given headers and send it to 69 * the given destination. 70 * @param destination the target destination 71 * @param payload the Object to use as payload 72 * @param headers headers for the message to send 73 */ 74 void convertAndSend(T destination, Object payload, Map!(string, Object) headers); 75 76 /** 77 * Convert the given Object to serialized form, possibly using a 78 * {@link hunt.stomp.converter.MessageConverter}, 79 * wrap it as a message, apply the given post processor, and send 80 * the resulting message to a default destination. 81 * @param payload the Object to use as payload 82 * @param postProcessor the post processor to apply to the message 83 */ 84 void convertAndSend(Object payload, MessagePostProcessor postProcessor); 85 86 /** 87 * Convert the given Object to serialized form, possibly using a 88 * {@link hunt.stomp.converter.MessageConverter}, 89 * wrap it as a message, apply the given post processor, and send 90 * the resulting message to the given destination. 91 * @param destination the target destination 92 * @param payload the Object to use as payload 93 * @param postProcessor the post processor to apply to the message 94 */ 95 void convertAndSend(T destination, Object payload, MessagePostProcessor postProcessor); 96 97 /** 98 * Convert the given Object to serialized form, possibly using a 99 * {@link hunt.stomp.converter.MessageConverter}, 100 * wrap it as a message with the given headers, apply the given post processor, 101 * and send the resulting message to the given destination. 102 * @param destination the target destination 103 * @param payload the Object to use as payload 104 * @param headers headers for the message to send 105 * @param postProcessor the post processor to apply to the message 106 */ 107 void convertAndSend(T destination, Object payload, Map!(string, Object) headers, 108 MessagePostProcessor postProcessor); 109 110 }