Package org.springframework.messaging

Examples of org.springframework.messaging.MessageHeaders


   * The content of the given header map is copied.
   * @param payload the message payload (never {@code null})
   * @param headers message headers to use for initialization
   */
  public GenericMessage(T payload, Map<String, Object> headers) {
    this(payload, new MessageHeaders(headers));
  }
View Full Code Here


  @SuppressWarnings("unchecked")
  public Message<T> build() {
    if (this.originalMessage != null && !this.headerAccessor.isModified()) {
      return this.originalMessage;
    }
    MessageHeaders headersToUse = this.headerAccessor.toMessageHeaders();
    if (this.payload instanceof Throwable) {
      return (Message<T>) new ErrorMessage((Throwable) this.payload, headersToUse);
    }
    else {
      return new GenericMessage<T>(this.payload, headersToUse);
View Full Code Here

  public void handleReturnValue(Object returnValue, MethodParameter returnType, Message<?> message) throws Exception {
    if (returnValue == null) {
      return;
    }

    MessageHeaders headers = message.getHeaders();
    String destination = SimpMessageHeaderAccessor.getDestination(headers);
    String sessionId = SimpMessageHeaderAccessor.getSessionId(headers);
    String subscriptionId = SimpMessageHeaderAccessor.getSubscriptionId(headers);

    Assert.state(subscriptionId != null,
View Full Code Here

    }
    return new UserDestinationResult(destination, resolved, info.getSubscribeDestination(), info.getUser());
  }

  private DestinationInfo parseUserDestination(Message<?> message) {
    MessageHeaders headers = message.getHeaders();
    SimpMessageType messageType = SimpMessageHeaderAccessor.getMessageType(headers);
    String destination = SimpMessageHeaderAccessor.getDestination(headers);
    Principal principal = SimpMessageHeaderAccessor.getUser(headers);
    String sessionId = SimpMessageHeaderAccessor.getSessionId(headers);
View Full Code Here

  @Override
  public void handleReturnValue(Object returnValue, MethodParameter returnType, Message<?> message) throws Exception {
    if (returnValue == null) {
      return;
    }
    MessageHeaders headers = message.getHeaders();
    String sessionId = SimpMessageHeaderAccessor.getSessionId(headers);

    SendToUser sendToUser = returnType.getMethodAnnotation(SendToUser.class);
    if (sendToUser != null) {
      boolean broadcast = sendToUser.broadcast();
View Full Code Here

        this.matchingHeaders = matchingHeaders;
    }
   
    @Override
    public boolean accept(Message<?> message) {
        MessageHeaders messageHeaders = message.getHeaders();

        Map<String, Object> citrusMessageHeaders = new HashMap<String, Object>();
        if (message.getPayload() instanceof com.consol.citrus.message.Message) {
            citrusMessageHeaders = ((com.consol.citrus.message.Message) message.getPayload()).copyHeaders();
        }

        for (Entry<String, String> matchEntry : matchingHeaders.entrySet()) {
            String namePart = matchEntry.getKey();
           
            if (!messageHeaders.containsKey(namePart) && !citrusMessageHeaders.containsKey(namePart)) {
                return false;
            }

            if (citrusMessageHeaders.containsKey(namePart) && !citrusMessageHeaders.get(namePart).equals(matchEntry.getValue())) {
                return false;
            } else if (messageHeaders.containsKey(namePart) && !messageHeaders.get(namePart).toString().equals(matchEntry.getValue())) {
                return false;
            }
        }
       
        return true;
View Full Code Here

  @Test
  public void resolveArgumentMessageHeaders() throws Exception {
    Object resolved = this.resolver.resolveArgument(this.paramMessageHeaders, this.message);

    assertTrue(resolved instanceof MessageHeaders);
    MessageHeaders headers = (MessageHeaders) resolved;
    assertEquals("bar", headers.get("foo"));
  }
View Full Code Here

  public void testReply() {
    JobParametersBuilder builder = new JobParametersBuilder();
    builder.addString("dontclash", "12");
    Map<String, Object> map = new HashMap<String, Object>();
    map.put(MessageHeaders.REPLY_CHANNEL, "response");
    MessageHeaders headers = new MessageHeaders(map);
    GenericMessage<JobLaunchRequest> trigger = new GenericMessage<JobLaunchRequest>(new JobLaunchRequest(job,
        builder.toJobParameters()), headers);
    requestChannel.send(trigger);
    Message<JobExecution> executionMessage = (Message<JobExecution>) responseChannel.receive(1000);
View Full Code Here

  public void testReply() {
    JobParametersBuilder builder = new JobParametersBuilder();
    builder.addString("dontclash", "12");
    Map<String, Object> map = new HashMap<String, Object>();
    map.put(MessageHeaders.REPLY_CHANNEL, "response");
    MessageHeaders headers = new MessageHeaders(map);
    GenericMessage<JobLaunchRequest> trigger = new GenericMessage<JobLaunchRequest>(new JobLaunchRequest(job,
        builder.toJobParameters()), headers);
    requestChannel.send(trigger);
    Message<JobExecution> executionMessage = (Message<JobExecution>) responseChannel.receive(1000);
View Full Code Here

    JobParametersBuilder builder = new JobParametersBuilder();
    builder.addString("dontclash", "12");
    Map<String, Object> map = new HashMap<String, Object>();
    map.put(MessageHeaders.REPLY_CHANNEL, "response");
    MessageHeaders headers = new MessageHeaders(map);
    GenericMessage<JobLaunchRequest> trigger = new GenericMessage<JobLaunchRequest>(new JobLaunchRequest(testJob,
        builder.toJobParameters()), headers);
    requestChannel.send(trigger);

    Message<JobExecution> executionMessage = (Message<JobExecution>) responseChannel.receive(1000);
View Full Code Here

TOP

Related Classes of org.springframework.messaging.MessageHeaders

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.