Can I dynamically choose which topics to replicate?

AMPS requires you to specify the topics to replicate at configuration time, and does not currently allow you to change that specification without restarting AMPS.

However, AMPS supports regular expressions in the topic name for both transaction logging and replication. You can create a pattern for replicated topics, and then any topic that matches that pattern will be automatically logged and replicated.

For example, the configuration snippet below records and replicates JSON messages published to any topic name that begins with /orders/important or /archive/. There is no need to explicitly specify all of the topics to replicate, and if a publisher begins publishing to a new topic that matches the pattern, those messages will be logged and replicated.

<TransactionLog>
  <JournalDirectory>./amps/journal/</JournalDirectory>
  <JournalArchiveDirectory>/mnt/somedev0/amps/journal</JournalArchiveDirectory>
  <PreallocatedJournalFiles>1</PreallocatedJournalFiles>
  <MinJournalSize>10MB</MinJournalSize>
  <Topic>
    <Name>^/orders/important/.*|^/archive/.*</Name>
    <MessageType>json</MessageType>
  </Topic>
 </TransactionLog>

<Replication>
  <Destination>
    <Topic>
      <Name>^/orders/important.*|^/archive/.*</Name>
      <MessageType>json</MessageType>
    </Topic>
    <Name>amps-2</Name>
    <SyncType>sync</SyncType>
    <Transport>
      <InetAddr>amps-2-server.example.com:10005</InetAddr>
       <Type>amps-replication</Type>
    </Transport>
  </Destination>
 </Replication>

Last updated