001 /** 002 * 003 * Copyright 2004 Protique Ltd 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 * 017 **/ 018 package org.activemq.ra; 019 020 import javax.jms.JMSException; 021 import javax.jms.MessageProducer; 022 import javax.jms.Session; 023 024 /** 025 * Represents an object which has-a {@link Session} instance and 026 * an optional, lazily created {@link MessageProducer} instance 027 * which can them be used by a pooling based JMS provider for publishing 028 * messages using the session used by the current thread. 029 * 030 * @version $Revision: 1.1.1.1 $ 031 */ 032 public interface SessionAndProducer { 033 034 /** 035 * Returns the current session being used to process a JMS message in the current thread. 036 */ 037 public Session getSession() throws JMSException; 038 039 /** 040 * Lazily creates a message producer that can be used to send messages using the 041 * same JMS Session which is being used to dispatch messages which minimises the XA 042 * overheard of consuming and producing or allows JMS transactions to be used for consuming 043 * and producing messages. 044 * 045 * @return the current message producer or a new one is lazily created, using a null 046 * destination so the destination must be specified on a send() method. 047 * @throws javax.jms.JMSException 048 */ 049 public MessageProducer getMessageProducer() throws JMSException; 050 }