Java源码示例:org.springframework.messaging.support.AbstractSubscribableChannel
示例1
@Test
public void clientOutboundChannelCustomized() {
ApplicationContext context = loadConfig(CustomConfig.class);
AbstractSubscribableChannel channel = context.getBean(
"clientOutboundChannel", AbstractSubscribableChannel.class);
assertEquals(4, channel.getInterceptors().size());
ThreadPoolTaskExecutor taskExecutor = context.getBean(
"clientOutboundChannelExecutor", ThreadPoolTaskExecutor.class);
assertEquals(21, taskExecutor.getCorePoolSize());
assertEquals(22, taskExecutor.getMaxPoolSize());
assertEquals(23, taskExecutor.getKeepAliveSeconds());
SimpleBrokerMessageHandler broker =
context.getBean("simpleBrokerMessageHandler", SimpleBrokerMessageHandler.class);
assertTrue(broker.isPreservePublishOrder());
}
示例2
@Test
public void brokerChannelCustomized() {
ApplicationContext context = loadConfig(CustomConfig.class);
AbstractSubscribableChannel channel = context.getBean(
"brokerChannel", AbstractSubscribableChannel.class);
assertEquals(4, channel.getInterceptors().size());
ThreadPoolTaskExecutor taskExecutor = context.getBean(
"brokerChannelExecutor", ThreadPoolTaskExecutor.class);
assertEquals(31, taskExecutor.getCorePoolSize());
assertEquals(32, taskExecutor.getMaxPoolSize());
assertEquals(33, taskExecutor.getKeepAliveSeconds());
}
示例3
@Test
public void clientOutboundChannelCustomized() {
ApplicationContext context = loadConfig(CustomConfig.class);
AbstractSubscribableChannel channel = context.getBean(
"clientOutboundChannel", AbstractSubscribableChannel.class);
assertEquals(4, channel.getInterceptors().size());
ThreadPoolTaskExecutor taskExecutor = context.getBean(
"clientOutboundChannelExecutor", ThreadPoolTaskExecutor.class);
assertEquals(21, taskExecutor.getCorePoolSize());
assertEquals(22, taskExecutor.getMaxPoolSize());
assertEquals(23, taskExecutor.getKeepAliveSeconds());
SimpleBrokerMessageHandler broker =
context.getBean("simpleBrokerMessageHandler", SimpleBrokerMessageHandler.class);
assertTrue(broker.isPreservePublishOrder());
}
示例4
@Test
public void brokerChannelCustomized() {
ApplicationContext context = loadConfig(CustomConfig.class);
AbstractSubscribableChannel channel = context.getBean(
"brokerChannel", AbstractSubscribableChannel.class);
assertEquals(4, channel.getInterceptors().size());
ThreadPoolTaskExecutor taskExecutor = context.getBean(
"brokerChannelExecutor", ThreadPoolTaskExecutor.class);
assertEquals(31, taskExecutor.getCorePoolSize());
assertEquals(32, taskExecutor.getMaxPoolSize());
assertEquals(33, taskExecutor.getKeepAliveSeconds());
}
示例5
@Test
public void testInterceptors(final MockTracer tracer) {
final DelegatingWebSocketMessageBrokerConfiguration configuration = new DelegatingWebSocketMessageBrokerConfiguration();
final AbstractSubscribableChannel inboundChannel = configuration.clientInboundChannel();
inboundChannel.setBeanName("clientInboundChannel");
final AbstractSubscribableChannel outboundChannel = configuration.clientOutboundChannel();
outboundChannel.setBeanName("clientOutboundChannel");
outboundChannel.subscribe(new SubProtocolWebSocketHandler(inboundChannel, outboundChannel));
inboundChannel.subscribe(new SubProtocolWebSocketHandler(inboundChannel, outboundChannel));
configuration.clientInboundChannelExecutor().initialize();
configuration.clientOutboundChannelExecutor().initialize();
final Map<String,Object> headers = Collections.<String,Object>singletonMap("simpMessageType", SimpMessageType.MESSAGE);
final GenericMessage<String> message = new GenericMessage<>("test", headers);
outboundChannel.send(message);
inboundChannel.send(message);
await().atMost(15, TimeUnit.SECONDS).until(TestUtil.reportedSpansSize(tracer), equalTo(2));
assertEquals(2, tracer.finishedSpans().size());
}
示例6
@Bean
public AbstractSubscribableChannel clientInboundChannel() {
ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(clientInboundChannelExecutor());
channel.setLogger(SimpLogging.forLog(channel.getLogger()));
ChannelRegistration reg = getClientInboundChannelRegistration();
if (reg.hasInterceptors()) {
channel.setInterceptors(reg.getInterceptors());
}
return channel;
}
示例7
@Bean
public AbstractSubscribableChannel clientOutboundChannel() {
ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(clientOutboundChannelExecutor());
channel.setLogger(SimpLogging.forLog(channel.getLogger()));
ChannelRegistration reg = getClientOutboundChannelRegistration();
if (reg.hasInterceptors()) {
channel.setInterceptors(reg.getInterceptors());
}
return channel;
}
示例8
@Bean
public AbstractSubscribableChannel brokerChannel() {
ChannelRegistration reg = getBrokerRegistry().getBrokerChannelRegistration();
ExecutorSubscribableChannel channel = (reg.hasTaskExecutor() ?
new ExecutorSubscribableChannel(brokerChannelExecutor()) : new ExecutorSubscribableChannel());
reg.interceptors(new ImmutableMessageChannelInterceptor());
channel.setLogger(SimpLogging.forLog(channel.getLogger()));
channel.setInterceptors(reg.getInterceptors());
return channel;
}
示例9
@Test
public void clientInboundChannelCustomized() {
ApplicationContext context = loadConfig(CustomConfig.class);
AbstractSubscribableChannel channel = context.getBean(
"clientInboundChannel", AbstractSubscribableChannel.class);
assertEquals(3, channel.getInterceptors().size());
CustomThreadPoolTaskExecutor taskExecutor = context.getBean(
"clientInboundChannelExecutor", CustomThreadPoolTaskExecutor.class);
assertEquals(11, taskExecutor.getCorePoolSize());
assertEquals(12, taskExecutor.getMaxPoolSize());
assertEquals(13, taskExecutor.getKeepAliveSeconds());
}
示例10
@Override
@Bean
public AbstractSubscribableChannel clientInboundChannel() {
TestChannel channel = new TestChannel();
channel.setInterceptors(super.clientInboundChannel().getInterceptors());
return channel;
}
示例11
@Override
@Bean
public AbstractSubscribableChannel clientOutboundChannel() {
TestChannel channel = new TestChannel();
channel.setInterceptors(super.clientOutboundChannel().getInterceptors());
return channel;
}
示例12
private void testChannel(
String channelName, List<Class<? extends MessageHandler>> subscriberTypes, int interceptorCount) {
AbstractSubscribableChannel channel = this.appContext.getBean(channelName, AbstractSubscribableChannel.class);
for (Class<? extends MessageHandler> subscriberType : subscriberTypes) {
MessageHandler subscriber = this.appContext.getBean(subscriberType);
assertNotNull("No subscription for " + subscriberType, subscriber);
assertTrue(channel.hasSubscription(subscriber));
}
List<ChannelInterceptor> interceptors = channel.getInterceptors();
assertEquals(interceptorCount, interceptors.size());
assertEquals(ImmutableMessageChannelInterceptor.class, interceptors.get(interceptors.size()-1).getClass());
}
示例13
@Bean
public AbstractSubscribableChannel clientInboundChannel() {
ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(clientInboundChannelExecutor());
channel.setLogger(SimpLogging.forLog(channel.getLogger()));
ChannelRegistration reg = getClientInboundChannelRegistration();
if (reg.hasInterceptors()) {
channel.setInterceptors(reg.getInterceptors());
}
return channel;
}
示例14
@Bean
public AbstractSubscribableChannel clientOutboundChannel() {
ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(clientOutboundChannelExecutor());
channel.setLogger(SimpLogging.forLog(channel.getLogger()));
ChannelRegistration reg = getClientOutboundChannelRegistration();
if (reg.hasInterceptors()) {
channel.setInterceptors(reg.getInterceptors());
}
return channel;
}
示例15
@Bean
public AbstractSubscribableChannel brokerChannel() {
ChannelRegistration reg = getBrokerRegistry().getBrokerChannelRegistration();
ExecutorSubscribableChannel channel = (reg.hasTaskExecutor() ?
new ExecutorSubscribableChannel(brokerChannelExecutor()) : new ExecutorSubscribableChannel());
reg.interceptors(new ImmutableMessageChannelInterceptor());
channel.setLogger(SimpLogging.forLog(channel.getLogger()));
channel.setInterceptors(reg.getInterceptors());
return channel;
}
示例16
@Test
public void clientInboundChannelCustomized() {
ApplicationContext context = loadConfig(CustomConfig.class);
AbstractSubscribableChannel channel = context.getBean(
"clientInboundChannel", AbstractSubscribableChannel.class);
assertEquals(3, channel.getInterceptors().size());
CustomThreadPoolTaskExecutor taskExecutor = context.getBean(
"clientInboundChannelExecutor", CustomThreadPoolTaskExecutor.class);
assertEquals(11, taskExecutor.getCorePoolSize());
assertEquals(12, taskExecutor.getMaxPoolSize());
assertEquals(13, taskExecutor.getKeepAliveSeconds());
}
示例17
@Override
@Bean
public AbstractSubscribableChannel clientInboundChannel() {
TestChannel channel = new TestChannel();
channel.setInterceptors(super.clientInboundChannel().getInterceptors());
return channel;
}
示例18
@Override
@Bean
public AbstractSubscribableChannel clientOutboundChannel() {
TestChannel channel = new TestChannel();
channel.setInterceptors(super.clientOutboundChannel().getInterceptors());
return channel;
}
示例19
private void testChannel(
String channelName, List<Class<? extends MessageHandler>> subscriberTypes, int interceptorCount) {
AbstractSubscribableChannel channel = this.appContext.getBean(channelName, AbstractSubscribableChannel.class);
for (Class<? extends MessageHandler> subscriberType : subscriberTypes) {
MessageHandler subscriber = this.appContext.getBean(subscriberType);
assertNotNull("No subscription for " + subscriberType, subscriber);
assertTrue(channel.hasSubscription(subscriber));
}
List<ChannelInterceptor> interceptors = channel.getInterceptors();
assertEquals(interceptorCount, interceptors.size());
assertEquals(ImmutableMessageChannelInterceptor.class, interceptors.get(interceptors.size()-1).getClass());
}
示例20
@Bean
public AbstractSubscribableChannel clientInboundChannel() {
ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(clientInboundChannelExecutor());
ChannelRegistration reg = getClientInboundChannelRegistration();
channel.setInterceptors(reg.getInterceptors());
return channel;
}
示例21
@Bean
public AbstractSubscribableChannel clientOutboundChannel() {
ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(clientOutboundChannelExecutor());
ChannelRegistration reg = getClientOutboundChannelRegistration();
channel.setInterceptors(reg.getInterceptors());
return channel;
}
示例22
@Bean
public AbstractSubscribableChannel brokerChannel() {
ChannelRegistration reg = getBrokerRegistry().getBrokerChannelRegistration();
ExecutorSubscribableChannel channel = reg.hasTaskExecutor() ?
new ExecutorSubscribableChannel(brokerChannelExecutor()) : new ExecutorSubscribableChannel();
reg.setInterceptors(new ImmutableMessageChannelInterceptor());
channel.setInterceptors(reg.getInterceptors());
return channel;
}
示例23
@Test
public void clientInboundChannelCustomized() {
AbstractSubscribableChannel channel = this.customContext.getBean(
"clientInboundChannel", AbstractSubscribableChannel.class);
assertEquals(3, channel.getInterceptors().size());
CustomThreadPoolTaskExecutor taskExecutor = this.customContext.getBean(
"clientInboundChannelExecutor", CustomThreadPoolTaskExecutor.class);
assertEquals(11, taskExecutor.getCorePoolSize());
assertEquals(12, taskExecutor.getMaxPoolSize());
assertEquals(13, taskExecutor.getKeepAliveSeconds());
}
示例24
@Test
public void clientOutboundChannelCustomized() {
AbstractSubscribableChannel channel = this.customContext.getBean(
"clientOutboundChannel", AbstractSubscribableChannel.class);
assertEquals(3, channel.getInterceptors().size());
ThreadPoolTaskExecutor taskExecutor = this.customContext.getBean(
"clientOutboundChannelExecutor", ThreadPoolTaskExecutor.class);
assertEquals(21, taskExecutor.getCorePoolSize());
assertEquals(22, taskExecutor.getMaxPoolSize());
assertEquals(23, taskExecutor.getKeepAliveSeconds());
}
示例25
@Test
public void brokerChannelCustomized() {
AbstractSubscribableChannel channel = this.customContext.getBean(
"brokerChannel", AbstractSubscribableChannel.class);
assertEquals(4, channel.getInterceptors().size());
ThreadPoolTaskExecutor taskExecutor = this.customContext.getBean(
"brokerChannelExecutor", ThreadPoolTaskExecutor.class);
assertEquals(31, taskExecutor.getCorePoolSize());
assertEquals(32, taskExecutor.getMaxPoolSize());
assertEquals(33, taskExecutor.getKeepAliveSeconds());
}
示例26
@Override
@Bean
public AbstractSubscribableChannel clientInboundChannel() {
TestChannel channel = new TestChannel();
channel.setInterceptors(super.clientInboundChannel().getInterceptors());
return channel;
}
示例27
@Override
@Bean
public AbstractSubscribableChannel clientOutboundChannel() {
TestChannel channel = new TestChannel();
channel.setInterceptors(super.clientOutboundChannel().getInterceptors());
return channel;
}
示例28
private void testChannel(String channelName, List<Class<? extends MessageHandler>> subscriberTypes,
int interceptorCount) {
AbstractSubscribableChannel channel = this.appContext.getBean(channelName, AbstractSubscribableChannel.class);
for (Class<? extends MessageHandler> subscriberType : subscriberTypes) {
MessageHandler subscriber = this.appContext.getBean(subscriberType);
assertNotNull("No subsription for " + subscriberType, subscriber);
assertTrue(channel.hasSubscription(subscriber));
}
List<ChannelInterceptor> interceptors = channel.getInterceptors();
assertEquals(interceptorCount, interceptors.size());
assertEquals(ImmutableMessageChannelInterceptor.class, interceptors.get(interceptors.size()-1).getClass());
}
示例29
@Override
@Bean
public AbstractSubscribableChannel clientInboundChannel() {
return new TestChannel();
}
示例30
@Override
@Bean
public AbstractSubscribableChannel clientOutboundChannel() {
return new TestChannel();
}