Example usage for javax.jms BytesMessage getJMSCorrelationID

List of usage examples for javax.jms BytesMessage getJMSCorrelationID

Introduction

In this page you can find the example usage for javax.jms BytesMessage getJMSCorrelationID.

Prototype


String getJMSCorrelationID() throws JMSException;

Source Link

Document

Gets the correlation ID for the message.

Usage

From source file:com.bitsofproof.supernode.core.ImplementBCSAPI.java

private void addBloomFilterListener() throws JMSException {
    addMessageListener("filterRequest", new MessageListener() {
        @Override//  www .j  a va2s  .  c  om
        public void onMessage(Message msg) {
            BytesMessage o = (BytesMessage) msg;
            byte[] body;
            try {
                body = new byte[(int) o.getBodyLength()];
                o.readBytes(body);
                BCSAPIMessage.FilterRequest request = BCSAPIMessage.FilterRequest.parseFrom(body);
                byte[] data = request.getFilter().toByteArray();
                long hashFunctions = request.getHashFunctions();
                long tweak = request.getTweak();
                UpdateMode updateMode = UpdateMode.values()[request.getMode()];
                BloomFilter filter = new BloomFilter(data, hashFunctions, tweak, updateMode);
                synchronized (correlationBloomFilter) {
                    if (!correlationProducer.containsKey(o.getJMSCorrelationID())) {
                        MessageProducer producer = session.createProducer(msg.getJMSReplyTo());
                        correlationProducer.put(o.getJMSCorrelationID(), producer);
                    }
                    correlationBloomFilter.put(o.getJMSCorrelationID(), filter);
                }
            } catch (JMSException e) {
                log.error("invalid filter request", e);
            } catch (InvalidProtocolBufferException e) {
                log.error("invalid filter request", e);
            }
        }
    });
}