コード例 #1
0
  @Test
  public void testWithMessageHistory() throws Exception {
    GemfireMessageStore store = new GemfireMessageStore(this.cache);
    store.afterPropertiesSet();

    store.getMessageGroup(1);

    Message<?> message = new GenericMessage<String>("Hello");
    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.addMessageToGroup(1, message);

    message = store.getMessageGroup(1).getMessages().iterator().next();

    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"));
  }
コード例 #2
0
 @Override
 protected void handleMessage(Message<?> message) {
   if (this.shouldTrack) {
     message = MessageHistory.write(message, this, this.getMessageBuilderFactory());
   }
   try {
     this.messagingTemplate.send(getOutputChannel(), message);
   } catch (Exception e) {
     if (e instanceof MessagingException) {
       throw (MessagingException) e;
     } else {
       throw new MessagingException(message, "Failed to send Message", e);
     }
   }
 }