| 51 | } |
| 52 | |
| 53 | void onTrigger(const std::shared_ptr<core::ProcessContext>& context, const std::shared_ptr<core::ProcessSession>& session) override { |
| 54 | std::unique_lock<std::mutex> lock(onTriggerMutex_, std::try_to_lock); |
| 55 | if (!lock.owns_lock()) { |
| 56 | logger_->log_warn("'onTrigger' is called before previous 'onTrigger' call is finished."); |
| 57 | context->yield(); |
| 58 | return; |
| 59 | } |
| 60 | |
| 61 | try { |
| 62 | if (!connection_) { |
| 63 | connection_ = dbService_->getConnection(); |
| 64 | } |
| 65 | static_cast<T*>(this)->processOnTrigger(*session); |
| 66 | } catch (std::exception& e) { |
| 67 | logger_->log_error("SQLProcessor: '%s'", e.what()); |
| 68 | if (connection_) { |
| 69 | std::string exp; |
| 70 | if (!connection_->connected(exp)) { |
| 71 | logger_->log_error("SQLProcessor: Connection exception: %s", exp.c_str()); |
| 72 | connection_.reset(); |
| 73 | } |
| 74 | } |
| 75 | context->yield(); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | void notifyStop() override { |
| 80 | connection_.reset(); |
nothing calls this directly
no test coverage detected