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 * The Command Pattern so that we can send and receive commands on the different
023 * transports
024 */
025public interface Command extends DataStructure {
026
027    void setCommandId(int value);
028
029    /**
030     * @return the unique ID of this request used to map responses to requests
031     */
032    int getCommandId();
033
034    void setResponseRequired(boolean responseRequired);
035
036    boolean isResponseRequired();
037
038    boolean isResponse();
039
040    boolean isMessageDispatch();
041
042    boolean isBrokerInfo();
043
044    boolean isWireFormatInfo();
045
046    boolean isMessage();
047
048    boolean isMessageAck();
049
050    boolean isMessageDispatchNotification();
051
052    boolean isShutdownInfo();
053
054    boolean isConnectionControl();
055
056    boolean isConsumerControl();
057
058    Response visit(CommandVisitor visitor) throws Exception;
059
060    /**
061     * The endpoint within the transport where this message came from which
062     * could be null if the transport only supports a single endpoint.
063     */
064    Endpoint getFrom();
065
066    void setFrom(Endpoint from);
067
068    /**
069     * The endpoint within the transport where this message is going to - null
070     * means all endpoints.
071     */
072    Endpoint getTo();
073
074    void setTo(Endpoint to);
075}