Search in sources :

Example 16 with MessageStore

use of org.springframework.integration.store.MessageStore 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 17 with MessageStore

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

the class AbstractMongoDbMessageGroupStoreTests method testRemoveMessageGroup.

@Test
@MongoDbAvailable
public void testRemoveMessageGroup() throws Exception {
    this.cleanupCollections(new SimpleMongoDbFactory(new MongoClient(), "test"));
    MessageGroupStore store = this.getMessageGroupStore();
    MessageStore messageStore = this.getMessageStore();
    MessageGroup messageGroup = store.getMessageGroup(1);
    Message<?> message = new GenericMessage<String>("Hello");
    UUID id = message.getHeaders().getId();
    messageGroup = store.addMessageToGroup(1, message);
    assertNotNull(messageGroup);
    assertEquals(1, messageGroup.size());
    message = messageStore.getMessage(id);
    assertNotNull(message);
    store.removeMessageGroup(1);
    MessageGroup messageGroupA = store.getMessageGroup(1);
    assertEquals(0, messageGroupA.size());
    assertFalse(messageGroupA.equals(messageGroup));
}
Also used : MessageStore(org.springframework.integration.store.MessageStore) MongoClient(com.mongodb.MongoClient) GenericMessage(org.springframework.messaging.support.GenericMessage) AbstractBatchingMessageGroupStore(org.springframework.integration.store.AbstractBatchingMessageGroupStore) MessageGroupStore(org.springframework.integration.store.MessageGroupStore) SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory) MessageGroup(org.springframework.integration.store.MessageGroup) UUID(java.util.UUID) Test(org.junit.Test) MongoDbAvailable(org.springframework.integration.mongodb.rules.MongoDbAvailable)

Example 18 with MessageStore

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

the class AbstractMongoDbMessageGroupStoreTests method testMessageGroupWithAddedMessagePrimitiveGroupId.

@Test
@MongoDbAvailable
public void testMessageGroupWithAddedMessagePrimitiveGroupId() throws Exception {
    this.cleanupCollections(new SimpleMongoDbFactory(new MongoClient(), "test"));
    MessageGroupStore store = this.getMessageGroupStore();
    MessageStore messageStore = this.getMessageStore();
    MessageGroup messageGroup = store.getMessageGroup(1);
    Message<?> messageA = new GenericMessage<String>("A");
    Message<?> messageB = new GenericMessage<String>("B");
    store.addMessagesToGroup(1, messageA);
    messageGroup = store.addMessageToGroup(1, messageB);
    assertNotNull(messageGroup);
    assertEquals(2, messageGroup.size());
    Message<?> retrievedMessage = messageStore.getMessage(messageA.getHeaders().getId());
    assertNotNull(retrievedMessage);
    assertEquals(retrievedMessage.getHeaders().getId(), messageA.getHeaders().getId());
    // ensure that 'message_group' header that is only used internally is not propagated
    assertNull(retrievedMessage.getHeaders().get("message_group"));
}
Also used : MessageStore(org.springframework.integration.store.MessageStore) MongoClient(com.mongodb.MongoClient) GenericMessage(org.springframework.messaging.support.GenericMessage) AbstractBatchingMessageGroupStore(org.springframework.integration.store.AbstractBatchingMessageGroupStore) MessageGroupStore(org.springframework.integration.store.MessageGroupStore) SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory) MessageGroup(org.springframework.integration.store.MessageGroup) Test(org.junit.Test) MongoDbAvailable(org.springframework.integration.mongodb.rules.MongoDbAvailable)

Example 19 with MessageStore

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

the class AbstractMongoDbMessageStoreTests method testAddGetWithObjectDefaultConstructorPayload.

