activemq-cpp-3.9.5
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
32
34#include <decaf/util/StlSet.h>
37
38namespace activemq {
39namespace core {
40namespace kernels {
42}
43
44 using decaf::lang::Pointer;
45
46 class LocalTransactionEventListener;
48 class TxContextData;
49
59 class AMQCPP_API ActiveMQTransactionContext : public cms::XAResource {
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
76 ActiveMQTransactionContext(const ActiveMQTransactionContext&);
77 ActiveMQTransactionContext& operator=(const ActiveMQTransactionContext&);
78
79 public:
80
90 const decaf::util::Properties& properties);
91
93
99
105
110 virtual void begin();
111
116 virtual void commit();
117
122 virtual void rollback();
123
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
Concrete connection used for all connectors to the ActiveMQ broker.
Definition ActiveMQConnection.h:62
virtual void removeSynchronization(const Pointer< Synchronization > &sync)
Removes a Synchronization to this Transaction.
virtual void begin()
Begins a new transaction if one is not currently in progress.
virtual bool isInLocalTransaction() const
Checks to see if there is currently an Local Transaction in progess, returns false if not,...
ActiveMQTransactionContext(activemq::core::kernels::ActiveMQSessionKernel *session, const decaf::util::Properties &properties)
Constructor.
virtual int prepare(const cms::Xid *xid)
Requests the Resource manager to prepare to commit a specified transaction.
virtual void start(const cms::Xid *xid, int flags)
Starts work for a specified transaction branch.
virtual void addSynchronization(const Pointer< Synchronization > &sync)
Adds a Synchronization to this Transaction.
virtual bool isSameRM(const cms::XAResource *theXAResource)
Returns true if the ResourceManager for this XAResource is the same as the Resource Manager for a sup...
virtual bool setTransactionTimeout(int seconds)
Sets the transaction timeout value for this XAResource.
virtual bool isInTransaction() const
Checks to see if there is currently a Transaction in progress returns false if not,...
virtual void rollback(const cms::Xid *xid)
Requests the Resource Manager to rollback a specified transaction branch.
virtual void commit(const cms::Xid *xid, bool onePhase)
Commits a global transaction.
virtual int getTransactionTimeout() const
Gets the transaction timeout value for this XAResource.
virtual void end(const cms::Xid *xid, int flags)
Ends the work done for a transaction branch.
virtual void forget(const cms::Xid *xid)
Informs the Resource Manager that it can forget about a specified transaction branch.
virtual const decaf::lang::Pointer< commands::TransactionId > & getTransactionId() const
Get the Transaction Id object for the current Transaction, returns NULL if no transaction is running.
virtual bool isInXATransaction() const
Checks to see if there is currently an XA Transaction in progress, returns false if not,...
virtual void commit()
Commit the current Transaction.
virtual void rollback()
Rollback the current Transaction.
virtual int recover(int flag, cms::Xid **recovered)
Get a list of prepared transaction branches.
Definition ActiveMQSessionKernel.h:67
CMS API Exception that is the base for all exceptions thrown from CMS classes.
Definition CMSException.h:50
The XAException is thrown by the Resource Manager (RM) to inform the Transaction Manager of an error ...
Definition XAException.h:32
The XAResource interface is a CMS mapping of the industry standard XA interface based on the X/Open C...
Definition XAResource.h:44
An interface which provides a mapping for the X/Open XID transaction identifier structure.
Definition Xid.h:37
Definition Exception.h:38
Decaf's implementation of a Smart Pointer that is a template on a Type and is Thread Safe if the defa...
Definition Pointer.h:53
Java-like properties class for mapping string names to string values.
Definition Properties.h:53
Set template that wraps around a std::set to provide a more user-friendly interface and to provide co...
Definition StlSet.h:39
#define local
Definition gzguts.h:40
Definition ActiveMQQueueBrowser.h:37
Definition ActiveMQTempDestination.h:29
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition CachedConsumer.h:24