View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2010 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
10   *  See the GNU Lesser General Public License for more details at gnu.org.
11   */
12  package com.eviware.soapui.impl.wsdl.submit.transports.jms;
13  
14  import javax.jms.JMSException;
15  import javax.jms.MessageConsumer;
16  import javax.jms.Queue;
17  import javax.jms.Session;
18  
19  import com.eviware.soapui.SoapUI;
20  import com.eviware.soapui.model.iface.Request;
21  import com.eviware.soapui.model.iface.Response;
22  import com.eviware.soapui.model.iface.SubmitContext;
23  
24  public class HermesJmsRequestReceiveTransport extends HermesJmsRequestTransport
25  {
26  
27  	public Response execute( SubmitContext submitContext, Request request, long timeStarted ) throws Exception
28  	{
29  		Session queueSession = null;
30  		JMSConnectionHolder jmsConnectionHolder = null;
31  		try
32  		{
33  			init( submitContext, request );
34  			jmsConnectionHolder = new JMSConnectionHolder( jmsEndpoint, hermes,  false, clientID, username, password );
35  
36  			// session
37  			queueSession = jmsConnectionHolder.getSession();
38  
39  			// destination
40  			Queue queue = jmsConnectionHolder.getQueue( jmsConnectionHolder.getJmsEndpoint().getReceive() );
41  
42  			// consumer
43  			MessageConsumer messageConsumer = queueSession.createConsumer( queue, messageSelector );
44  
45  			return makeResponse( submitContext, request, timeStarted, null, messageConsumer );
46  
47  		}
48  		catch( JMSException jmse )
49  		{
50  			return errorResponse( submitContext, request, timeStarted, jmse );
51  		}
52  		catch( Throwable t )
53  		{
54  			SoapUI.logError( t );
55  		}
56  		finally
57  		{
58  			closeSessionAndConnection( jmsConnectionHolder != null ? jmsConnectionHolder.getConnection() : null,queueSession );
59  		}
60  		return null;
61  	}
62  }