Hi

I have written a plugin (public final class MessageAuditorPlugin extends
BrokerPluginSupport). I audit the incoming message before sending to a queue
(override the send() method) and I have also overridden the acknowledge()
method - see code snippet below. The client is set to Auto Acknowledgement
mode. So as soon as the client consume the response and acknowledgement is
automatically sent to the broker and get's picked in the override method
below acknowledge(ConsumerBrokerExchange consumerExchange, final MessageAck
ack). 
I am looking for a way of correlating the original request to the
acknowledgement. 
Bear in mind the MessageAck doesn't contain a direct correlation Id to the
original request. It does have MessageId which is slightly different to that
the original Request - see below pattern. I could use the below pattern to
correlate request and acknowledgement but not sure if this is the best way?

Any direction is really appreciated.

Thanks

Ayache

*Message Id pattern*

*First Request:*

Request MessageId: ID:akhettar-58632-1455191246966-5:11:-1:1:1
Acknowledgement MessageId: ID:akhettar-58632-1455191246966-5:11:-1:1

*Second Request:*
Request MessageId: ID:akhettar-58632-1455191246966-5:11:-1:1:2
Acknowledgement MessageId: ID:akhettar-58632-1455191246966-5:11:-1:2

*Code Snippet*

/**
 * Message AuditWriter Interceptor. It audits message into Cassandra
datastore.
 */
public final class MessageAuditorPluginNew extends BrokerPluginSupport {

    @Override
    public void send(final ProducerBrokerExchange producerExchange, final
Message message) throws Exception {
        // audit the message
        super.send(producerExchange, message);
    }


    @Override
    public void acknowledge(final ConsumerBrokerExchange consumerExchange,
final MessageAck ack) throws Exception {
        // handle acknowledgment
        
        getNext().acknowledge(consumerExchange, ack);
    }

}



--
View this message in context: 
http://activemq.2283324.n4.nabble.com/Message-Ack-and-Original-Request-correlation-tp4707527.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to