View | Details | Raw Unified | Return to bug 51841
Collapse All | Expand All

(-)src/protocol/jms/org/apache/jmeter/protocol/jms/client/ReceiveSubscriber.java (-21 / +41 lines)
Lines 84-97 Link Here
84
            String initialContextFactory, String providerUrl, String connfactory, String destinationName,
84
            String initialContextFactory, String providerUrl, String connfactory, String destinationName,
85
            String durableSubscriptionId, boolean useAuth, 
85
            String durableSubscriptionId, boolean useAuth, 
86
            String securityPrincipal, String securityCredentials) throws NamingException, JMSException {
86
            String securityPrincipal, String securityCredentials) throws NamingException, JMSException {
87
        Context ctx = InitialContextFactory.getContext(useProps, 
87
        boolean initSuccess = false;
88
                initialContextFactory, providerUrl, useAuth, securityPrincipal, securityCredentials);
88
        try{
89
        CONN = Utils.getConnection(ctx, connfactory);
89
            Context ctx = InitialContextFactory.getContext(useProps, 
90
        SESSION = CONN.createSession(false, Session.AUTO_ACKNOWLEDGE);
90
                    initialContextFactory, providerUrl, useAuth, securityPrincipal, securityCredentials);
91
        Destination dest = Utils.lookupDestination(ctx, destinationName);
91
            CONN = Utils.getConnection(ctx, connfactory);
92
       	SUBSCRIBER = createSubscriber(SESSION, dest, durableSubscriptionId);
92
            SESSION = CONN.createSession(false, Session.AUTO_ACKNOWLEDGE);
93
        queue = null;
93
            Destination dest = Utils.lookupDestination(ctx, destinationName);
94
        log.debug("<init> complete");
94
           	SUBSCRIBER = createSubscriber(SESSION, dest, durableSubscriptionId);
95
            queue = null;
96
            log.debug("<init> complete");
97
            initSuccess = true;
98
        } finally {
99
            if(!initSuccess) {
100
                close();
101
            }
102
        }
95
    }
103
    }
96
104
97
    /**
105
    /**
Lines 117-135 Link Here
117
            String initialContextFactory, String providerUrl, String connfactory, String destinationName,
125
            String initialContextFactory, String providerUrl, String connfactory, String destinationName,
118
            String durableSubscriptionId, boolean useAuth, 
126
            String durableSubscriptionId, boolean useAuth, 
119
            String securityPrincipal, String securityCredentials) throws NamingException, JMSException {
127
            String securityPrincipal, String securityCredentials) throws NamingException, JMSException {
120
        Context ctx = InitialContextFactory.getContext(useProps, 
128
        boolean initSuccess = false;
121
                initialContextFactory, providerUrl, useAuth, securityPrincipal, securityCredentials);
129
        try{
122
        CONN = Utils.getConnection(ctx, connfactory);
130
            Context ctx = InitialContextFactory.getContext(useProps, 
123
        SESSION = CONN.createSession(false, Session.AUTO_ACKNOWLEDGE);
131
                    initialContextFactory, providerUrl, useAuth, securityPrincipal, securityCredentials);
124
        Destination dest = Utils.lookupDestination(ctx, destinationName);
132
            CONN = Utils.getConnection(ctx, connfactory);
125
        SUBSCRIBER = createSubscriber(SESSION, dest, durableSubscriptionId);
133
            SESSION = CONN.createSession(false, Session.AUTO_ACKNOWLEDGE);
126
        if (queueSize <=0) {
134
            Destination dest = Utils.lookupDestination(ctx, destinationName);
127
            queue = new LinkedBlockingQueue<Message>();
135
            SUBSCRIBER = createSubscriber(SESSION, dest, durableSubscriptionId);
128
        } else {
136
            if (queueSize <=0) {
129
            queue = new LinkedBlockingQueue<Message>(queueSize);            
137
                queue = new LinkedBlockingQueue<Message>();
138
            } else {
139
                queue = new LinkedBlockingQueue<Message>(queueSize);            
140
            }
141
            SUBSCRIBER.setMessageListener(this);
142
            log.debug("<init> complete");
143
            initSuccess = true;
144
        }
145
        finally {
146
            if(!initSuccess) {
147
                close();
148
            }
130
        }
149
        }
131
        SUBSCRIBER.setMessageListener(this);
132
        log.debug("<init> complete");
133
    }
150
    }
134
    
151
    
135
    /**
152
    /**
Lines 208-218 Link Here
208
    public void close() { // called from threadFinished() thread
225
    public void close() { // called from threadFinished() thread
209
        log.debug("close()");
226
        log.debug("close()");
210
        try {
227
        try {
211
            CONN.stop();
228
            if(CONN != null) {
229
                CONN.stop();
230
            }
212
        } catch (JMSException e) {
231
        } catch (JMSException e) {
213
            log.error(e.getMessage());
232
            log.error(e.getMessage());
214
        }
233
        }
215
        Utils.close(SUBSCRIBER, log);
234
        Utils.close(SUBSCRIBER, log);
235
        Utils.close(SUBSCRIBER, log);
216
        Utils.close(SESSION, log);
236
        Utils.close(SESSION, log);
217
        Utils.close(CONN, log);
237
        Utils.close(CONN, log);
218
    }
238
    }
(-)src/protocol/jms/org/apache/jmeter/protocol/jms/client/Publisher.java (-10 / +18 lines)
Lines 94-109 Link Here
94
            String securityPrincipal, String securityCredentials,
94
            String securityPrincipal, String securityCredentials,
95
            boolean staticDestination) throws JMSException, NamingException {
95
            boolean staticDestination) throws JMSException, NamingException {
96
        super();
96
        super();
97
        ctx = InitialContextFactory.getContext(useProps, initialContextFactory, 
97
        boolean initSuccess = false;
98
                providerUrl, useAuth, securityPrincipal, securityCredentials);
98
        try{
99
        connection = Utils.getConnection(ctx, connfactory);
99
            ctx = InitialContextFactory.getContext(useProps, initialContextFactory, 
100
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
100
                    providerUrl, useAuth, securityPrincipal, securityCredentials);
101
        staticDest = staticDestination;
101
            connection = Utils.getConnection(ctx, connfactory);
102
        if (staticDest) {
102
            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
103
            Destination dest = Utils.lookupDestination(ctx, destinationName);
103
            staticDest = staticDestination;
104
            producer = session.createProducer(dest);
104
            if (staticDest) {
105
        } else {
105
                Destination dest = Utils.lookupDestination(ctx, destinationName);
106
            producer = session.createProducer(null);
106
                producer = session.createProducer(dest);
107
            } else {
108
                producer = session.createProducer(null);
109
            }
110
            initSuccess = true;
111
        } finally {
112
            if(!initSuccess) {
113
                close();
114
            }
107
        }
115
        }
108
    }
116
    }
109
117

Return to bug 51841