fintp_connectors
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
DbFetcher.h
Go to the documentation of this file.
1 /*
2 * FinTP - Financial Transactions Processing Application
3 * Copyright (C) 2013 Business Information Systems (Allevo) S.R.L.
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>
17 * or contact Allevo at : 031281 Bucuresti, 23C Calea Vitan, Romania,
18 * phone +40212554577, office@allevo.ro <mailto:office@allevo.ro>, www.allevo.ro.
19 */
20 
21 #ifndef DBFETCHER_H
22 #define DBFETCHER_H
23 
24 #include "DB/DbWatcher.h"
25 #include "Database.h"
26 #include "DatabaseProvider.h"
27 
28 #include "../Endpoint.h"
29 
30 // Database to Mq
31 
33 {
34  protected :
35 
36  // methods for controlling the endpoint
37  void internalStart();
38  void internalStop();
39 
40  public:
41 
42  // constructor
43  DbFetcher();
44 
45  //destructor
46  ~DbFetcher();
47 
48  // called before start. allows the endpoint to prepare environment
49  void Init();
50 
51  // methods for transactional execution
54 
55  //Connect to database
56  string Prepare();
57 
59  // Delete processed data, disconnect from database
60  void Commit();
61 
63  // Delete processed data, disconnect from database
64  void Abort();
65 
67  // Disconnect from database
68  void Rollback();
69 
72  //Select data, convert to XML format, passed them to be processed
73  void Process( const string& correlationId );
74 
75  static void NotificationCallback( const AbstractWatcher::NotificationObject* notification );
76 
77  static DbFetcher* m_Me;
78  pthread_t getWatcherThreadId() { return m_Watcher.getThreadId(); }
79 
80  private :
81 
82  DbWatcher m_Watcher;
84  int m_UncommitedTrns, m_MaxUncommitedTrns;
85  XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *m_CurrentMessage;
86  XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *m_SavedMessage;
87  ManagedBuffer *m_CurrentMessageStr;
88  bool m_NotificationTypeXML, m_Rollback;
90 
92  string m_DatabaseName; //Connector Database Name
93  string m_UserName; //Connector User
94  string m_UserPassword; //Connector Password
95  string m_TableName; //Connector Table
96 
97  //Connector table Stored Procedures
98  string m_SPmarkforprocess; //mark an unprocessed record as the currently processed recod
99  string m_SPselectforprocess; //select the current record
100  string m_SPmarkcommit; //mark current processed record commited
101  string m_SPmarkabort; //mark current processed record aborted
102  string m_SPWatcher; //look for available records
103 
104  Database *m_CurrentDatabase;
105  DatabaseProviderFactory *m_CurrentProvider;
106 };
107 
108 #endif