nats_messaging 1.0.3 → 1.0.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 +14 -21
- 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: 024bad04425d91a4a9674cf078c2bfeebc7f5edbe44bb10811e45b0c4d3e4909
|
4
|
+
data.tar.gz: b251dc00455ba4c726ffba695b0708a7b2a5744e3786f0c288f5982f8d3c8c97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a0bf3614866c633447cdf13431049229e49bf22a1482c234c1b407967bc1762ea2caaa26c2764b46cbb83fbb0875ef01dd0a17198aed8be4c90843c0782006b
|
7
|
+
data.tar.gz: 8fd31978fdb026ca9ce61f29d5829436535ad2cd5ee38b34753c91cffddebb18107c0c45d5ef019f2362aa1a43f065a21d56e949efa40ad955469dbec87572e2
|
@@ -107,8 +107,20 @@ module NatsMessaging
|
|
107
107
|
# Create a new subscription
|
108
108
|
puts "NATS: Suscribing to #{subject}"
|
109
109
|
subscription = @nats.subscribe(subject) do |msg|
|
110
|
-
|
111
|
-
|
110
|
+
begin
|
111
|
+
unpacked_data = MessagePack.unpack(msg.data) # Deserializar mensaje recibido
|
112
|
+
puts "NATS: Received request on #{subject}: #{unpacked_data}"
|
113
|
+
packed_reply = reply_message.to_msgpack # Serializar respuesta
|
114
|
+
# Asegurar que msg.reply existe antes de responder
|
115
|
+
if msg.reply
|
116
|
+
@nats.publish(msg.reply, packed_reply)
|
117
|
+
puts "NATS: Replied to #{subject} with message: #{reply_message} new"
|
118
|
+
else
|
119
|
+
puts "NATS: No reply subject for #{subject}, cannot respond"
|
120
|
+
end
|
121
|
+
rescue => e
|
122
|
+
puts "NATS: Error while processing message: #{e.message}"
|
123
|
+
end
|
112
124
|
end
|
113
125
|
rescue => e
|
114
126
|
puts "NATS: Error while replying: #{e.message}"
|
@@ -116,26 +128,7 @@ module NatsMessaging
|
|
116
128
|
|
117
129
|
# Store the new subscription in the hash
|
118
130
|
@subscriptions[subject] = subscription
|
119
|
-
puts "NATS: Stored subscription for #{subject}: #{@subscriptions[subject].inspect}"
|
120
131
|
puts "NATS: Listening on #{subject} with reply message: #{reply_message}"
|
121
132
|
end
|
122
133
|
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
134
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nats_messaging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bea Graboloza
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-02-
|
11
|
+
date: 2025-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A service to send and receive messages on a Rails application using NATS
|
14
14
|
email: beatriz.graboloza@bpo-advisors.net
|