Pular para conteúdo

Invalidação de caches e notificação

Receber POST /cacheinvalidator/invalidate ou mensagens iPaaS e invalidar chaves Redis.

%%{init: {"theme":"base","themeVariables":{"fontFamily":"Arial, sans-serif","fontSize":"16px","lineColor":"#64748b","primaryTextColor":"#172b4d"},"flowchart":{"htmlLabels":true,"useMaxWidth":true,"nodeSpacing":28,"rankSpacing":38,"padding":14,"curve":"linear","subGraphTitleMargin":{"top":12,"bottom":16}},"sequence":{"useMaxWidth":true,"actorMargin":28,"width":145,"height":45,"diagramMarginX":32,"diagramMarginY":12,"messageMargin":24,"wrap":true,"mirrorActors":false},"themeCSS":".edgeLabel, .edgeLabel p {background-color:var(--diagram-surface)!important;color:var(--diagram-text)!important}\n.cluster rect {fill:var(--diagram-group)!important;stroke:var(--diagram-line)!important}\n.cluster-label span, .cluster-label text {color:var(--diagram-text)!important;fill:var(--diagram-text)!important}\n.flowchart-link, .actor-line {stroke:var(--diagram-line)!important}\nmarker path {fill:var(--diagram-line)!important;stroke:var(--diagram-line)!important}\n.actor {fill:var(--diagram-domain)!important;stroke:var(--diagram-domain-border)!important}\ntext.actor, .messageText, .loopText, .labelText {fill:var(--diagram-text)!important}\n.messageLine0, .messageLine1, .loopLine {stroke:var(--diagram-line)!important}\n.labelBox {fill:var(--diagram-surface)!important;stroke:var(--diagram-line)!important}\n.note {fill:var(--diagram-async)!important;stroke:var(--diagram-async-border)!important}\n.noteText {fill:var(--diagram-text)!important}\n.nodeLabel, .nodeLabel p, .nodeLabel span {color:var(--diagram-text)!important}\n.node .nodeLabel, .node .nodeLabel p {font-size:17px;font-weight:600;line-height:1.4;text-align:center}\n.nodeLabel small {display:inline-block;margin-top:4px;font-size:15px;font-weight:400;line-height:1.4;color:var(--diagram-description)!important}\ntext.actor, text.actor tspan {font-size:17px;font-weight:600}\n.node.entry rect, .node.entry polygon, .node.entry path, .node.entry circle {fill:var(--diagram-entry)!important;stroke:var(--diagram-entry-border)!important}\n.node.domain rect, .node.domain polygon, .node.domain path, .node.domain circle {fill:var(--diagram-domain)!important;stroke:var(--diagram-domain-border)!important}\n.node.security rect, .node.security polygon, .node.security path, .node.security circle {fill:var(--diagram-security)!important;stroke:var(--diagram-security-border)!important}\n.node.store rect, .node.store polygon, .node.store path, .node.store circle {fill:var(--diagram-store)!important;stroke:var(--diagram-store-border)!important}\n.node.async rect, .node.async polygon, .node.async path, .node.async circle {fill:var(--diagram-async)!important;stroke:var(--diagram-async-border)!important}\n.node.external rect, .node.external polygon, .node.external path, .node.external circle {fill:var(--diagram-external)!important;stroke:var(--diagram-external-border)!important}\n text.actor tspan, .loopText tspan, .labelText tspan, .messageText tspan, .noteText tspan {fill:var(--diagram-text)!important}\n\n"}}%%
%%{init: {"sequence":{"width":135,"actorMargin":24,"messageMargin":24,"wrap":true}}}%%
sequenceDiagram
    actor C as Consumidor
    participant I as Cache Invalidator
    participant R as Redis
    participant Q as RabbitMQ
    participant D as Discovery
    C->>I: tenantId, entity e id
    I->>R: KEYS pelo padrão
    R-->>I: Chaves
    I->>R: UNLINK
    opt tenantId não nulo
    I->>Q: Publicar entity e header tenantId
    Q--)D: Notificar instância
    D->>D: Remover cache do tenant
    end
    I-->>C: Retorno

Resumo: Campos vazios viram wildcard. O consumer iPaaS usa tenant nulo: invalida entre tenants e não publica a notificação neste ramo. A recepção no Discovery define as routing keys aceitas.

Resultado: Caches alcançados pelo padrão são removidos. Nenhum evento de publicação de domínio é criado aqui.

Alternativas relevantes: Falhas Redis e publicação são logadas sem propagação pelo serviço; retorno não comprova que ambos concluíram.

Fluxos do serviço · Catálogo funcional.

Referências de implementação

cacheinvalidator / CacheInvalidatorService

cacheinvalidator / RabbitConsumer

cacheinvalidator / RabbitProducer