消息
包含消息体和消息头。消息体可以是任意的类型;消息头是键值对,包含ID,时间戳,关联ID和返回地址。
消息通道
从语义学上理解,消息通道有两种,一种是点对点,另外一种是发布订阅。【点对点】模式下,只有一个消费者能接受发送到通道的所有消息。而【发布订阅】模式下,可以把消息广播给多个订阅了这个通道的订阅者上。
消息端点
处理消息的接收器,一般分为下面几种:
- 转换器
- 过滤器
- 路由器
- 分割器
- 聚合器
- 激活器
- 适配器
- 端点对象的名称
每个消费端点包含两个对象,消费对象和消息处理对象。消费对象持有一个消息处理对象的应用,当消息到来时,消费对象调用消息处理对象来处理消息。
那么这两个对象的名称是咋样的呢?看下面的例子:
@Component
public class SomeComponent {
@ServiceActivator(inputChannel = ...)
public String someMethod(...) {
...
}
}
消费对象名称: someComponent.someMethod.serviceActivator
处理对象名称: someComponent.someMethod.serviceActivator.handler
@Component
public class SomeComponent {
@EndpointId("someService")
@ServiceActivator(inputChannel = ...)
public String someMethod(...) {
...
}
}
消费对象名称: someService
处理对象名称: someService.handler
@Configuratiom
public class SomeConfiguration {
@Bean
@ServiceActivator(inputChannel = ...)
public MessageHandler someHandler() {
...
}
}
消费对象名称: someConfiguration.someHandler.serviceActivator
处理对象名称: someHandler(@Bean的名称)
@Configuratiom
public class SomeConfiguration {
@Bean("someService.handler")
@EndpointId("someService")
@ServiceActivator(inputChannel = ...)
public MessageHandler someHandler() {
...
}
}
消费对象名称: someService.handler(bean的名称,只要符合@Bean名称末尾加.handler的约束)
处理对象名称: someService(endpoint ID)
@EndpointId("someAdapter")
@InboundChannelAdapter(channel = "channel3", poller = @Poller(fixedDelay = "5000"))
public String pojoSource() {
...
}
SPCA: someAdapter
处理对象名称: someAdapter.source
@Bean("someAdapter.source")
@EndpointId("someAdapter")
@InboundChannelAdapter(channel = "channel3", poller = @Poller(fixedDelay = "5000"))
public MessageSource<?> source() {
return () -> {
...
};
}
SPCA: someAdapter
处理对象名称: someAdapter.source(只要符合@Bean名称末尾加.source的约束)