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.listener; 018 019import javax.jms.JMSException; 020import javax.jms.Message; 021import javax.jms.Session; 022 023/** 024 * Variant of the standard JMS {@link javax.jms.MessageListener} interface, 025 * offering not only the received Message but also the underlying 026 * JMS Session object. The latter can be used to send reply messages, 027 * without the need to access an external Connection/Session, 028 * i.e. without the need to access the underlying ConnectionFactory. 029 * 030 * <p>Supported by Spring's {@link DefaultMessageListenerContainer} 031 * and {@link SimpleMessageListenerContainer}, 032 * as direct alternative to the standard JMS MessageListener interface. 033 * Typically <i>not</i> supported by JCA-based listener containers: 034 * For maximum compatibility, implement a standard JMS MessageListener instead. 035 * 036 * @author Juergen Hoeller 037 * @since 2.0 038 * @see AbstractMessageListenerContainer#setMessageListener 039 * @see DefaultMessageListenerContainer 040 * @see SimpleMessageListenerContainer 041 * @see org.springframework.jms.listener.endpoint.JmsMessageEndpointManager 042 * @see javax.jms.MessageListener 043 */ 044public interface SessionAwareMessageListener<M extends Message> { 045 046 /** 047 * Callback for processing a received JMS message. 048 * <p>Implementors are supposed to process the given Message, 049 * typically sending reply messages through the given Session. 050 * @param message the received JMS message (never {@code null}) 051 * @param session the underlying JMS Session (never {@code null}) 052 * @throws JMSException if thrown by JMS methods 053 */ 054 void onMessage(M message, Session session) throws JMSException; 055 056}