-
- 类型参数:
T
- T
@Local @Component @ClassDepends public interface MessageConsumer<T>
MQ消费器, 实现类必须标记ResourceConsumer
@ResourceConsumer(mq = "mymq", topics = "test_bean_topic") public class TestMessageConsumer implements MessageConsumer<TestBean> { @Override public void init(AnyValue config) { System.out.println("执行 TestMessageConsumer.init"); } @Override public void onMessage(MessageEvent<TestBean>[] events) { for(MessageEvent<TestBean> event : events) { System.out.println("TestMessageConsumer消费消息, message: " + event.getMessage()); } } @Override public void destroy(AnyValue config) { System.out.println("执行 TestMessageConsumer.destroy"); } }
详情见: https://redkale.org
- 从以下版本开始:
- 2.8.0
- 作者:
- zhangjx
- 另请参阅:
MessageEvent
,ResourceConsumer
,Messaged
-
-
方法详细资料
-
init
default void init(AnyValue config)
-
onMessage
void onMessage(MessageEvent<T>[] events)
-
destroy
default void destroy(AnyValue config)
-
-