-
|
Hello, I have a non-functioning setup and I am not really understanding what's wrong. I have watched this video about aggregating streams from multiple site into one stream: https://github.com/nats-io/jetstream-leaf-nodes-demo#connect-streams-cross-accounts respectively https://www.youtube.com/watch?v=0MkS_S7lyHk which both describe how to aggregate streams. Now our scenario is this: We have multiple (remote) sites producing data and want to aggregate those into a central nats instance. But we want to use KV for this. For the sake of simplicity I am using two sites (clusters) only for now, which have the same accounts/users. There a leafnode connection between the two. I have done the following: On site1: On the central site: (kv2_mirror similar) Whenever I put a key into kv1 or kv2 on site1 I can see that key in kv1_mirror resp. kv2_mirror on the central site. Fine! Now I create an aggregate bucket on the central site: But kv_aggregate is always empty. I would have expected to see all the keys of either kv1_mirror or kv2_mirror, but nothing. I am pretty sure I have some misunderstanding somewhere. Can someone please explain to me why kv_aggregate does not see any messages? How should this setup look to work as intended (all keys in one bucket on the central site)? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
You need to do a little bit of subject transformation as you source into your aggregated stream, as the name of the bucket is part of the subject of the messages when stored in the stream underlying a KV bucket. Example of the StreamConfig for a bucket C that sources from KV buckets A and B: (see #1200 for reference) Line 246 in e870594 |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for your answer. However, you state "nats does this automatically for you". So checking the underlying stream of the aggregate KV bucket I indeed see: But still: no messages in kv_aggregate So I have changed the settings like this and it now works! Thanks again! ( I think it should also be possible to do the transformation directly on the mirrors but this had not worked at first attempt, so I dropped the idea for now) |
Beta Was this translation helpful? Give feedback.
-
|
One more question: when I now delete a KV in the aggregate it vanishes there but not in the two mirrors where the aggregate is sourcing from. Can this be achieved somehow? |
Beta Was this translation helpful? Give feedback.
You need to do a little bit of subject transformation as you source into your aggregated stream, as the name of the bucket is part of the subject of the messages when stored in the stream underlying a KV bucket.
Example of the StreamConfig for a bucket C that sources from KV buckets A and B: