001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.activemq.command;
018
019 import org.apache.activemq.state.CommandVisitor;
020
021 /**
022 * A general purpose replay command for some kind of producer where ranges of
023 * messages are asked to be replayed. This command is typically used over a
024 * non-reliable transport such as UDP or multicast but could also be used on
025 * TCP/IP if a socket has been re-established.
026 *
027 * @openwire:marshaller code="65"
028 *
029 */
030 public class ReplayCommand extends BaseCommand {
031
032 public static final byte DATA_STRUCTURE_TYPE = CommandTypes.REPLAY;
033
034 private String producerId;
035 private int firstAckNumber;
036 private int lastAckNumber;
037 private int firstNakNumber;
038 private int lastNakNumber;
039
040 public ReplayCommand() {
041 }
042
043 public byte getDataStructureType() {
044 return DATA_STRUCTURE_TYPE;
045 }
046
047 public String getProducerId() {
048 return producerId;
049 }
050
051 /**
052 * Is used to uniquely identify the producer of the sequence
053 *
054 * @openwire:property version=1 cache=false
055 */
056 public void setProducerId(String producerId) {
057 this.producerId = producerId;
058 }
059
060 public int getFirstAckNumber() {
061 return firstAckNumber;
062 }
063
064 /**
065 * Is used to specify the first sequence number being acknowledged as delivered on the transport
066 * so that it can be removed from cache
067 *
068 * @openwire:property version=1
069 */
070 public void setFirstAckNumber(int firstSequenceNumber) {
071 this.firstAckNumber = firstSequenceNumber;
072 }
073
074 public int getLastAckNumber() {
075 return lastAckNumber;
076 }
077
078 /**
079 * Is used to specify the last sequence number being acknowledged as delivered on the transport
080 * so that it can be removed from cache
081 *
082 * @openwire:property version=1
083 */
084 public void setLastAckNumber(int lastSequenceNumber) {
085 this.lastAckNumber = lastSequenceNumber;
086 }
087
088 public Response visit(CommandVisitor visitor) throws Exception {
089 return null;
090 }
091
092 /**
093 * Is used to specify the first sequence number to be replayed
094 *
095 * @openwire:property version=1
096 */
097 public int getFirstNakNumber() {
098 return firstNakNumber;
099 }
100
101 public void setFirstNakNumber(int firstNakNumber) {
102 this.firstNakNumber = firstNakNumber;
103 }
104
105 /**
106 * Is used to specify the last sequence number to be replayed
107 *
108 * @openwire:property version=1
109 */
110 public int getLastNakNumber() {
111 return lastNakNumber;
112 }
113
114 public void setLastNakNumber(int lastNakNumber) {
115 this.lastNakNumber = lastNakNumber;
116 }
117
118 public String toString() {
119 return "ReplayCommand {commandId = " + getCommandId() + ", firstNakNumber = " + getFirstNakNumber() + ", lastNakNumber = " + getLastNakNumber() + "}";
120 }
121
122 }