001/* 002 * Copyright 2002-2013 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 * Extends {@link MessageSendingOperations} and adds operations for sending messages 026 * to a destination specified as a (resolvable) String name. 027 * 028 * @author Mark Fisher 029 * @author Rossen Stoyanchev 030 * @since 4.0 031 * @see DestinationResolver 032 */ 033public interface DestinationResolvingMessageSendingOperations<D> extends MessageSendingOperations<D> { 034 035 /** 036 * Resolve the given destination name to a destination and send a message to it. 037 * @param destinationName the destination name to resolve 038 * @param message the message to send 039 */ 040 void send(String destinationName, Message<?> message) throws MessagingException; 041 042 /** 043 * Resolve the given destination name to a destination, convert the payload Object 044 * to serialized form, possibly using a 045 * {@link org.springframework.messaging.converter.MessageConverter}, 046 * wrap it as a message and send it to the resolved destination. 047 * @param destinationName the destination name to resolve 048 * @param payload the Object to use as payload 049 */ 050 <T> void convertAndSend(String destinationName, T payload) throws MessagingException; 051 052 /** 053 * Resolve the given destination name to a destination, convert the payload 054 * Object to serialized form, possibly using a 055 * {@link org.springframework.messaging.converter.MessageConverter}, 056 * wrap it as a message with the given headers and send it to the resolved 057 * destination. 058 * @param destinationName the destination name to resolve 059 * @param payload the Object to use as payload 060 * @param headers headers for the message to send 061 */ 062 <T> void convertAndSend(String destinationName, T payload, Map<String, Object> headers) 063 throws MessagingException; 064 065 /** 066 * Resolve the given destination name to a destination, convert the payload 067 * Object to serialized form, possibly using a 068 * {@link org.springframework.messaging.converter.MessageConverter}, 069 * wrap it as a message, apply the given post processor, and send the resulting 070 * message to the resolved destination. 071 * @param destinationName the destination name to resolve 072 * @param payload the Object to use as payload 073 * @param postProcessor the post processor to apply to the message 074 */ 075 <T> void convertAndSend(String destinationName, T payload, MessagePostProcessor postProcessor) 076 throws MessagingException; 077 078 /** 079 * Resolve the given destination name to a destination, convert the payload 080 * Object to serialized form, possibly using a 081 * {@link org.springframework.messaging.converter.MessageConverter}, 082 * wrap it as a message with the given headers, apply the given post processor, 083 * and send the resulting message to the resolved destination. 084 * @param destinationName the destination name to resolve 085 * @param payload the Object to use as payload 086 * @param headers headers for the message to send 087 * @param postProcessor the post processor to apply to the message 088 */ 089 <T> void convertAndSend(String destinationName, T payload, Map<String, Object> headers, 090 MessagePostProcessor postProcessor) throws MessagingException; 091 092}