View Javadoc

1   /*
2    * $Id: WebsphereTransactedJmsMessageReceiver.java 22674 2011-08-16 07:20:10Z dirk.olmes $
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      @Override
31      protected void doConnect() throws Exception
32      {
33          super.doConnect();
34  
35          if (connector.isConnected() && connector.isEagerConsumer())
36          {
37              createConsumer();
38          }
39  
40          // TODO make it configurable. This connection blip is killing performance with WMQ, session create() and close()
41          // are the heaviest operations there, synchronizing on a global QM for this machine
42          // MULE-1150 check whether mule is really connected
43          if (connector.isConnected() && !this.connected.get() && connector.getSessionFromTransaction() == null)
44          {
45              // check connection by creating session
46              Session s = connector.getConnection().createSession(false, 1);
47              s.close();
48          }
49      }
50  }
51  
52