001/*
002The contents of this file are subject to the Mozilla Public License Version 1.1 
003(the "License"); you may not use this file except in compliance with the License. 
004You may obtain a copy of the License at http://www.mozilla.org/MPL/ 
005Software distributed under the License is distributed on an "AS IS" basis, 
006WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 
007specific language governing rights and limitations under the License. 
008
009The Original Code is "JMSDestination.java".  Description: 
010"A facade for a JMS Queue or Topic." 
011
012The Initial Developer of the Original Code is University Health Network. Copyright (C) 
0132004.  All Rights Reserved. 
014
015Contributor(s): ______________________________________. 
016
017Alternatively, the contents of this file may be used under the terms of the 
018GNU General Public License (the "GPL"), in which case the provisions of the GPL are 
019applicable instead of those above.  If you wish to allow use of your version of this 
020file only under the terms of the GPL and not to allow others to use your version 
021of this file under the MPL, indicate your decision by deleting  the provisions above 
022and replace  them with the notice and other provisions required by the GPL License.  
023If you do not delete the provisions above, a recipient may use your version of 
024this file under either the MPL or the GPL. 
025*/
026package ca.uhn.hl7v2.protocol;
027
028import javax.jms.Connection;
029import javax.jms.JMSException;
030import javax.jms.Message;
031import javax.jms.TextMessage;
032
033/**
034 * A facade for a JMS Queue or Topic.    
035 * 
036 * @author <a href="mailto:bryan.tripp@uhn.on.ca">Bryan Tripp</a>
037 * @version $Revision: 1.1 $ updated on $Date: 2007-02-19 02:24:38 $ by $Author: jamesagnew $
038 */
039public interface JMSDestination {
040
041    /**
042     * @return the name of the Queue or Topic 
043     * @throws JMSException
044     */
045    public String getName() throws JMSException; 
046    
047    /**
048     * @return a new JMS Message object.  
049     * @throws JMSException
050     */
051    public TextMessage createMessage() throws JMSException;
052
053    /**
054     * Creates a new session, sender/publisher, and receiver/subscriber.  
055     * @throws JMSException
056     */    
057    public void connect() throws JMSException;
058    
059    /**
060     * Closes the JMS session.  
061     * @throws JMSException
062     */
063    public void disconnect() throws JMSException;
064    
065    /**
066     * @return true if connected.  
067     */
068    public boolean isConnected(); 
069    
070    /**
071     * @return the JMS Connection underlying this destination
072     */
073    public Connection getConnection();
074
075    /**
076     * Sends the given message to the JMS destination.  
077     * @param theMessage message to send
078     * @throws JMSException
079     */
080    public void send(Message theMessage) throws JMSException;
081
082    /**
083     * @return a message received from the JMS destination. 
084     * @throws JMSException
085     */
086    public Message receive() throws JMSException;
087    
088}