Skip to content

@RqueueListener Generic results not support  #49

Description

@victory-wu
@Getter
@Setter
public class RqueueResponse<T> {
    private CreatorMerchant owner;
    private T data;
}

@Component
@Slf4j
public class CustomerChangeListener {
    @Autowired
    private CustomerScoreService customerScoreService;

    @RqueueListener(value = TopicConstant.CUSTOMER_INFO_CHANGE)
    public void infoChange(RqueueResponse<CustomerInfo> resp) {         <---- ERROR RESULT
        customerScoreService.updateInfoScore(resp.getData(), resp.getOwner().getMerchantId());
    }
}
@Service
public class RqueueService {
    @Autowired
    private RqueueMessageEnqueuer rqueueMessageEnqueuer;
    @Autowired
    private SaasContext saasContext;

    public <T> void enqueue(String queueName, T message) {
        rqueueMessageEnqueuer.enqueue(queueName, new RqueueResponse<T>(saasContext.getCurrentCreator(), message));
    }
}

ERROR:
java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to com.wzx.server.entity.m.CustomerInfo

analysis:

It does not support generic parsing and is converted to LinkHashMap by default

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    limitationThis is a system limitation

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions