Search in sources :

Example 1 with JdbcMessageStore

use of org.springframework.integration.jdbc.store.JdbcMessageStore in project spring-integration by spring-projects.

the class MySqlJdbcMessageStoreTests method testSameMessageAndGroupToMultipleRegions.

@Test
@Transactional
@Rollback(false)
@Repeat(20)
public void testSameMessageAndGroupToMultipleRegions() throws Exception {
    final String groupId = "myGroup";
    final String region1 = "region1";
    final String region2 = "region2";
    final JdbcMessageStore messageStore1 = new JdbcMessageStore(dataSource);
    messageStore1.setRegion(region1);
    final JdbcMessageStore messageStore2 = new JdbcMessageStore(dataSource);
    messageStore1.setRegion(region2);
    final Message<String> message = MessageBuilder.withPayload("foo").build();
    final MessageBuilder<String> builder1 = MessageBuilder.fromMessage(message);
    final MessageBuilder<String> builder2 = MessageBuilder.fromMessage(message);
    builder1.setSequenceNumber(1);
    builder2.setSequenceNumber(2);
    final Message<?> message1 = builder1.build();
    final Message<?> message2 = builder2.build();
    messageStore1.addMessageToGroup(groupId, message1);
    messageStore2.addMessageToGroup(groupId, message2);
    final Message<?> messageFromRegion1 = messageStore1.pollMessageFromGroup(groupId);
    final Message<?> messageFromRegion2 = messageStore2.pollMessageFromGroup(groupId);
    assertNotNull(messageFromRegion1);
    assertNotNull(messageFromRegion2);
    LOG.info("messageFromRegion1: " + messageFromRegion1.getHeaders().getId() + "; Sequence #: " + new IntegrationMessageHeaderAccessor(messageFromRegion1).getSequenceNumber());
    LOG.info("messageFromRegion2: " + messageFromRegion2.getHeaders().getId() + "; Sequence #: " + new IntegrationMessageHeaderAccessor(messageFromRegion2).getSequenceNumber());
    assertEquals(Integer.valueOf(1), messageFromRegion1.getHeaders().get(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER));
    assertEquals(Integer.valueOf(2), messageFromRegion2.getHeaders().get(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER));
}
Also used : IntegrationMessageHeaderAccessor(org.springframework.integration.IntegrationMessageHeaderAccessor) JdbcMessageStore(org.springframework.integration.jdbc.store.JdbcMessageStore) Test(org.junit.Test) Repeat(org.springframework.test.annotation.Repeat) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with JdbcMessageStore

use of org.springframework.integration.jdbc.store.JdbcMessageStore in project spring-integration by spring-projects.

the class JdbcMessageStoreParserTests method testSimpleMessageStoreWithTemplate.

@Test
public void testSimpleMessageStoreWithTemplate() {
    setUp("jdbcOperationsJdbcMessageStore.xml", getClass());
    MessageStore store = context.getBean("messageStore", MessageStore.class);
    assertTrue(store instanceof JdbcMessageStore);
}
Also used : JdbcMessageStore(org.springframework.integration.jdbc.store.JdbcMessageStore) MessageStore(org.springframework.integration.store.MessageStore) JdbcMessageStore(org.springframework.integration.jdbc.store.JdbcMessageStore) Test(org.junit.Test)

Example 3 with JdbcMessageStore

use of org.springframework.integration.jdbc.store.JdbcMessageStore in project spring-integration by spring-projects.

the class JdbcMessageStoreParserTests method testSimpleMessageStoreWithDataSource.

@Test
public void testSimpleMessageStoreWithDataSource() {
    setUp("defaultJdbcMessageStore.xml", getClass());
    MessageStore store = context.getBean("messageStore", MessageStore.class);
    assertTrue(store instanceof JdbcMessageStore);
}
Also used : JdbcMessageStore(org.springframework.integration.jdbc.store.JdbcMessageStore) MessageStore(org.springframework.integration.store.MessageStore) JdbcMessageStore(org.springframework.integration.jdbc.store.JdbcMessageStore) Test(org.junit.Test)

Example 4 with JdbcMessageStore

use of org.springframework.integration.jdbc.store.JdbcMessageStore in project spring-integration by spring-projects.

the class MySqlJdbcMessageStoreTests method init.

@Before
public void init() {
    messageStore = new JdbcMessageStore(dataSource);
    messageStore.setRegion("JdbcMessageStoreTests");
}
Also used : JdbcMessageStore(org.springframework.integration.jdbc.store.JdbcMessageStore) Before(org.junit.Before)

Aggregations

JdbcMessageStore (org.springframework.integration.jdbc.store.JdbcMessageStore)4 Test (org.junit.Test)3 MessageStore (org.springframework.integration.store.MessageStore)2 Before (org.junit.Before)1 IntegrationMessageHeaderAccessor (org.springframework.integration.IntegrationMessageHeaderAccessor)1 Repeat (org.springframework.test.annotation.Repeat)1 Rollback (org.springframework.test.annotation.Rollback)1 Transactional (org.springframework.transaction.annotation.Transactional)1