MQ!Rabbit-client AMQImpl

MQ!Rabbit-client AMQImpl

AMQPImpl类包括AMQP接口(public class AMQImpl implements AMQP)主要囊括了AMQP协议中的通信帧的类别。

在学习 channelN类的时候basicQos调用的类实际是AMQImpl的一个内部类的方法。

结构图

下面是Connection.Start帧,其他帧也都是类似的(我严重怀疑写这个程序的人以前是写C的😒)

public static class Connection {
    public static final int INDEX = 10;

    public static class Start
        extends Method
        implements com.rabbitmq.client.AMQP.Connection.Start
    {
        public static final int INDEX = 10;

        private final int versionMajor;
        private final int versionMinor;
        private final Map<String,Object> serverProperties;
        private final LongString mechanisms;
        private final LongString locales;

        public int getVersionMajor() { return versionMajor; }
        public int getVersionMinor() { return versionMinor; }
        public Map<String,Object> getServerProperties() { return serverProperties; }
        public LongString getMechanisms() { return mechanisms; }
        public LongString getLocales() { return locales; }

        public Start(int versionMajor, int versionMinor, Map<String,Object> serverProperties, LongString mechanisms, LongString locales) {
            if (locales == null)
                throw new IllegalStateException("Invalid configuration: 'locales' must be non-null.");
            if (mechanisms == null)
                throw new IllegalStateException("Invalid configuration: 'mechanisms' must be non-null.");
            this.versionMajor = versionMajor;
            this.versionMinor = versionMinor;
            this.serverProperties = serverProperties==null ? null : Collections.unmodifiableMap(new HashMap<String,Object>(serverProperties));
            this.mechanisms = mechanisms;
            this.locales = locales;
        }
        public Start(MethodArgumentReader rdr) throws IOException {
            this(rdr.readOctet(), rdr.readOctet(), rdr.readTable(), rdr.readLongstr(), rdr.readLongstr());
        }

        public int protocolClassId() { return 10; }
        public int protocolMethodId() { return 10; }
        public String protocolMethodName() { return "connection.start";}

        public boolean hasContent() { return false; }

        public Object visit(MethodVisitor visitor) throws IOException
        {   return visitor.visit(this); }

        public void appendArgumentDebugStringTo(StringBuilder acc) {
            acc.append("(version-major=")
                .append(this.versionMajor)
                .append(", version-minor=")
                .append(this.versionMinor)
                .append(", server-properties=")
                .append(this.serverProperties)
                .append(", mechanisms=")
                .append(this.mechanisms)
                .append(", locales=")
                .append(this.locales)
                .append(")");
        }

        public void writeArgumentsTo(MethodArgumentWriter writer)
            throws IOException
        {
            writer.writeOctet(this.versionMajor);
            writer.writeOctet(this.versionMinor);
            writer.writeTable(this.serverProperties);
            writer.writeLongstr(this.mechanisms);
            writer.writeLongstr(this.locales);
        }
    }
 ...   
}

看起来代码好长好长😱,但是不用怕(反正怕也得看🙃)。首先要注意一点内部类Start是继承Method类(注意!!这里的Method类不是反射里面的那个,而是rabbitMq里面的类)。

一些属性

public static final int INDEX = 10;
private final int versionMajor;
private final int versionMinor;
private final Map<String,Object> serverProperties;
private final LongString mechanisms;
private final LongString locales;

一些get方法

public int getVersionMajor() { return versionMajor; }
public int getVersionMinor() { return versionMinor; }
public Map<String,Object> getServerProperties() { return serverProperties; }
public LongString getMechanisms() { return mechanisms; }
public LongString getLocales() { return locales; }

重要的参数:classId,MethodId,hasContent

public int protocolClassId() { return 10; }
public int protocolMethodId() { return 10; }
public boolean hasContent() { return false; }

剩下的都是对应方法中的主要信息。

下表涵盖AQMP协议各个种类的Method以及其一些属性,看完这张表就看完了AMQPImpl的全部。

Method-NameclassIdmethodIdhasContent
Connection.Start1010false
Connection.StartOk1011false
Connection.Secure1020false
Connection.SecureOk1021false
Connection.Tune1030false
Connection.TuneOk1031false
Connection.Open1040false
Connection.OpenOk1041false
Connection.Close1050false
Connection.CloseOk1051false
Connection.Blocked1060false
Connection.Unblocked1061false
Channel.Open2010false
Channel.OpenOk2011false
Channel.Flow2020false
Channel.FlowOk2021false
Channel.Close2040false
Channel.CloseOk2041false
Access.Request3010false
Access.RequestOk3011false
Exchange.Declare4010false
Exchange.DeclareOk4011false
Exchange.Delete4020false
Exchange.DeleteOk4021false
Exchange.Bind4030false
Exchange.BindOk4031false
Exchange.Unbind4040false
Exchange.UnbindOk4051false
Queue.Declare5010false
Queue.DeclareOk5011false
Queue.Bind5020false
Queue.BindOk5021false
Queue.Purge5030false
Queue.PurgeOk5031false
Queue.Delete5040false
Queue.DeleteOk5041false
Queue.Unbind5050false
Queue.UnbindOk5051false
Basic.Qos6010false
Basic.QosOk6011false
Basic.Consume6020false
Basic.ConsumeOk6021false
Basic.Cancel6030false
Basic.CancelOk6031false
Basic.Publish6040true
Basic.Return6050true
Basic.Deliver6060true
Basic.Get6070false
Basic.GetOk6071true
Basic.GetEmpty6072false
Basic.Ack6080false
Basic.Reject6090false
Basic.RecoverAsync60100false
Basic.Recover60110false
Basic.RecoverOk60111false
Basic.Nack60120false
Tx.Select9010false
Tx.SelectOk9011false
Tx.Commit9020false
Tx.CommitOk9021false
Tx.Rollback9030false
Tx.RollbackOk9031false
Confirm.Select8510false
Confirm.SelectOk8511false

好的,完美的水了一篇 over😂

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值