use of org.springframework.integration.channel.PriorityChannel in project spring-integration by spring-projects.
the class ChannelCapacityPlaceholderTests method testCapacityOnPriorityChannel.
@Test
public void testCapacityOnPriorityChannel() {
PriorityChannel channel = context.getBean("priorityChannel", PriorityChannel.class);
assertNotNull(channel);
assertEquals(99, channel.getRemainingCapacity());
channel.send(MessageBuilder.withPayload("test1").build());
channel.send(MessageBuilder.withPayload("test2").build());
assertEquals(97, channel.getRemainingCapacity());
assertNotNull(channel.receive(0));
assertEquals(98, channel.getRemainingCapacity());
}
use of org.springframework.integration.channel.PriorityChannel in project spring-integration by spring-projects.
the class ConfigurableMongoDbMessageGroupStoreTests method testPriorityChannel.
@Test
@MongoDbAvailable
public void testPriorityChannel() throws Exception {
this.cleanupCollections(new SimpleMongoDbFactory(new MongoClient(), "test"));
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("ConfigurableMongoDbMessageStore-CustomConverter.xml", this.getClass());
context.refresh();
Object priorityChannel = context.getBean("priorityChannel");
assertThat(priorityChannel, Matchers.instanceOf(PriorityChannel.class));
QueueChannel channel = (QueueChannel) priorityChannel;
Message<String> message = MessageBuilder.withPayload("1").setHeader(IntegrationMessageHeaderAccessor.PRIORITY, 1).build();
channel.send(message);
message = MessageBuilder.withPayload("-1").setHeader(IntegrationMessageHeaderAccessor.PRIORITY, -1).build();
channel.send(message);
message = MessageBuilder.withPayload("3").setHeader(IntegrationMessageHeaderAccessor.PRIORITY, 3).build();
channel.send(message);
message = MessageBuilder.withPayload("0").setHeader(IntegrationMessageHeaderAccessor.PRIORITY, 0).build();
channel.send(message);
message = MessageBuilder.withPayload("2").setHeader(IntegrationMessageHeaderAccessor.PRIORITY, 2).build();
channel.send(message);
message = MessageBuilder.withPayload("none").build();
channel.send(message);
message = MessageBuilder.withPayload("31").setHeader(IntegrationMessageHeaderAccessor.PRIORITY, 3).build();
channel.send(message);
Message<?> receive = channel.receive(1000);
assertNotNull(receive);
assertEquals("3", receive.getPayload());
receive = channel.receive(1000);
assertNotNull(receive);
assertEquals("31", receive.getPayload());
receive = channel.receive(1000);
assertNotNull(receive);
assertEquals("2", receive.getPayload());
receive = channel.receive(1000);
assertNotNull(receive);
assertEquals("1", receive.getPayload());
receive = channel.receive(1000);
assertNotNull(receive);
assertEquals("0", receive.getPayload());
receive = channel.receive(1000);
assertNotNull(receive);
assertEquals("-1", receive.getPayload());
receive = channel.receive(1000);
assertNotNull(receive);
assertEquals("none", receive.getPayload());
context.close();
}
Aggregations