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 */ 017package org.apache.activemq.command; 018 019import org.apache.activemq.state.CommandVisitor; 020 021/** 022 * Used to pull messages on demand. 023 * 024 * @openwire:marshaller code="20" 025 * 026 * 027 */ 028public class MessagePull extends BaseCommand { 029 030 public static final byte DATA_STRUCTURE_TYPE = CommandTypes.MESSAGE_PULL; 031 032 protected ConsumerId consumerId; 033 protected ActiveMQDestination destination; 034 protected long timeout; 035 private MessageId messageId; 036 private String correlationId; 037 038 private transient boolean tracked = false; 039 040 @Override 041 public byte getDataStructureType() { 042 return DATA_STRUCTURE_TYPE; 043 } 044 045 @Override 046 public Response visit(CommandVisitor visitor) throws Exception { 047 return visitor.processMessagePull(this); 048 } 049 050 /** 051 * Configures a message pull from the consumer information 052 */ 053 public void configure(ConsumerInfo info) { 054 setConsumerId(info.getConsumerId()); 055 setDestination(info.getDestination()); 056 } 057 058 /** 059 * @openwire:property version=1 cache=true 060 */ 061 public ConsumerId getConsumerId() { 062 return consumerId; 063 } 064 065 public void setConsumerId(ConsumerId consumerId) { 066 this.consumerId = consumerId; 067 } 068 069 /** 070 * @openwire:property version=1 cache=true 071 */ 072 public ActiveMQDestination getDestination() { 073 return destination; 074 } 075 076 public void setDestination(ActiveMQDestination destination) { 077 this.destination = destination; 078 } 079 080 /** 081 * @openwire:property version=1 082 */ 083 public long getTimeout() { 084 return timeout; 085 } 086 087 public void setTimeout(long timeout) { 088 this.timeout = timeout; 089 } 090 091 /** 092 * An optional correlation ID which could be used by a broker to decide which messages are pulled 093 * on demand from a queue for a consumer 094 * 095 * @openwire:property version=3 096 */ 097 public String getCorrelationId() { 098 return correlationId; 099 } 100 101 public void setCorrelationId(String correlationId) { 102 this.correlationId = correlationId; 103 } 104 105 106 /** 107 * An optional message ID which could be used by a broker to decide which messages are pulled 108 * on demand from a queue for a consumer 109 * 110 * @openwire:property version=3 111 */ 112 public MessageId getMessageId() { 113 return messageId; 114 } 115 116 public void setMessageId(MessageId messageId) { 117 this.messageId = messageId; 118 } 119 120 public void setTracked(boolean tracked) { 121 this.tracked = tracked; 122 } 123 124 public boolean isTracked() { 125 return this.tracked; 126 } 127}