All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.feingto.cloud.dto.tcc.TccRequest Maven / Gradle / Ivy

There is a newer version: 2.3.5.RELEASE
Show newest version
package com.feingto.cloud.dto.tcc;

import com.feingto.cloud.kit.json.JSON;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 事务模型
 *
 * @author longfei
 */
@Data
@Accessors(chain = true)
public class TccRequest implements Serializable {
    private static final long serialVersionUID = 3721580645655868196L;
    private static final String TOPIC_TCC_PREFIX = "/cloud/tx/tcc";
    public static final String TOPIC_TCC = TOPIC_TCC_PREFIX + "/#";

    /**
     * 主线事务ID
     */
    private long id;

    /**
     * 参与者
     */
    private List participants = new ArrayList<>();

    public Message toMessage() {
        return MessageBuilder.withPayload(JSON.obj2json(this)).build();
    }

    /**
     * 获取对应状态的事务消息主题
     */
    public static String topic(TccStatus status) {
        return TOPIC_TCC_PREFIX + "/" + status.name().toLowerCase();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy