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.Message;
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 HermesJmsRequestSendTransport 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  			// queue
40  			Queue queueSend = jmsConnectionHolder.getQueue( jmsConnectionHolder.getJmsEndpoint().getSend() );
41  
42  			Message messageSend = messageSend( submitContext, request, queueSession, jmsConnectionHolder.getHermes(),
43  					queueSend );
44  
45  			return makeEmptyResponse( submitContext, request, timeStarted, messageSend );
46  		}
47  		catch( JMSException jmse )
48  		{
49  			return errorResponse( submitContext, request, timeStarted, jmse );
50  		}
51  		catch( Throwable t )
52  		{
53  			SoapUI.logError( t );
54  		}
55  		finally
56  		{
57  			closeSessionAndConnection( jmsConnectionHolder != null ? jmsConnectionHolder.getConnection() : null,queueSession );
58  		}
59  		return null;
60  	}
61  }