Package org.springframework.integration

Examples of org.springframework.integration.Message


   
    Scrobble scrobble1 = new Scrobble(user1, track1, false);
    Thread.sleep(3);
    Scrobble scrobble2 = new Scrobble(user1, track1, false);

    Message message1 = new GenericMessage<Scrobble>(scrobble1);
    Message message2 = new GenericMessage<Scrobble>(scrobble2);
    PollableChannel scrobbleChannel = mock(PollableChannel.class);
    when(scrobbleChannel.receive()).thenReturn(message1, message2, null);
   
    scrobbleService.setScrobbleChannel(scrobbleChannel);
    scrobbleService.receive();
View Full Code Here


    Thread.sleep(3);
    Scrobble scrobble2 = new Scrobble(user1, track2, false);

    assertFalse(scrobble1.getStartTime().equals(scrobble2.getStartTime()));
   
    Message message1 = new GenericMessage<Scrobble>(scrobble1);
    Message message2 = new GenericMessage<Scrobble>(scrobble2);
    PollableChannel scrobbleChannel = mock(PollableChannel.class);
    when(scrobbleChannel.receive()).thenReturn(message1, message2, null);
   
    scrobbleService.setScrobbleChannel(scrobbleChannel);
    scrobbleService.receive();
View Full Code Here

  public void differentUsersCanScrobbleSameTrack() throws ApplicationException {
   
    Scrobble scrobble1 = new Scrobble(user1, track1, false);
    Scrobble scrobble2 = new Scrobble(user2, track1, false);

    Message message1 = new GenericMessage<Scrobble>(scrobble1);
    Message message2 = new GenericMessage<Scrobble>(scrobble2);
    PollableChannel scrobbleChannel = mock(PollableChannel.class);
    when(scrobbleChannel.receive()).thenReturn(message1, message2, null);
   
    scrobbleService.setScrobbleChannel(scrobbleChannel);
    scrobbleService.receive();
View Full Code Here

  @Test
  public void scrobblerIgnoresTooNewSubmissions() throws ApplicationException {

    Scrobble scrobble = new Scrobble(user1, track1, false);

    Message message = new GenericMessage<Scrobble>(scrobble);
    PollableChannel scrobbleChannel = mock(PollableChannel.class);
    when(scrobbleChannel.receive()).thenReturn(message, (Message) null);

    scrobbleService.setScrobbleChannel(scrobbleChannel);
    scrobbleService.receive();
View Full Code Here

    @Test
    public void testSendingTwoWayMessage() throws Exception {

        MessageChannel requestChannel = applicationContext.getBean("channelB", MessageChannel.class);
        Message message = new GenericMessage<Object>(MESSAGE_BODY);
        //Need to subscribe the responseChannel first
        DirectChannel responseChannel = (DirectChannel) applicationContext.getBean("channelC");
        responseChannel.subscribe(new MessageHandler() {
            public void handleMessage(Message<?> message) {
                String result = (String) message.getPayload();
                assertEquals("Get the wrong result", MESSAGE_BODY + " is processed",  result);               
            }           
        });
        requestChannel.send(message);
    }
View Full Code Here

    @Test
    public void testSendingTwoWayMessage() throws Exception {

        MessageChannel requestChannel = (MessageChannel) applicationContext.getBean("channelB");
        Message message = new GenericMessage(MESSAGE_BODY);
        //Need to subscribe the responseChannel first
        DirectChannel responseChannel = (DirectChannel) applicationContext.getBean("channelC");
        responseChannel.subscribe(new MessageHandler() {
            public void handleMessage(Message<?> message) {
                String result = (String) message.getPayload();
                assertEquals("Get the wrong result", MESSAGE_BODY + " is processed",  result);               
            }           
        });
        requestChannel.send(message);
    }
View Full Code Here

        Exchange outExchange = getCamelTemplate().send(getCamelEndpointUri(), inExchange);
        if (outExchange.getOut() != null && outExchange.getOut().isFault()) {
            result = true;
        }

        Message response;
        if (isExpectReply()) {
            //Check the message header for the return address
            response = SpringIntegrationBinding.storeToSpringIntegrationMessage(outExchange.getOut());
            if (replyChannel == null) {
                MessageChannel messageReplyChannel = (MessageChannel) message.getHeaders().get(MessageHeaders.REPLY_CHANNEL);
View Full Code Here

    @Test
    public void testSendingTwoWayMessage() throws Exception {

        MessageChannel requestChannel = (MessageChannel) applicationContext.getBean("channelB");
        Message message = new GenericMessage<Object>(MESSAGE_BODY);
        //Need to subscribe the responseChannel first
        DirectChannel responseChannel = (DirectChannel) applicationContext.getBean("channelC");
        responseChannel.subscribe(new MessageHandler() {
            public void handleMessage(Message<?> message) {
                String result = (String) message.getPayload();
                assertEquals("Get the wrong result", MESSAGE_BODY + " is processed",  result);               
            }           
        });
        requestChannel.send(message);
    }
View Full Code Here

            headerMap.put(key, value);
          }
        }
      }

      Message newMessage = MessageBuilder.withPayload(message.getPayload()).copyHeaders(headerMap).build();
      log.debug("NEW HEADERS: " + newMessage.getHeaders().toString());

      return super.transform(newMessage);
    }
    catch (Exception e) {
      throw new MessagingException(message, "failed to transform message headers", e);
View Full Code Here

    private Message<?> messageContainingEvent(final StubDomainEvent event) {
        return argThat(new ArgumentMatcher<Message<?>>() {
            @Override
            public boolean matches(Object argument) {
                Message message = (Message) argument;
                return event.equals(message.getPayload());
            }
        });
    }
View Full Code Here

TOP

Related Classes of org.springframework.integration.Message

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.