messaging 4.0.10.pre → 4.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/messaging/adapters/postgres/consumer.rb +25 -4
- data/lib/messaging/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df024471a9ebf943e39cf252ccdbfff8c1b0ed44099d6d4ae2a86625cc25920a
|
4
|
+
data.tar.gz: 3e105b704a432035b7482b39ce5f01b27a591cff6c0960eb01347e1d4ed62828
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c279fb04ec1eeae67735d59434f3b5579ed2ee900bb75cf9f3bea56c995f8bab521e113b4797c5d602f4f8431521590fa6f165f15ae54fa70ef4791643e4d696
|
7
|
+
data.tar.gz: 5f58c6e116b7c2e39ed3808aa133e473112c784bdbe01aad7e2167aca4d65aac1e3dd736a1dd2184aec36b1f08524fa2155f5945ce5ab6e5075245c75c93b5b4
|
data/Gemfile.lock
CHANGED
@@ -23,7 +23,6 @@ module Messaging
|
|
23
23
|
|
24
24
|
def stop
|
25
25
|
@running = false
|
26
|
-
save
|
27
26
|
Messaging.logger.info "[#{name}] Consumer stopping"
|
28
27
|
end
|
29
28
|
|
@@ -43,6 +42,15 @@ module Messaging
|
|
43
42
|
return if last_processed_transaction_id.present?
|
44
43
|
|
45
44
|
self.last_processed_transaction_id = self.class.latest_known_transaction_id
|
45
|
+
save_position
|
46
|
+
rescue ActiveRecord::RecordNotFound => e
|
47
|
+
recreate_consumer_record
|
48
|
+
retry
|
49
|
+
end
|
50
|
+
|
51
|
+
def recreate_consumer_record
|
52
|
+
self.id = nil
|
53
|
+
@new_record = true
|
46
54
|
save
|
47
55
|
end
|
48
56
|
|
@@ -51,28 +59,41 @@ module Messaging
|
|
51
59
|
Meter.histogram('messaging.consumer.lag', unprocessed_messages_count, tags: { consumer: name })
|
52
60
|
messages = fetch_messages
|
53
61
|
messages.each do |message|
|
54
|
-
process_message(message)
|
62
|
+
break unless process_message(message)
|
55
63
|
end
|
56
|
-
|
64
|
+
save_position
|
57
65
|
pause_polling_for_5_s unless messages.any?
|
58
66
|
end
|
67
|
+
ensure
|
68
|
+
save_position
|
69
|
+
end
|
70
|
+
|
71
|
+
def save_position
|
72
|
+
save if last_processed_position_changed? || last_processed_transaction_id_changed?
|
59
73
|
end
|
60
74
|
|
61
75
|
def process_message(message)
|
62
76
|
Middleware.run(Config.consumer.middlewares, message) { handle message }
|
63
77
|
self.last_processed_position = message.global_position
|
64
78
|
self.last_processed_transaction_id = message.transaction_id
|
79
|
+
true
|
65
80
|
rescue StandardError => e
|
66
81
|
ExceptionHandler.call(e,
|
67
82
|
{
|
68
83
|
consumer: name,
|
69
84
|
transaction_id: message.transaction_id,
|
85
|
+
global_position: message.global_position,
|
70
86
|
message: message.inspect
|
71
87
|
}
|
72
88
|
)
|
89
|
+
Messaging.logger.error "[#{name}] Error processing message: #{e.message}"
|
90
|
+
|
91
|
+
pause_to_avoid_creating_exception_storm
|
92
|
+
false
|
93
|
+
end
|
73
94
|
|
95
|
+
def pause_to_avoid_creating_exception_storm
|
74
96
|
sleep 10
|
75
|
-
retry if @running
|
76
97
|
end
|
77
98
|
|
78
99
|
def pause_polling_for_5_s
|
data/lib/messaging/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: messaging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bukowskis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|