List of usage examples for org.springframework.messaging Message getHeaders
MessageHeaders getHeaders();
From source file:com.qpark.eip.core.spring.AbstractAggregator.java
/** * Remove the header values of/*from ww w. j a v a 2s . c om*/ * {@link IntegrationMessageHeaderAccessor#CORRELATION_ID} and * {@link IntegrationMessageHeaderAccessor#SEQUENCE_SIZE}. * * @param m * the Message */ protected static void removeAddedHeader(final Message<?> m) { if (m != null) { m.getHeaders().remove(IntegrationMessageHeaderAccessor.CORRELATION_ID); m.getHeaders().remove(IntegrationMessageHeaderAccessor.SEQUENCE_SIZE); } }
From source file:ru.asmsoft.p2p.incoming.LocalAddressesFilteringService.java
@Override public boolean isPacketAllowed(Message message) { return !localIpAddresses.contains((String) message.getHeaders().get("ip_address")); }
From source file:ru.asmsoft.p2p.outgoing.OutgoingChannelAdapter.java
public void send(Message<String> message) throws IOException { int port = (Integer) message.getHeaders().get("ip_port"); String ip = (String) message.getHeaders().get("ip_address"); byte[] bytesToSend = message.getPayload().getBytes(); InetAddress IPAddress = InetAddress.getByName(ip); DatagramPacket sendPacket = new DatagramPacket(bytesToSend, bytesToSend.length, IPAddress, port); clientSocket.send(sendPacket);//w ww .j a v a2 s. com }
From source file:org.openwms.common.comm.synq.TimesyncHandler.java
/** * Builds response message with the current time and the same request header to preserve header information (seq. number etc.) in post * transformation steps./*from w ww.j av a 2s . c o m*/ * * @param timesyncRequest the request * @return the response */ @Override public Message<TimesyncResponse> apply(Message<TimesyncRequest> timesyncRequest) { return MessageBuilder.createMessage(new TimesyncResponse(), timesyncRequest.getHeaders()); }
From source file:io.pivotal.poc.dispatcher.MessageDispatcher.java
private String sendMessage(String topic, Object body, HttpHeaders requestHeaders) { MessageChannel channel = resolver.resolveDestination(topic + ".input"); MessageBuilder<?> builder = MessageBuilder.withPayload(body); builder.setHeader(MessageHeaders.CONTENT_TYPE, requestHeaders.getContentType()); for (Map.Entry<String, List<String>> entry : requestHeaders.entrySet()) { String headerName = entry.getKey(); if (requestHeadersToMap.contains(headerName)) { builder.setHeaderIfAbsent(headerName, StringUtils.collectionToCommaDelimitedString(entry.getValue())); }//from www.j av a 2 s. c om } Message<?> message = builder.build(); channel.send(message); return message.getHeaders().getId().toString(); }
From source file:org.openwms.common.comm.transformer.tcp.HeaderAppendingTransformer.java
@Transformer public Message<Payload> transform(Message<Payload> msg) { MessageHeaderAccessor mha = new MessageHeaderAccessor(); mha.copyHeaders(msg.getHeaders()); mha.setHeader(CommHeader.SYNC_FIELD_NAME, msg.getHeaders().get(CommHeader.SYNC_FIELD_NAME)); mha.setHeader(CommHeader.MSG_LENGTH_FIELD_NAME, headerLength(msg.getHeaders()) + msg.getPayload().asString().length()); mha.setHeader(CommHeader.SENDER_FIELD_NAME, msg.getHeaders().get(CommHeader.RECEIVER_FIELD_NAME)); mha.setHeader(CommHeader.RECEIVER_FIELD_NAME, msg.getHeaders().get(CommHeader.SENDER_FIELD_NAME)); mha.setHeader(CommHeader.SEQUENCE_FIELD_NAME, Integer.parseInt(String.valueOf(msg.getHeaders().get(CommHeader.SEQUENCE_FIELD_NAME))) + 1); return org.springframework.messaging.support.MessageBuilder.withPayload(msg.getPayload()).setHeaders(mha) .build();/* w w w . j a v a 2 s. co m*/ }
From source file:ch.rasc.wampspring.method.WampMessageTypeMessageCondition.java
@Override public WampMessageTypeMessageCondition getMatchingCondition(Message<?> message) { WampMessageType actualMessageType = (WampMessageType) message.getHeaders() .get(WampMessageHeader.WAMP_MESSAGE_TYPE.name()); if (actualMessageType != this.messageType) { return null; }//from w w w . java 2s . c om return this; }
From source file:org.opencredo.couchdb.outbound.CouchDbSendingMessageHandler.java
@Override protected final void handleMessageInternal(Message<?> message) throws Exception { System.out.println(message.getHeaders().toString()); System.out.println(message.getPayload().toString()); String documentId = createDocumentId(message); if (logger.isDebugEnabled()) { logger.debug("sending message to CouchDB [" + message + "]"); }/*w w w . j a va2 s . c o m*/ couchDbDocumentOperations.writeDocument(documentId, message.getPayload(), message.getHeaders(), counter); }
From source file:biz.c24.io.spring.integration.config.HeaderEnricherTests.java
@Test public void canEnrich() throws Exception { template.convertAndSend(loadCsvBytes()); Message<?> message = rightChannel.receive(1); assertThat(message.getPayload(), notNullValue()); assertThat(message.getHeaders().get("bar", String.class), is("Acheson")); assertThat(message.getHeaders().get("foo", String.class), is("Andy")); }
From source file:ch.rasc.wampspring.method.WampMessageTypeMessageCondition.java
@Override public int compareTo(WampMessageTypeMessageCondition other, Message<?> message) { WampMessageType actualMessageType = (WampMessageType) message.getHeaders() .get(WampMessageHeader.WAMP_MESSAGE_TYPE.name()); if (actualMessageType != null) { if (actualMessageType == this.getMessageType() && actualMessageType == other.getMessageType()) { return 0; } else if (actualMessageType == this.getMessageType()) { return -1; } else if (actualMessageType == other.getMessageType()) { return 1; }//from w w w . ja v a 2 s. c o m } return 0; }