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.Topic;
29 import javax.jms.TopicSubscriber;
30
31 import com.eviware.soapui.SoapUI;
32 import com.eviware.soapui.model.iface.Request;
33 import com.eviware.soapui.model.iface.Response;
34 import com.eviware.soapui.model.iface.SubmitContext;
35 import com.eviware.soapui.support.StringUtils;
36
37 public class HermesJmsRequestSubscribeTransport extends HermesJmsRequestTransport
38 {
39
40 public Response execute( SubmitContext submitContext, Request request, long timeStarted ) throws Exception
41 {
42 Session topicSession = null;
43 TopicSubscriber topicDurableSubsriber = null;
44 JMSConnectionHolder jmsConnectionHolder = null;
45 try
46 {
47 init( submitContext, request );
48 String clientIDString = StringUtils.hasContent( clientID ) ? clientID : jmsEndpoint.getSessionName() + "-"
49 + jmsEndpoint.getReceive();
50 jmsConnectionHolder = new JMSConnectionHolder( jmsEndpoint, hermes, true, clientIDString, username,
51 password );
52
53
54 topicSession = jmsConnectionHolder.getSession();
55
56 Topic topicSubscribe = jmsConnectionHolder.getTopic( jmsConnectionHolder.getJmsEndpoint().getReceive() );
57
58
59 topicDurableSubsriber = topicSession.createDurableSubscriber( topicSubscribe, StringUtils
60 .hasContent( durableSubscriptionName ) ? durableSubscriptionName : "durableSubscription"
61 + jmsConnectionHolder.getJmsEndpoint().getReceive(), messageSelector, false );
62
63 return makeResponse( submitContext, request, timeStarted, null, topicDurableSubsriber );
64 }
65 catch( JMSException jmse )
66 {
67 return errorResponse( submitContext, request, timeStarted, jmse );
68 }
69 catch( Throwable t )
70 {
71 SoapUI.logError( t );
72 }
73 finally
74 {
75 if( topicDurableSubsriber != null )
76 topicDurableSubsriber.close();
77 closeSessionAndConnection( jmsConnectionHolder != null ? jmsConnectionHolder.getConnection() : null,topicSession );
78 }
79 return null;
80 }
81 }