Package org.codehaus.activemq.message

Examples of org.codehaus.activemq.message.Receipt


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

  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

     * @throws IOException thrown if an error occurs
     */

    public void writePacket(Packet packet, DataOutput dataOut) throws IOException {
        super.writePacket(packet, dataOut);
        Receipt info = (Receipt) packet;
        dataOut.writeShort(info.getCorrelationId());
        super.writeUTF(info.getBrokerName(), dataOut);
        super.writeUTF(info.getClusterName(), dataOut);
        dataOut.writeBoolean(info.isFailed());
        super.writeObject(info.getException(), dataOut);
        dataOut.writeByte(info.getBrokerMessageCapacity());
    }
View Full Code Here

            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.get()) {
            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.get()) {
            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

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.