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  
13  package com.eviware.soapui.impl.wsdl.submit.transports.jms;
14  
15  import javax.jms.JMSException;
16  import javax.jms.Message;
17  import javax.jms.Session;
18  import javax.jms.Topic;
19  
20  import com.eviware.soapui.SoapUI;
21  import com.eviware.soapui.model.iface.Request;
22  import com.eviware.soapui.model.iface.Response;
23  import com.eviware.soapui.model.iface.SubmitContext;
24  
25  public class HermesJmsRequestPublishTransport extends HermesJmsRequestTransport
26  {
27  
28  	public Response execute(SubmitContext submitContext, Request request, long timeStarted) throws Exception
29  	{
30  		Session topicSession = null;
31  		JMSConnectionHolder jmsConnectionHolder = null;
32  		try
33  		{
34  			init( submitContext, request );
35  			jmsConnectionHolder = new JMSConnectionHolder( jmsEndpoint, hermes, true, clientID , username, password);
36  
37  			// session
38  			topicSession = jmsConnectionHolder.getSession();
39  
40  			// destination
41  			Topic topicPublish = jmsConnectionHolder.getTopic( jmsConnectionHolder.getJmsEndpoint().getSend() );
42  
43  			Message messagePublish = messagePublish(submitContext, request, topicSession, jmsConnectionHolder.getHermes(), topicPublish);
44  
45  			return makeEmptyResponse(submitContext, request, timeStarted, messagePublish);
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, topicSession );
58  		}
59  		return null;
60  	}
61  
62  }