nats_messaging 1.0.2 → 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 +15 -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
|
@@ -107,7 +107,21 @@ module NatsMessaging
|
|
107
107
|
# Create a new subscription
|
108
108
|
puts "NATS: Suscribing to #{subject}"
|
109
109
|
subscription = @nats.subscribe(subject) do |msg|
|
110
|
-
|
110
|
+
puts "NATS: process reply?"
|
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
|
111
125
|
end
|
112
126
|
rescue => e
|
113
127
|
puts "NATS: Error while replying: #{e.message}"
|
@@ -119,22 +133,4 @@ module NatsMessaging
|
|
119
133
|
puts "NATS: Listening on #{subject} with reply message: #{reply_message}"
|
120
134
|
end
|
121
135
|
end
|
122
|
-
|
123
|
-
# Process and reply a message received
|
124
|
-
def process_reply(msg, subject, reply_message)
|
125
|
-
begin
|
126
|
-
unpacked_data = MessagePack.unpack(msg.data) # Deserializar mensaje recibido
|
127
|
-
puts "NATS: Received request on #{subject}: #{unpacked_data}"
|
128
|
-
packed_reply = reply_message.to_msgpack # Serializar respuesta
|
129
|
-
# Asegurar que msg.reply existe antes de responder
|
130
|
-
if msg.reply
|
131
|
-
@nats.publish(msg.reply, packed_reply)
|
132
|
-
puts "NATS: Replied to #{subject} with message: #{reply_message} new"
|
133
|
-
else
|
134
|
-
puts "NATS: No reply subject for #{subject}, cannot respond"
|
135
|
-
end
|
136
|
-
rescue => e
|
137
|
-
puts "NATS: Error while processing message: #{e.message}"
|
138
|
-
end
|
139
|
-
end
|
140
136
|
end
|