nats_messaging 1.0.3 → 1.0.4
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 +14 -19
- 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: 1410ad4983069407f3c538b9db4522f3147ed03e255b12a7f0218d067b689cf9
|
4
|
+
data.tar.gz: 781ee72ae14bd7f716d2fe0c890778ac987af0384d8267900d1409ea914887fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 014265c319e5c5659db9f11d65108227cf08943de804c2ef667bfda257ea1f8cbf724b33483eb6701da2ca758607441dcb2d848a8a314d8f0c344e7813b66784
|
7
|
+
data.tar.gz: c6087e2b4b407279c1f6d6176221690805b86173b852f31165fff16b79092b9da78db89681fffc1a406a6d4ab254306ccadcdee7937ac489070fb17872cd2ffb
|
@@ -108,7 +108,20 @@ module NatsMessaging
|
|
108
108
|
puts "NATS: Suscribing to #{subject}"
|
109
109
|
subscription = @nats.subscribe(subject) do |msg|
|
110
110
|
puts "NATS: process reply?"
|
111
|
-
|
111
|
+
begin
|
112
|
+
unpacked_data = MessagePack.unpack(msg.data) # Deserializar mensaje recibido
|
113
|
+
puts "NATS: Received request on #{subject}: #{unpacked_data}"
|
114
|
+
packed_reply = reply_message.to_msgpack # Serializar respuesta
|
115
|
+
# Asegurar que msg.reply existe antes de responder
|
116
|
+
if msg.reply
|
117
|
+
@nats.publish(msg.reply, packed_reply)
|
118
|
+
puts "NATS: Replied to #{subject} with message: #{reply_message} new"
|
119
|
+
else
|
120
|
+
puts "NATS: No reply subject for #{subject}, cannot respond"
|
121
|
+
end
|
122
|
+
rescue => e
|
123
|
+
puts "NATS: Error while processing message: #{e.message}"
|
124
|
+
end
|
112
125
|
end
|
113
126
|
rescue => e
|
114
127
|
puts "NATS: Error while replying: #{e.message}"
|
@@ -120,22 +133,4 @@ module NatsMessaging
|
|
120
133
|
puts "NATS: Listening on #{subject} with reply message: #{reply_message}"
|
121
134
|
end
|
122
135
|
end
|
123
|
-
|
124
|
-
# Process and reply a message received
|
125
|
-
def process_reply(msg, subject, reply_message)
|
126
|
-
begin
|
127
|
-
unpacked_data = MessagePack.unpack(msg.data) # Deserializar mensaje recibido
|
128
|
-
puts "NATS: Received request on #{subject}: #{unpacked_data}"
|
129
|
-
packed_reply = reply_message.to_msgpack # Serializar respuesta
|
130
|
-
# Asegurar que msg.reply existe antes de responder
|
131
|
-
if msg.reply
|
132
|
-
@nats.publish(msg.reply, packed_reply)
|
133
|
-
puts "NATS: Replied to #{subject} with message: #{reply_message} new"
|
134
|
-
else
|
135
|
-
puts "NATS: No reply subject for #{subject}, cannot respond"
|
136
|
-
end
|
137
|
-
rescue => e
|
138
|
-
puts "NATS: Error while processing message: #{e.message}"
|
139
|
-
end
|
140
|
-
end
|
141
136
|
end
|