001/* 002 * Copyright 2002-2015 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.messaging.core; 018 019import java.util.Map; 020 021import org.springframework.messaging.Message; 022import org.springframework.messaging.MessagingException; 023 024/** 025 * Operations for sending messages to a destination. 026 * 027 * @author Mark Fisher 028 * @author Rossen Stoyanchev 029 * @since 4.0 030 * @param <D> the type of destination to send messages to 031 */ 032public interface MessageSendingOperations<D> { 033 034 /** 035 * Send a message to a default destination. 036 * @param message the message to send 037 */ 038 void send(Message<?> message) throws MessagingException; 039 040 /** 041 * Send a message to the given destination. 042 * @param destination the target destination 043 * @param message the message to send 044 */ 045 void send(D destination, Message<?> message) throws MessagingException; 046 047 /** 048 * Convert the given Object to serialized form, possibly using a 049 * {@link org.springframework.messaging.converter.MessageConverter}, 050 * wrap it as a message and send it to a default destination. 051 * @param payload the Object to use as payload 052 */ 053 void convertAndSend(Object payload) throws MessagingException; 054 055 /** 056 * Convert the given Object to serialized form, possibly using a 057 * {@link org.springframework.messaging.converter.MessageConverter}, 058 * wrap it as a message and send it to the given destination. 059 * @param destination the target destination 060 * @param payload the Object to use as payload 061 */ 062 void convertAndSend(D destination, Object payload) throws MessagingException; 063 064 /** 065 * Convert the given Object to serialized form, possibly using a 066 * {@link org.springframework.messaging.converter.MessageConverter}, 067 * wrap it as a message with the given headers and send it to 068 * the given destination. 069 * @param destination the target destination 070 * @param payload the Object to use as payload 071 * @param headers headers for the message to send 072 */ 073 void convertAndSend(D destination, Object payload, Map<String, Object> headers) throws MessagingException; 074 075 /** 076 * Convert the given Object to serialized form, possibly using a 077 * {@link org.springframework.messaging.converter.MessageConverter}, 078 * wrap it as a message, apply the given post processor, and send 079 * the resulting message to a default destination. 080 * @param payload the Object to use as payload 081 * @param postProcessor the post processor to apply to the message 082 */ 083 void convertAndSend(Object payload, MessagePostProcessor postProcessor) throws MessagingException; 084 085 /** 086 * Convert the given Object to serialized form, possibly using a 087 * {@link org.springframework.messaging.converter.MessageConverter}, 088 * wrap it as a message, apply the given post processor, and send 089 * the resulting message to the given destination. 090 * @param destination the target destination 091 * @param payload the Object to use as payload 092 * @param postProcessor the post processor to apply to the message 093 */ 094 void convertAndSend(D destination, Object payload, MessagePostProcessor postProcessor) throws MessagingException; 095 096 /** 097 * Convert the given Object to serialized form, possibly using a 098 * {@link org.springframework.messaging.converter.MessageConverter}, 099 * wrap it as a message with the given headers, apply the given post processor, 100 * and send the resulting message to the given destination. 101 * @param destination the target destination 102 * @param payload the Object to use as payload 103 * @param headers headers for the message to send 104 * @param postProcessor the post processor to apply to the message 105 */ 106 void convertAndSend(D destination, Object payload, Map<String, Object> headers, MessagePostProcessor postProcessor) 107 throws MessagingException; 108 109}