001/* 002 * Copyright 2002-2012 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; 021import javax.jms.Session; 022 023/** 024 * Creates a JMS message given a {@link Session}. 025 * 026 * <p>The {@code Session} typically is provided by an instance 027 * of the {@link JmsTemplate} class. 028 * 029 * <p>Implementations <i>do not</i> need to concern themselves with 030 * checked {@code JMSExceptions} (from the '{@code javax.jms}' 031 * package) that may be thrown from operations they attempt. The 032 * {@code JmsTemplate} will catch and handle these 033 * {@code JMSExceptions} appropriately. 034 * 035 * @author Mark Pollack 036 * @since 1.1 037 */ 038public interface MessageCreator { 039 040 /** 041 * Create a {@link Message} to be sent. 042 * @param session the JMS {@link Session} to be used to create the 043 * {@code Message} (never {@code null}) 044 * @return the {@code Message} to be sent 045 * @throws javax.jms.JMSException if thrown by JMS API methods 046 */ 047 Message createMessage(Session session) throws JMSException; 048 049}