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