package org.apereo.cas.ticket.registry;

import org.apereo.cas.JmsQueueIdentifier;
import org.apereo.cas.ticket.Ticket;
import org.apereo.cas.ticket.registry.queue.AddTicketMessageQueueCommand;
import org.apereo.cas.ticket.registry.queue.DeleteTicketMessageQueueCommand;
import org.apereo.cas.ticket.registry.queue.DeleteTicketsMessageQueueCommand;
import org.apereo.cas.ticket.registry.queue.UpdateTicketMessageQueueCommand;
import org.apereo.cas.util.crypto.CipherExecutor;

import lombok.val;

/**
 * This is {@link JmsTicketRegistry}.
 *
 * @author Misagh Moayyed
 * @since 5.2.0
 */
public class JmsTicketRegistry extends DefaultTicketRegistry {

    private final JmsTicketRegistryPublisher ticketPublisher;

    private final JmsQueueIdentifier id;

    public JmsTicketRegistry(final JmsTicketRegistryPublisher publisher, final JmsQueueIdentifier id,
                             final CipherExecutor cipherExecutor) {
        super(cipherExecutor);
        this.ticketPublisher = publisher;
        this.id = id;
    }

    @Override
    public void addTicket(final Ticket ticket) {
        super.addTicket(ticket);
        ticketPublisher.publishMessageToQueue(new AddTicketMessageQueueCommand(id, ticket));
    }

    @Override
    public boolean deleteSingleTicket(final String ticketId) {
        val result = super.deleteSingleTicket(ticketId);
        ticketPublisher.publishMessageToQueue(new DeleteTicketMessageQueueCommand(id, ticketId));
        return result;
    }

    @Override
    public long deleteAll() {
        val result = super.deleteAll();
        ticketPublisher.publishMessageToQueue(new DeleteTicketsMessageQueueCommand(id));
        return result;
    }

    @Override
    public Ticket updateTicket(final Ticket ticket) {
        val result = super.updateTicket(ticket);
        ticketPublisher.publishMessageToQueue(new UpdateTicketMessageQueueCommand(id, ticket));
        return result;
    }
}

@@ -470,16 +470,50 @@
 cutor;%0A%0A
+import lombok.extern.slf4j.Slf4j;%0A
 import l
@@ -523,16 +523,16 @@
 ok.val;%0A
-
 %0A/**%0A * 
@@ -615,16 +615,23 @@
 2.0%0A */%0A
+@Slf4j%0A
 public c
@@ -1151,32 +1151,128 @@
 Ticket(ticket);%0A
+        LOGGER.trace(%22Publishing add command for id %5B%7B%7D%5D and ticket %5B%7B%7D%5D%22, id, ticket.getId());%0A
         ticketPu
@@ -1489,16 +1489,109 @@
 ketId);%0A
+        LOGGER.trace(%22Publishing delete command for id %5B%7B%7D%5D and ticket %5B%7B%7D%5D%22, id, ticketId);%0A
         
@@ -1973,32 +1973,32 @@
 icket ticket) %7B%0A
-
         val resu
@@ -2022,32 +2022,131 @@
 Ticket(ticket);%0A
+        LOGGER.trace(%22Publishing update command for id %5B%7B%7D%5D and ticket %5B%7B%7D%5D%22, id, ticket.getId());%0A
         ticketPu

fix failures