Example usage for javax.jms BytesMessage getJMSReplyTo

List of usage examples for javax.jms BytesMessage getJMSReplyTo

Introduction

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

Prototype


Destination getJMSReplyTo() throws JMSException;

Source Link

Document

Gets the Destination object to which a reply to this message should be sent.

Usage

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

private void addNewBlockListener() throws JMSException {
    addMessageListener("newBlock", new MessageListener() {
        @Override//www.j  ava2 s .  c  o  m
        public void onMessage(Message arg0) {
            BytesMessage o = (BytesMessage) arg0;
            try {
                byte[] body = new byte[(int) o.getBodyLength()];
                o.readBytes(body);
                Block block = Block.fromProtobuf(BCSAPIMessage.Block.parseFrom(body));
                block.computeHash();
                sendBlock(block);
                reply(o.getJMSReplyTo(), null);
            } catch (Exception e) {
                BCSAPIMessage.ExceptionMessage.Builder builder = BCSAPIMessage.ExceptionMessage.newBuilder();
                builder.setBcsapiversion(1);
                builder.addMessage(e.getMessage());
                try {
                    reply(o.getJMSReplyTo(), builder.build().toByteArray());
                } catch (JMSException e1) {
                    log.error("Can not send reply ", e1);
                }
            }
        }
    });
}

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

private void addBlockrequestListener() throws JMSException {
    addMessageListener("blockRequest", new MessageListener() {
        @Override/*w w  w . j  av a 2s  .  c om*/
        public void onMessage(Message arg0) {
            BytesMessage o = (BytesMessage) arg0;
            try {
                byte[] body = new byte[(int) o.getBodyLength()];
                o.readBytes(body);
                String hash = new Hash(BCSAPIMessage.Hash.parseFrom(body).getHash(0).toByteArray()).toString();
                Block b = getBlock(hash);
                if (b != null) {
                    reply(o.getJMSReplyTo(), b.toProtobuf().toByteArray());
                } else {
                    reply(o.getJMSReplyTo(), null);
                }
            } catch (Exception e) {
                log.trace("Rejected invalid block request ", e);
            }
        }
    });
}

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

private void addColorRequestListener() throws JMSException {
    addMessageListener("colorRequest", new MessageListener() {
        @Override/*from  w  ww .  j  a  v  a2  s.  c om*/
        public void onMessage(Message message) {
            BytesMessage o = (BytesMessage) message;
            try {
                byte[] body = new byte[(int) o.getBodyLength()];
                o.readBytes(body);
                String hash = new Hash(BCSAPIMessage.Hash.parseFrom(body).getHash(0).toByteArray()).toString();
                Color c = getColor(hash);
                if (c != null) {
                    reply(o.getJMSReplyTo(), c.toProtobuf().toByteArray());
                } else {
                    reply(o.getJMSReplyTo(), null);
                }
            } catch (Exception e) {
                log.trace("Rejected invalid color request ", e);
            }
        }
    });
}

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

private void addTransactionRequestListener() throws JMSException {
    addMessageListener("transactionRequest", new MessageListener() {
        @Override/*from w ww.  j  a va2  s .c  om*/
        public void onMessage(Message arg0) {
            BytesMessage o = (BytesMessage) arg0;
            try {
                byte[] body = new byte[(int) o.getBodyLength()];
                o.readBytes(body);
                String hash = new Hash(BCSAPIMessage.Hash.parseFrom(body).getHash(0).toByteArray()).toString();
                Transaction t = getTransaction(hash);
                if (t != null) {
                    reply(o.getJMSReplyTo(), t.toProtobuf().toByteArray());
                } else {
                    reply(o.getJMSReplyTo(), null);
                }
            } catch (Exception e) {
                log.trace("Rejected invalid transaction request ", e);
            }
        }
    });
}

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

private void addNewTransactionListener() throws JMSException {
    addMessageListener("newTransaction", new MessageListener() {
        @Override/*from w  w  w  .j  a  v a 2s . c  o m*/
        public void onMessage(Message arg0) {
            BytesMessage o = (BytesMessage) arg0;
            try {
                byte[] body = new byte[(int) o.getBodyLength()];
                o.readBytes(body);
                Transaction transaction = Transaction.fromProtobuf(BCSAPIMessage.Transaction.parseFrom(body));
                transaction.computeHash();
                sendTransaction(transaction);
                reply(o.getJMSReplyTo(), null);
            } catch (Exception e) {
                BCSAPIMessage.ExceptionMessage.Builder builder = BCSAPIMessage.ExceptionMessage.newBuilder();
                builder.setBcsapiversion(1);
                builder.addMessage(e.getMessage());
                try {
                    reply(o.getJMSReplyTo(), builder.build().toByteArray());
                } catch (JMSException e1) {
                    log.error("Can not send reply ", e1);
                }
            }
        }
    });
}

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

private void addNewColorListener() throws JMSException {
    addMessageListener("newColor", new MessageListener() {
        @Override//from   ww w  .  ja  v  a 2s. c o  m
        public void onMessage(Message arg0) {
            BytesMessage o = (BytesMessage) arg0;
            try {
                byte[] body = new byte[(int) o.getBodyLength()];
                o.readBytes(body);
                Color color = Color.fromProtobuf(BCSAPIMessage.Color.parseFrom(body));
                StoredColor sc = new StoredColor();
                sc.setFungibleName(color.getFungibleName());
                sc.setExpiryHeight(color.getExpiryHeight());
                sc.setPubkey(color.getPubkey());
                sc.setSignature(color.getSignature());
                sc.setTerms(color.getTerms());
                sc.setUnit(color.getUnit());
                sc.setTxHash(color.getTransaction());
                store.issueColor(sc);
                reply(o.getJMSReplyTo(), null);
            } catch (Exception e) {
                BCSAPIMessage.ExceptionMessage.Builder builder = BCSAPIMessage.ExceptionMessage.newBuilder();
                builder.setBcsapiversion(1);
                builder.addMessage(e.getMessage());
                try {
                    reply(o.getJMSReplyTo(), builder.build().toByteArray());
                } catch (JMSException e1) {
                    log.error("Can not send reply ", e1);
                }
            }
        }
    });
}