View Javadoc

1   /*
2    * $Id: WebsphereTransactedJmsMessageReceiver.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.transport.jms.websphere;
12  
13  import org.mule.api.construct.FlowConstruct;
14  import org.mule.api.endpoint.InboundEndpoint;
15  import org.mule.api.lifecycle.CreateException;
16  import org.mule.api.lifecycle.InitialisationException;
17  import org.mule.api.transport.Connector;
18  import org.mule.transport.jms.XaTransactedJmsMessageReceiver;
19  
20  import javax.jms.Session;
21  
22  public class WebsphereTransactedJmsMessageReceiver extends XaTransactedJmsMessageReceiver
23  {
24      public WebsphereTransactedJmsMessageReceiver(Connector connector, FlowConstruct flowConstruct, 
25          InboundEndpoint endpoint) throws InitialisationException, CreateException
26      {
27          super(connector, flowConstruct, endpoint);
28      }
29      
30      protected void doConnect() throws Exception
31      {
32          if (connector.isConnected() && connector.isEagerConsumer())
33          {
34              createConsumer();
35          }
36  
37          // TODO make it configurable. This connection blip is killing performance with WMQ, session create() and close()
38          // are the heaviest operations there, synchronizing on a global QM for this machine
39          // MULE-1150 check whether mule is really connected    
40          if (connector.isConnected() && !this.connected.get() && connector.getSessionFromTransaction() == null)
41          {
42              // check connection by creating session
43              Session s = connector.getConnection().createSession(false, 1);
44              s.close();
45          }
46      }
47  }
48  
49