nats_messaging 1.2.3 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/nats_messaging/nats_service.rb +7 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e73a3877a8ab4eefd41d971b156e2dcca212aa5463e193c65bf85edca5af63bd
|
4
|
+
data.tar.gz: 63c277cf1ba11a19051f797d6dd2fa1d1de652e67075bfe1ed0e650f7043faa0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd56ddda31f993cfa2ba400c9a8329c439dbad2a7439403dfabd8bba0954e286efc999598906dce3e11f050df430619119602fe07b0a52f51d5768ef483aa577
|
7
|
+
data.tar.gz: 538d17257b10ce2a7ff6c10727743313c29b8eb128eeb2b70dfb48bb6684c87aa166beeb5fef8ed292979fcb699eccc907926c0b62f1f0f7e7371ecc27af81e5
|
@@ -55,11 +55,13 @@ module NatsMessaging
|
|
55
55
|
if @js
|
56
56
|
@subscriptions[subject] = @js.subscribe(subject, durable: durable_name) do |msg|
|
57
57
|
unpacked_data = process_received_message(msg, subject)
|
58
|
+
yield(subject, unpacked_data) if block_given?
|
58
59
|
unpacked_data
|
59
60
|
end
|
60
61
|
else
|
61
62
|
@subscriptions[subject] = @nats.subscribe(subject) do |msg|
|
62
63
|
unpacked_data = process_received_message(msg, subject)
|
64
|
+
yield(subject, unpacked_data) if block_given?
|
63
65
|
unpacked_data
|
64
66
|
end
|
65
67
|
end
|
@@ -84,6 +86,7 @@ module NatsMessaging
|
|
84
86
|
response = @nats.request(subject, packed_message, timeout: 5) # Timeout of 5 seconds
|
85
87
|
unpacked_response = MessagePack.unpack(response.data) # Deserializar respuesta
|
86
88
|
puts "NATS: Received reply: #{unpacked_response}"
|
89
|
+
yield(subject, unpacked_data) if block_given?
|
87
90
|
unpacked_response
|
88
91
|
rescue NATS::IO::Timeout
|
89
92
|
puts "NATS: Request timed out for subject: #{subject}"
|
@@ -103,8 +106,8 @@ module NatsMessaging
|
|
103
106
|
unpacked_data = nil
|
104
107
|
begin
|
105
108
|
# Create a new subscription
|
106
|
-
puts "NATS:
|
107
|
-
|
109
|
+
puts "NATS: Listening on #{subject} with reply message: #{reply_message}"
|
110
|
+
@subscriptions[subject] = @nats.subscribe(subject) do |msg|
|
108
111
|
begin
|
109
112
|
unpacked_data = MessagePack.unpack(msg.data) # Deserializar mensaje recibido
|
110
113
|
puts "NATS: Received request on #{subject}: #{unpacked_data}"
|
@@ -116,6 +119,8 @@ module NatsMessaging
|
|
116
119
|
else
|
117
120
|
puts "NATS: No reply subject for #{subject}, cannot respond"
|
118
121
|
end
|
122
|
+
yield(subject, unpacked_data) if block_given?
|
123
|
+
unpacked_data
|
119
124
|
rescue => e
|
120
125
|
puts "NATS: Error while processing message: #{e.message}"
|
121
126
|
end
|
@@ -123,11 +128,6 @@ module NatsMessaging
|
|
123
128
|
rescue => e
|
124
129
|
puts "NATS: Error while replying: #{e.message}"
|
125
130
|
end
|
126
|
-
|
127
|
-
# Store the new subscription in the hash
|
128
|
-
@subscriptions[subject] = subscription
|
129
|
-
puts "NATS: Listening on #{subject} with reply message: #{reply_message}"
|
130
|
-
unpacked_data
|
131
131
|
end
|
132
132
|
end
|
133
133
|
end
|