Instructions

Features

  • Loki supports two ways of receiving messages: auto decoding, and non-auto decoding.
  • Ways to use it freely

Listener Interface

Listener needs to specify generics, auto decoding generics needs to have @MessageName annotation, non-auto decoding generics can use String.

Both methods need to implement the onMessage method to receive the message content.

@Component
public class TestListener implements Listener<String> {
    @Override
    public void onMessage(MessageContent<String> entity) {
    }
}

MessageContent

参数名称类型备注
topicStringtopic
tagStringtag
messageIdStringmessage id
messageGroupStringmessage group
keysCollectionmessage key
bodyGenericsmessage body
bodyMessageStringmessage body for String