fintp_base
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MqFilter.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 MQFILTER_H
22 #define MQFILTER_H
23 
24 #include <string>
25 
26 #include "../DllMain.h"
27 #include "../AbstractFilter.h"
28 #include "Collections.h"
29 #include <xercesc/util/PlatformUtils.hpp>
30 #include <xercesc/framework/StdOutFormatTarget.hpp>
31 #include "TransportHelper.h"
32 #include "../BatchManager/BatchManager.h"
33 #include "../BatchManager/Storages/BatchMQStorage.h"
34 
35 using namespace std;
36 
37 namespace FinTP
38 {
40  {
41  public:
42 
43  //config section parameters
44  static const string MQQUEUE;
45  static const string MQBACKUPQUEUE;
46  static const string MQMANAGER;
47  static const string MQURI;
48  static const string MQHELPERTYPE;
49  static const string MQBATCH;
50 
51  static const string MQMSGSIZE;
52  static const string MQMSGID;
53  static const string MQGROUPID; // GroupId = BatchId
54  static const string MQLASTMSG; // Last message in Group 0 = No, 1 = Yes
55  static const string MQMSGCORELID;
56  static const string MQREPLYQUEUE;
57  static const string MQREPLYQUEUEMANAGER;
58  static const string MQREPLYOPTIONS;
59  static const string MQRPLTransportURI;
60  static const string MQRPLMESSAGETYPE;
61  static const string MQRPLUSRDATA;
62  static const string MQRPLMESSAGEFORMAT;
63  static const string MQMESSAGETYPE;
64  static const string MQFEEDBACK;
65  static const string MQFORMAT;
66  static const string MQAPPNAME;
67  static const string MQSEQUENCE;
68 
69  static const string MQSSLKEYREPOSITORY;
70  static const string MQSSLCYPHERSPEC;
71  static const string MQSSLPEERNAME;
72  static const string MQHELPERRETRIES;
73 
74  MqFilter();
75  ~MqFilter();
76 
77  // return true if the filter supports logging payload to a file
78  // note for overrides : return true/false if the payload can be read without rewinding ( not a stream )
79  bool canLogPayload();
80  // return true if the filter can execute the requested operation in client/server context
81  bool isMethodSupported( FilterMethod method, bool asClient );
82 
83  FilterResult ProcessMessage( XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* inputOutputData, NameValueCollection& transportHeaders, bool asClient );
84  FilterResult ProcessMessage( const XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* inputData, AbstractFilter::buffer_type outputData, NameValueCollection& transportHeaders, bool asClient );
85  FilterResult ProcessMessage( AbstractFilter::buffer_type inputData, XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* outputData, NameValueCollection& transportHeaders, bool asClient );
86  FilterResult ProcessMessage( AbstractFilter::buffer_type inputData, AbstractFilter::buffer_type outputData, NameValueCollection& transportHeaders, bool asClient );
87 
88  FilterResult ProcessMessage( const XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* inputData, unsigned char** outputData, NameValueCollection& transportHeaders, bool asClient )
89  {
90  throw FilterInvalidMethod( AbstractFilter::XmlToBuffer );
91  }
92 
93  FilterResult ProcessMessage( AbstractFilter::buffer_type inputData, unsigned char** outputData, NameValueCollection& transportHeaders, bool asClient )
94  {
95  throw FilterInvalidMethod( AbstractFilter::BufferToBuffer );
96  }
97 
98  void Init();
99 
105  void Reply( const string& buffer, const NameValueCollection& transportHeaders, long feedback );
106 
107  void Rollback(); // rolls back the current get/put
108  void Commit(); // commits get/put
109  void Abort(); // moves the message to system.dead.letter.queue
110  void Cleanup(); // Current batch action that get messages from current position till the last message
111 
112  // returns true if the filter is running in batch mode
113  bool isBatch() const;
114 
115  // returns the MQ queue manager name
116  string getQueueManagerName() const;
117 
118  // returns the MQ channel definition
119  string getTransportURI() const;
120 
121  // returns the MQ queue name used to put/get messages from
122  string getQueueName() const;
123 
124  TransportHelper::TRANSPORT_HELPER_TYPE getHelperType() const;
125 
126  bool isTransportType() { return true; }
127 
128  private :
129 
131  string m_QueueName;
133  string m_MessageId;
134  string m_GroupId;
136 
137  string m_CrtBatchId;
138 
140 
141  // validates required properties
142  void ValidateProperties();
143 
144  TransportHelper* m_CrtHelper;
145  TransportHelper::TRANSPORT_HELPER_TYPE m_HelperType;
146 
147  string getQueueManagerName( NameValueCollection& transportHeaders ) const;
148  string getTransportURI( const NameValueCollection& transportHeaders ) const;
149  string getReplyTransportURI( const NameValueCollection& transportHeaders ) const;
150  string getQueueName( NameValueCollection& transportHeaders ) const;
151  string getBackupQueueName( NameValueCollection& transportHeaders ) const;
152  string getMessageId( NameValueCollection& transportHeaders ) const;
153  string getGroupId( NameValueCollection& transportHeaders ) const;
154  string getCorrelationId( NameValueCollection& transportHeaders ) const;
155 
156  string getSSLKeyRepository( const NameValueCollection& transportHeaders ) const;
157  string getSSLCypherSpec( const NameValueCollection& transportHeaders ) const;
158  string getSSLPeerName( const NameValueCollection& transportHeaders ) const;
159 
160  void setTransportHeaders( NameValueCollection& transportHeaders, bool asClient );
161  string getFormat();
162 
163  bool isBatch( NameValueCollection& transportHeaders ) const;
164  };
165 }
166 
167 #endif // MQFILTER_H