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 * Used to pull messages on demand.
023 *
024 * @openwire:marshaller code="20"
025 *
026 *
027 */
028 public 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 public byte getDataStructureType() {
039 return DATA_STRUCTURE_TYPE;
040 }
041
042 public Response visit(CommandVisitor visitor) throws Exception {
043 return visitor.processMessagePull(this);
044 }
045
046 /**
047 * Configures a message pull from the consumer information
048 */
049 public void configure(ConsumerInfo info) {
050 setConsumerId(info.getConsumerId());
051 setDestination(info.getDestination());
052 }
053
054 /**
055 * @openwire:property version=1 cache=true
056 */
057 public ConsumerId getConsumerId() {
058 return consumerId;
059 }
060
061 public void setConsumerId(ConsumerId consumerId) {
062 this.consumerId = consumerId;
063 }
064
065 /**
066 * @openwire:property version=1 cache=true
067 */
068 public ActiveMQDestination getDestination() {
069 return destination;
070 }
071
072 public void setDestination(ActiveMQDestination destination) {
073 this.destination = destination;
074 }
075
076 /**
077 * @openwire:property version=1
078 */
079 public long getTimeout() {
080 return timeout;
081 }
082
083 public void setTimeout(long timeout) {
084 this.timeout = timeout;
085 }
086
087 /**
088 * An optional correlation ID which could be used by a broker to decide which messages are pulled
089 * on demand from a queue for a consumer
090 *
091 * @openwire:property version=3
092 */
093 public String getCorrelationId() {
094 return correlationId;
095 }
096
097 public void setCorrelationId(String correlationId) {
098 this.correlationId = correlationId;
099 }
100
101
102 /**
103 * An optional message ID which could be used by a broker to decide which messages are pulled
104 * on demand from a queue for a consumer
105 *
106 * @openwire:property version=3
107 */
108 public MessageId getMessageId() {
109 return messageId;
110 }
111
112 public void setMessageId(MessageId messageId) {
113 this.messageId = messageId;
114 }
115 }