messaging 4.0.10 → 4.0.12
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 +26 -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: 8b33d86158fa568ad2d0a28cd0ba116148c9138b257b0d7debed82b435972af2
|
4
|
+
data.tar.gz: 71d5f06396fd5bc96af015dabb3877c6a90673694d0a4d139873766817262adf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65588cd136c5b5726cbcf996f1f0ce9fcd8d511fd612f5500e365bbb22741a02875743106a8b1df54eaaeae6a5011368017b946d0ae354d826d95560f5e06e3b
|
7
|
+
data.tar.gz: ce5b8a54d1faa1b107e130afbee144f2cee506a23e49087f688426a287db137d9054aefe81be1bfee1ae2d2d606bb9e26ea1290db49678e9eb4be76532f762ce
|
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,16 @@ 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
|
54
|
+
@attributes = @attributes.except('id') if ::Rails::VERSION::MAJOR == 2
|
46
55
|
save
|
47
56
|
end
|
48
57
|
|
@@ -51,17 +60,26 @@ module Messaging
|
|
51
60
|
Meter.histogram('messaging.consumer.lag', unprocessed_messages_count, tags: { consumer: name })
|
52
61
|
messages = fetch_messages
|
53
62
|
messages.each do |message|
|
54
|
-
process_message(message)
|
63
|
+
break unless process_message(message)
|
55
64
|
end
|
56
|
-
|
65
|
+
save_position
|
57
66
|
pause_polling_for_5_s unless messages.any?
|
58
67
|
end
|
68
|
+
ensure
|
69
|
+
save_position
|
70
|
+
end
|
71
|
+
|
72
|
+
def save_position
|
73
|
+
return unless last_processed_position_changed? || last_processed_transaction_id_changed?
|
74
|
+
recreate_consumer_record unless self.class.exists? id
|
75
|
+
save
|
59
76
|
end
|
60
77
|
|
61
78
|
def process_message(message)
|
62
79
|
Middleware.run(Config.consumer.middlewares, message) { handle message }
|
63
80
|
self.last_processed_position = message.global_position
|
64
81
|
self.last_processed_transaction_id = message.transaction_id
|
82
|
+
true
|
65
83
|
rescue StandardError => e
|
66
84
|
ExceptionHandler.call(e,
|
67
85
|
{
|
@@ -72,8 +90,12 @@ module Messaging
|
|
72
90
|
}
|
73
91
|
)
|
74
92
|
|
93
|
+
pause_to_avoid_creating_exception_storm
|
94
|
+
false
|
95
|
+
end
|
96
|
+
|
97
|
+
def pause_to_avoid_creating_exception_storm
|
75
98
|
sleep 10
|
76
|
-
retry if @running
|
77
99
|
end
|
78
100
|
|
79
101
|
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.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bukowskis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|