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 ProducerAck command is sent by a broker to a producer to let it know it has
023 * received and processed messages that it has produced. The producer will be
024 * flow controlled if it does not receive ProducerAck commands back from the
025 * broker.
026 *
027 * @openwire:marshaller code="19" version="3"
028 *
029 */
030 public class ProducerAck extends BaseCommand {
031
032 public static final byte DATA_STRUCTURE_TYPE = CommandTypes.PRODUCER_ACK;
033
034 protected ProducerId producerId;
035 protected int size;
036
037 public ProducerAck() {
038 }
039
040 public ProducerAck(ProducerId producerId, int size) {
041 this.producerId = producerId;
042 this.size = size;
043 }
044
045 public void copy(ProducerAck copy) {
046 super.copy(copy);
047 copy.producerId = producerId;
048 copy.size = size;
049 }
050
051 public byte getDataStructureType() {
052 return DATA_STRUCTURE_TYPE;
053 }
054
055 public Response visit(CommandVisitor visitor) throws Exception {
056 return visitor.processProducerAck(this);
057 }
058
059 /**
060 * The producer id that this ack message is destined for.
061 *
062 * @openwire:property version=3
063 */
064 public ProducerId getProducerId() {
065 return producerId;
066 }
067
068 public void setProducerId(ProducerId producerId) {
069 this.producerId = producerId;
070 }
071
072 /**
073 * The number of bytes that are being acked.
074 *
075 * @openwire:property version=3
076 */
077 public int getSize() {
078 return size;
079 }
080
081 public void setSize(int size) {
082 this.size = size;
083 }
084
085 }