@Test
@MongoDbAvailable
public void testAddGetWithObjectDefaultConstructorPayload() throws Exception {
    cleanupCollections(new SimpleMongoDbFactory(new MongoClient(), "test"));
    MessageStore store = getMessageStore();
    Person p = new Person();
    p.setFname("John");
    p.setLname("Doe");
    Message<?> messageToStore = MessageBuilder.withPayload(p).build();
    store.addMessage(messageToStore);
    Message<?> retrievedMessage = store.getMessage(messageToStore.getHeaders().getId());
    assertNotNull(retrievedMessage);
    assertEquals(messageToStore.getPayload(), retrievedMessage.getPayload());
    assertEquals(messageToStore.getHeaders(), retrievedMessage.getHeaders());
    assertEquals(messageToStore, retrievedMessage);
}
Also used : MessageStore(org.springframework.integration.store.MessageStore) MongoClient(com.mongodb.MongoClient) SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory) Test(org.junit.Test) MongoDbAvailable(org.springframework.integration.mongodb.rules.MongoDbAvailable)

Example 20 with MessageStore

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

the class AbstractMongoDbMessageStoreTests method testWithMessageHistory.

@Test
@MongoDbAvailable
public void testWithMessageHistory() throws Exception {
    cleanupCollections(new SimpleMongoDbFactory(new MongoClient(), "test"));
    MessageStore store = getMessageStore();
    Foo foo = new Foo();
    foo.setName("foo");
    Message<?> message = MessageBuilder.withPayload(foo).setHeader("foo", foo).setHeader("bar", new Bar("bar")).setHeader("baz", new Baz()).setHeader("abc", new Abc()).setHeader("xyz", new Xyz()).build();
    DirectChannel fooChannel = new DirectChannel();
    fooChannel.setBeanName("fooChannel");
    DirectChannel barChannel = new DirectChannel();
    barChannel.setBeanName("barChannel");
    message = MessageHistory.write(message, fooChannel);
    message = MessageHistory.write(message, barChannel);
    store.addMessage(message);
    message = store.getMessage(message.getHeaders().getId());
    assertNotNull(message);
    assertTrue(message.getHeaders().get("foo") instanceof Foo);
    assertTrue(message.getHeaders().get("bar") instanceof Bar);
    assertTrue(message.getHeaders().get("baz") instanceof Baz);
    assertTrue(message.getHeaders().get("abc") instanceof Abc);
    assertTrue(message.getHeaders().get("xyz") instanceof Xyz);
    MessageHistory messageHistory = MessageHistory.read(message);
    assertNotNull(messageHistory);
    assertEquals(2, messageHistory.size());
    Properties fooChannelHistory = messageHistory.get(0);
    assertEquals("fooChannel", fooChannelHistory.get("name"));
    assertEquals("channel", fooChannelHistory.get("type"));
}
Also used : MessageStore(org.springframework.integration.store.MessageStore) MongoClient(com.mongodb.MongoClient) MessageHistory(org.springframework.integration.history.MessageHistory) SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory) DirectChannel(org.springframework.integration.channel.DirectChannel) Properties(java.util.Properties) Test(org.junit.Test) MongoDbAvailable(org.springframework.integration.mongodb.rules.MongoDbAvailable)

Aggregations

Test (org.junit.Test)23 MessageStore (org.springframework.integration.store.MessageStore)23 MongoDbAvailable (org.springframework.integration.mongodb.rules.MongoDbAvailable)14 MongoClient (com.mongodb.MongoClient)8 SimpleMongoDbFactory (org.springframework.data.mongodb.core.SimpleMongoDbFactory)8 GenericMessage (org.springframework.messaging.support.GenericMessage)5 JdbcMessageStore (org.springframework.integration.jdbc.store.JdbcMessageStore)4 UUID (java.util.UUID)3 AbstractBatchingMessageGroupStore (org.springframework.integration.store.AbstractBatchingMessageGroupStore)3 MessageGroup (org.springframework.integration.store.MessageGroup)3 MessageGroupStore (org.springframework.integration.store.MessageGroupStore)3 SimpleMessageStore (org.springframework.integration.store.SimpleMessageStore)3 Matchers.containsString (org.hamcrest.Matchers.containsString)2 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)2 AdviceMessage (org.springframework.integration.message.AdviceMessage)2 Properties (java.util.Properties)1 DirectChannel (org.springframework.integration.channel.DirectChannel)1 MessageHistory (org.springframework.integration.history.MessageHistory)1 MutableMessage (org.springframework.integration.support.MutableMessage)1 ClaimCheckInTransformer (org.springframework.integration.transformer.ClaimCheckInTransformer)1