001/**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  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 */
017package org.apache.activemq.ra;
018
019import javax.jms.JMSException;
020import javax.jms.MessageProducer;
021import javax.jms.Session;
022
023/**
024 * Represents an object which has-a {@link Session} instance and
025 * an optional, lazily created {@link MessageProducer} instance
026 * which can them be used by a pooling based JMS provider for publishing
027 * messages using the session used by the current thread.
028 *
029 * 
030 */
031public interface InboundContext {
032
033    /**
034     * Returns the current session being used to process a JMS message in the current thread.
035     */
036    Session getSession() throws JMSException;
037
038    /**
039     * Lazily creates a message producer that can be used to send messages using the
040     * same JMS Session which is being used to dispatch messages which minimises the XA
041     * overheard of consuming and producing or allows JMS transactions to be used for consuming
042     * and producing messages.
043     *
044     * @return the current message producer or a new one is lazily created, using a null
045     *         destination so the destination must be specified on a send() method.
046     * @throws javax.jms.JMSException
047     */
048    MessageProducer getMessageProducer() throws JMSException;
049}