模块 org.redkale
程序包 org.redkale.mq

注释类型 ResourceProducer


  • @Documented
    @Target(FIELD)
    @Retention(RUNTIME)
    public @interface ResourceProducer
    MQ资源注解, 只能标记在MessageProducer类型字段上
     public class TestMessageService extends AbstractService {
    
         @ResourceProducer(mq = "mymq")
          private MessageProducer producer;
    
          @Override
          public void init(AnyValue config) {
               sendMessage();
          }
    
          public void sendMessage() {
               TestBean bean = new TestBean(12345, "this is a message");
               System.out.println("生产消息: " + bean);
               producer.sendMessage("test_bean_topic", bean);
          }
     }
     

    详情见: https://redkale.org

    从以下版本开始:
    2.8.0
    作者:
    zhangjx
    另请参阅:
    MessageProducer
      • required

        boolean required
        是否必须要加载,为ture时若mq()值对应MessageAgent对象不存在的情况下会抛异常
        返回:
        是否必须要加载
        默认值:
        true
      • convertType

        ConvertType convertType
        消息序列化类型
        返回:
        序列化类型
        默认值:
        org.redkale.convert.ConvertType.JSON