Package org.codehaus.activemq.message

Examples of org.codehaus.activemq.message.Receipt


     * @throws IOException
     */

    public void buildPacket(Packet packet, DataInput dataIn) throws IOException {
        super.buildPacket(packet, dataIn);
        Receipt info = (Receipt) packet;
        info.setCorrelationId(dataIn.readShort());
        info.setBrokerName(dataIn.readUTF());
        info.setClusterName(dataIn.readUTF());
        info.setFailed(dataIn.readBoolean());
        info.setException((Throwable) super.readObject(dataIn));
        info.setBrokerMessageCapacity(dataIn.readByte());
    }
View Full Code Here


        ReceiptReader reader = new ReceiptReader();
        assertTrue(reader.getPacketType() == Packet.RECEIPT_INFO);
    }

    public void testReadPacket() {
        Receipt info = (Receipt) createPacket();

        ReceiptWriter writer = new ReceiptWriter();
        ReceiptReader reader = new ReceiptReader();
        try {
            byte[] data = writer.writePacketToByteArray(info);
            Receipt receipt = (Receipt) reader.readPacketFromByteArray(data);

            assertPacket(receipt, info);
        }
        catch (Throwable e) {
            e.printStackTrace();
View Full Code Here

        }
    }

    public void testTime() {

        Receipt info = (Receipt) createPacket();

        ReceiptWriter writer = new ReceiptWriter();
        ReceiptReader reader = new ReceiptReader();

        try {
            int count = 100000;
            long startTime = System.currentTimeMillis();
            for (int i = 0; i < count; i++) {
                byte[] data = writer.writePacketToByteArray(info);
                Receipt test = (Receipt) reader.readPacketFromByteArray(data);
            }
            long finishTime = System.currentTimeMillis();
            long totalTime = finishTime - startTime;
            long ps = (count * 1000) / totalTime;
            System.out.println("Time taken :" + totalTime + " for " + count + "iterations, = " + ps + " per sec.");
View Full Code Here

            assertTrue(false);
        }
    }

    protected void assertValidPacket(Packet packet) {
        Receipt receipt = (Receipt) packet;
        assertTrue(receipt.getId() == this.id);
        assertTrue(receipt.getCorrelationId() == this.correlationId);
    }
View Full Code Here

        assertTrue(receipt.getId() == this.id);
        assertTrue(receipt.getCorrelationId() == this.correlationId);
    }

    protected Packet createPacket() {
        Receipt info = new Receipt();
        info.setId(this.id);
        info.setCorrelationId(this.correlationId);
        return info;
    }
View Full Code Here

            remoteConnection.start();
            BrokerInfo info = new BrokerInfo();
            info.setBrokerName(brokerContainer.getBroker().getBrokerName());
            info.setClusterName(brokerContainer.getBroker().getBrokerClusterName());
         
            Receipt receipt = remoteConnection.syncSendRequest(info);
            if (receipt != null){
                remoteBrokerName = receipt.getBrokerName();
                remoteClusterName = receipt.getClusterName();
            }
            connectionAdvisor = new ConnectionAdvisor(remoteConnection);
            connectionAdvisor.addListener(this);
            connectionAdvisor.start();
            connected.set(true);
View Full Code Here

    // prematurely by using a long timeout here. If the existing client
    // is working heavily and/or over a slow link, it might take some time
    // for it to respond. In such a case, the new client is misconfigured
    // and can wait for a while before being kicked out.

    Receipt r = getChannel().send(packet, timeout);
    if (r == null) throw new JMSException("Client did not respond in time");

  }
View Full Code Here

        sendReceipt(packet, null, false);
    }

    private void sendReceipt(Packet packet, Throwable requestEx, boolean failed) {
        if (packet != null && packet.isReceiptRequired()) {
            Receipt receipt = new Receipt();
            receipt.setCorrelationId(packet.getId());
            receipt.setBrokerName(brokerConnector.getBrokerInfo().getBrokerName());
            receipt.setClusterName(brokerConnector.getBrokerInfo().getClusterName());
            receipt.setException(requestEx);
            receipt.setFailed(failed);
            send(receipt);
        }
    }
View Full Code Here

     * @return the Receipt
     * @throws JMSException
     */
    public Receipt send(Packet packet, int timeout) throws JMSException {
        ReceiptHolder rh = asyncSendWithReceipt(packet);
        Receipt result = rh.getReceipt(timeout);
        return result;
    }
View Full Code Here

        boolean result = false;
        if (packet != null) {
            if (packet.isReceipt()) {
              lastReceiptTimstamp = System.currentTimeMillis();
                result = true;
                Receipt receipt = (Receipt) packet;
                ReceiptHolder rh = (ReceiptHolder) requestMap.remove(new Short(receipt.getCorrelationId()));
                if (rh != null) {
                    rh.setReceipt(receipt);
                }
                else {
                    log.warn("No Packet found to match Receipt correlationId: " + receipt.getCorrelationId());
                }
            }
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of org.codehaus.activemq.message.Receipt

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.