tags:

views:

351

answers:

1

I need the queue to enforce no-duplicate policy. Is it possible? If so , how? (I've been googling for hours... )

Edit:

The ActiveMQSession implementation has this lines:

        // transform to our own message format here
            ActiveMQMessage msg = ActiveMQMessageTransformation.transformMessage(message, connection);

        // Set the message id.
        if (msg == message) {
            msg.setMessageId(new MessageId(producer.getProducerInfo().getProducerId(), sequenceNumber));
        } else {
            msg.setMessageId(new MessageId(producer.getProducerInfo().getProducerId(), sequenceNumber));
            message.setJMSMessageID(msg.getMessageId().toString());
        }

The ActiveMQMessageTransformation is plugable (you can set it) , but the following if statement is a rather incontrovertible .

Any ideas , except changing their code?

A: 

ActiveMQ has duplicate message detection built in - how are you defining a duplicate ? If the duplicate has the same messageId - it should be discarded

Rob Davies
(I'm sorry for the non-specific class names , it's been a while)I wanted to define the parameter message id which is tested for duplication . However , in spite the fact that you can do message.setId , it is being override(!) in the AMQProxy and set with a new manufactured messageId.
yossale
the messageID is set by the JMS provider - and for ActiveMQ we provide a globally unique id. The correct way to do this with JMS is to set a Message Header property. For ActiveMQ - you can use use generated messageID itself - as it will always be unique.
Rob Davies