1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package com.eviware.soapui.impl.wsdl.submit.transports.jms;
25
26 import javax.jms.JMSException;
27 import javax.jms.Session;
28 import javax.jms.TopicSubscriber;
29
30 import com.eviware.soapui.SoapUI;
31 import com.eviware.soapui.model.iface.Request;
32 import com.eviware.soapui.model.iface.Response;
33 import com.eviware.soapui.model.iface.SubmitContext;
34 import com.eviware.soapui.support.StringUtils;
35
36 public class HermesJmsRequestSubscribeTransport extends HermesJmsRequestTransport
37 {
38
39 public Response execute( SubmitContext submitContext, Request request, long timeStarted ) throws Exception
40 {
41 Session topicSession = null;
42 TopicSubscriber topicDurableSubsriber = null;
43 JMSConnectionHolder jmsConnectionHolder = null;
44 try
45 {
46 init( submitContext, request );
47 String clientIDString = StringUtils.hasContent( clientID ) ? clientID : jmsEndpoint.getSessionName() + "-"
48 + jmsEndpoint.getReceive();
49 jmsConnectionHolder = new JMSConnectionHolder( jmsEndpoint, hermes, true, clientIDString, username,
50 password );
51
52
53 topicSession = jmsConnectionHolder.getSession();
54
55 topicDurableSubsriber = createDurableSubscription( submitContext, topicSession, jmsConnectionHolder );
56
57 return makeResponse( submitContext, request, timeStarted, null, topicDurableSubsriber );
58 }
59 catch( JMSException jmse )
60 {
61 return errorResponse( submitContext, request, timeStarted, jmse );
62 }
63 catch( Throwable t )
64 {
65 SoapUI.logError( t );
66 }
67 finally
68 {
69 if( topicDurableSubsriber != null )
70 topicDurableSubsriber.close();
71 jmsConnectionHolder.closeAll();
72 closeSessionAndConnection( jmsConnectionHolder != null ? jmsConnectionHolder.getConnection() : null,topicSession );
73 }
74 return null;
75 }
76 }