Package org.activemq.message

Examples of org.activemq.message.Receipt


            else if (packet.getPacketType() == Packet.CAPACITY_INFO) {
                CapacityInfo info = (CapacityInfo) packet;
                flowControlSleepTime = info.getFlowControlTimeout();
                //System.out.println("SET FLOW TIMEOUT = " + flowControlSleepTime + " FOR " + info);
            } else if (packet.getPacketType() == Packet.KEEP_ALIVE && packet.isReceiptRequired()) {
              Receipt receipt = new Receipt();
                receipt.setCorrelationId(packet.getId());
                receipt.setReceiptRequired(false);
                try {
                  asyncSendPacket(receipt);
                } catch (JMSException jmsEx) {
                  handleAsyncException(jmsEx);
                }
View Full Code Here


     * @param timeout
     * @throws JMSException
     */
    public void syncSendPacket(Packet packet, int timeout) throws JMSException {
        if (isTransportOK && !closed) {
            Receipt receipt;
            packet.setId(packetIdGenerator.getNextShortSequence());
            packet.setReceiptRequired(true);
            receipt = this.transportChannel.send(packet, timeout);
            if (receipt != null) {
                if (receipt.isFailed()) {
                    Throwable e = receipt.getException();
                    if (e != null) {
                        throw JMSExceptionHelper.newJMSException(e);
                    }
                    throw new JMSException("syncSendPacket failed with unknown exception");
                }
View Full Code Here

    }
   
    public Receipt syncSendRequest(Packet packet) throws JMSException {
        checkClosed();
        if (isTransportOK && !closed) {
            Receipt receipt;
            packet.setReceiptRequired(true);
            packet.setId(this.packetIdGenerator.getNextShortSequence());

            receipt = this.transportChannel.send(packet);
            if (receipt != null && receipt.isFailed()) {
                Throwable e = receipt.getException();
                if (e != null) {
                    throw (JMSException) new JMSException(e.getMessage()).initCause(e);
                }
                throw new JMSException("syncSendPacket failed with unknown exception");
            }
View Full Code Here

    /**
     * @return a new Packet instance
     */

    public Packet createPacket() {
        return new Receipt();
    }
View Full Code Here

     * @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

    // 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

        }
    }


    private void sendReceipt(short correlationId, Throwable requestEx, boolean failed) {
        Receipt receipt = new Receipt();
        receipt.setCorrelationId(correlationId);
        receipt.setBrokerName(brokerConnector.getBrokerInfo().getBrokerName());
        receipt.setClusterName(brokerConnector.getBrokerInfo().getClusterName());
        receipt.setException(requestEx);
        receipt.setFailed(failed);
        send(receipt);
    }
View Full Code Here

    public void testAsyncSendWithReceipt() throws Exception {
        sendReceipts = true;
        Packet packet = new KeepAlive();
        packet.setId((short) 1);
        ReceiptHolder rh = sender.asyncSendWithReceipt(packet);
        Receipt result = rh.getReceipt(5000);
        if (result == null) {
            fail("Should have gotten receipt");
        }
    }
View Full Code Here

        sendReceipts = true;

        List tmpList = (List) packets.clone();
        for (int i = 0; i < TEST_SIZE; i++) {
            Packet packet = (Packet) tmpList.get(i);
            Receipt receipt = sender.send(packet, 4000);
            assertTrue("Receipt should not be null!", receipt != null);
            System.out.println("Got receipt: " + receipt + " for packet: " + packet);
        }
    }
View Full Code Here

    public void consume(Packet packet) {
        System.out.println("Received packet: " + packet);

        if (sendReceipts) {
            // lets send a receipt
            Receipt receipt = new Receipt();
            receipt.setId(idGenerator.getNextShortSequence());
            receipt.setCorrelationId(packet.getId());
            try {
                receiver.asyncSend(receipt);
            }
            catch (JMSException e) {
                logMessage("Sending receipt: " + receipt + " for packet: " + packet, e);
View Full Code Here

TOP

Related Classes of org.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.