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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5ead704427116a07ddd339c19d35f065df636d7749edaef7c4393cf85f9d005
4
- data.tar.gz: a155c0ee0612fe9e2460a624b5f9d5d31570b59b96b0b557022cc8da19823962
3
+ metadata.gz: 1410ad4983069407f3c538b9db4522f3147ed03e255b12a7f0218d067b689cf9
4
+ data.tar.gz: 781ee72ae14bd7f716d2fe0c890778ac987af0384d8267900d1409ea914887fe
5
5
  SHA512:
6
- metadata.gz: a904b0f5fb732efb2995744a0986533f5f7b9fc53ef45b4334cb29f6a076e3cc9487c74978f4bfd78d9c16579223f6158f20e94df4e9652d78557f31b24350a4
7
- data.tar.gz: d059934259d0d08e93a2833879451787625ef895994bbe674da4a5058c0361443bb4531abb2d788dbd00585c98c19e0ac03a2b7d5e109ebdcd1cc288cf5f5f57
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
- process_reply(msg, subject, reply_message)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nats_messaging
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bea Graboloza