01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.jms.listener;
18:
19: import javax.jms.JMSException;
20: import javax.jms.Message;
21: import javax.jms.Session;
22:
23: /**
24: * Variant of the standard JMS {@link javax.jms.MessageListener} interface,
25: * offering not only the received Message but also the underlying
26: * JMS Session object. The latter can be used to send reply messages,
27: * without the need to access an external Connection/Session,
28: * i.e. without the need to access the underlying ConnectionFactory.
29: *
30: * <p>Supported by Spring's {@link DefaultMessageListenerContainer},
31: * {@link SimpleMessageListenerContainer} and
32: * {@link org.springframework.jms.listener.serversession.ServerSessionMessageListenerContainer},
33: * as direct alternative to the standard JMS MessageListener interface.
34: * Typically <i>not</i> supported by JCA-based listener containers:
35: * For maximum compatibility, implement a standard JMS MessageListener instead.
36: *
37: * @author Juergen Hoeller
38: * @since 2.0
39: * @see AbstractMessageListenerContainer#setMessageListener
40: * @see DefaultMessageListenerContainer
41: * @see SimpleMessageListenerContainer
42: * @see org.springframework.jms.listener.serversession.ServerSessionMessageListenerContainer
43: * @see javax.jms.MessageListener
44: */
45: public interface SessionAwareMessageListener {
46:
47: /**
48: * Callback for processing a received JMS message.
49: * <p>Implementors are supposed to process the given Message,
50: * typically sending reply messages through the given Session.
51: * @param message the received JMS message (never <code>null</code>)
52: * @param session the underlying JMS Session (never <code>null</code>)
53: * @throws JMSException if thrown by JMS methods
54: */
55: void onMessage(Message message, Session session)
56: throws JMSException;
57:
58: }
|