activemq-cpp-3.8.2
ActiveMQTransactionContext.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #ifndef _ACTIVEMQ_CORE_ACTIVEMQTRANSACTIONCONTEXT_H_
18 #define _ACTIVEMQ_CORE_ACTIVEMQTRANSACTIONCONTEXT_H_
19 
20 #include <memory>
21 
22 #include <cms/Message.h>
23 #include <cms/XAResource.h>
24 #include <cms/CMSException.h>
25 #include <cms/XAException.h>
26 
27 #include <activemq/util/Config.h>
32 
34 #include <decaf/util/StlSet.h>
35 #include <decaf/util/Properties.h>
37 
38 namespace activemq {
39 namespace core {
40 namespace kernels {
41  class ActiveMQSessionKernel;
42 }
43 
45 
46  class LocalTransactionEventListener;
47  class ActiveMQConnection;
48  class TxContextData;
49 
60  private:
61 
62  // Internal structure to hold all class TX data.
63  TxContextData* context;
64 
65  // Session this Transaction is associated with
67 
68  // The Connection that is the parent of the Session.
69  ActiveMQConnection* connection;
70 
71  // List of Registered Synchronizations
73 
74  private:
75 
78 
79  public:
80 
90  const decaf::util::Properties& properties);
91 
92  virtual ~ActiveMQTransactionContext();
93 
98  virtual void addSynchronization(const Pointer<Synchronization>& sync);
99 
104  virtual void removeSynchronization(const Pointer<Synchronization>& sync);
105 
110  virtual void begin();
111 
116  virtual void commit();
117 
122  virtual void rollback();
123 
130  virtual const decaf::lang::Pointer<commands::TransactionId>& getTransactionId() const;
131 
138  virtual bool isInTransaction() const;
139 
146  virtual bool isInLocalTransaction() const;
147 
154  virtual bool isInXATransaction() const;
155 
156  public: // XAResource implementation.
157 
158  virtual void commit(const cms::Xid* xid, bool onePhase);
159 
160  virtual void end(const cms::Xid* xid, int flags);
161 
162  virtual void forget(const cms::Xid* xid);
163 
164  virtual int getTransactionTimeout() const;
165 
166  virtual bool isSameRM(const cms::XAResource* theXAResource);
167 
168  virtual int prepare(const cms::Xid* xid);
169 
170  virtual int recover(int flag, cms::Xid** recovered);
171 
172  virtual void rollback(const cms::Xid* xid);
173 
174  virtual bool setTransactionTimeout(int seconds);
175 
176  virtual void start(const cms::Xid* xid, int flags);
177 
178  private:
179 
180  std::string getResourceManagerId() const;
181  void setXid(const cms::Xid* xid);
182  bool equals(const cms::Xid* local, const cms::Xid* remote);
183  cms::XAException toXAException(cms::CMSException& ex);
184  cms::XAException toXAException(decaf::lang::Exception& ex);
185 
186  void beforeEnd();
187  void afterCommit();
188  void afterRollback();
189 
190  };
191 
192 }}
193 
194 #endif /*_ACTIVEMQ_CORE_ACTIVEMQTRANSACTIONCONTEXT_H_*/
#define AMQCPP_API
Definition: Config.h:30
An interface which provides a mapping for the X/Open XID transaction identifier structure.
Definition: Xid.h:37
The XAResource interface is a CMS mapping of the industry standard XA interface based on the X/Open C...
Definition: XAResource.h:44
Set template that wraps around a std::set to provide a more user-friendly interface and to provide co...
Definition: StlSet.h:39
The XAException is thrown by the Resource Manager (RM) to inform the Transaction Manager of an error ...
Definition: XAException.h:32
#define local
Definition: gzguts.h:40
CMS API Exception that is the base for all exceptions thrown from CMS classes.
Definition: CMSException.h:50
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: CachedConsumer.h:24
Definition: Exception.h:38
Java-like properties class for mapping string names to string values.
Definition: Properties.h:53
Definition: ActiveMQSessionKernel.h:65
Decaf&#39;s implementation of a Smart Pointer that is a template on a Type and is Thread Safe if the defa...
Definition: Pointer.h:53
Concrete connection used for all connectors to the ActiveMQ broker.
Definition: ActiveMQConnection.h:60
Transaction Management class, hold messages that are to be redelivered upon a request to roll-back...
Definition: ActiveMQTransactionContext.h:59