001/*
002 * Copyright 2002-2020 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.jms.core;
018
019import javax.jms.JMSException;
020import javax.jms.Message;
021
022/**
023 * To be used with JmsTemplate's send method that converts an object to a message.
024 *
025 * <p>This allows for further modification of the message after it has been processed
026 * by the converter and is useful for setting JMS headers and properties.
027 *
028 * <p>Often implemented as a lambda expression or as an anonymous inner class.
029 *
030 * @author Mark Pollack
031 * @since 1.1
032 * @see JmsTemplate#convertAndSend(String, Object, MessagePostProcessor)
033 * @see JmsTemplate#convertAndSend(javax.jms.Destination, Object, MessagePostProcessor)
034 * @see org.springframework.jms.support.converter.MessageConverter
035 */
036@FunctionalInterface
037public interface MessagePostProcessor {
038
039        /**
040         * Process the given message.
041         * <p>The returned message is typically a modified version of the original.
042         * @param message the JMS message from the MessageConverter
043         * @return a post-processed variant of the message, or simply the incoming
044         * message; never {@code null}
045         * @throws javax.jms.JMSException if thrown by JMS API methods
046         */
047        Message postProcessMessage(Message message) throws JMSException;
048
049}