Dubbo related questions

1. Asynchronous call problem: If A->B->C has three application calling relationships, and A->B is set to async=true, then B->C is automatically asynchronous. Because Attachments in RpcContext is a final type, it will be passed.

2. Hession serialization: Hessian is the default serialization protocol of dubbo, and its serialization performance is much higher than that of java. When Hessian serializes an object, the default serializer class is com.caucho.hessian.io.JavaSerializer. When the subclass and superclass fields with the same name are overridden, overwriting occurs, causing problems with the final value. Reference 1 , the same field can be deleted by subclassing. You can also change the serialization method, refer to ;

public JavaDeserializer(Class cl)
  {
    _type = cl;
    _fieldMap = getFieldMap(cl);
.......

protected HashMap getFieldMap(Class cl)
  {
    HashMap fieldMap = new HashMap();
    
    for (; cl != null; cl = cl.getSuperclass()) {
      Field []fields = cl.getDeclaredFields();
      for (int i = 0; i < fields.length; i++) {
        Field field = fields[i];

        if (Modifier.isTransient(field.getModifiers())
        || Modifier.isStatic(field.getModifiers()))
          continue;
        else if (fieldMap.get(field.getName()) != null)
          continue;
......

private Object readObjectInstance(Class cl, ObjectDefinition def)
    throws IOException
  {
    String type = def.getType();
    String []fieldNames = def.getFieldNames();
......


public Object readObject(AbstractHessianInput in,
               Object obj,
               String []fieldNames)
    throws IOException
  {
    try {
      int ref = in.addRef(obj);

      for (int i = 0; i < fieldNames.length; i++) {
        String name = fieldNames[i];
                //If the name is the same, all private properties are taken out
        FieldDeserializer deser = (FieldDeserializer) _fieldMap.get(name);

        if (deser != null) // When in reads the parent class, it overwrites the attribute value of this class
      deser.deserialize(in, obj);
        else
          in.readObject();
      }

      Object resolve = resolve(obj);

      if (obj != resolve)
    in.setRef(ref, resolve);

      return resolve;
    } catch (IOException e) {
      throw e;
    } catch (Exception e) {
      throw new IOExceptionWrapper(obj.getClass().getName() + ":" + e, e);
    }
  }

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326426658&siteId=291194637