List of usage examples for org.springframework.messaging Message getHeaders
MessageHeaders getHeaders();
From source file:com.qpark.eip.core.spring.RequestIdMessageHeaderEnhancer.java
/** * Enhance the message header with name of this class. * * @see org.springframework.integration.channel.ChannelInterceptor#preSend(org.springframework.integration.Message, * org.springframework.integration.MessageChannel) *///from w w w . j a va 2s. com @Override public Message<?> preSend(final Message<?> message, final MessageChannel channel) { Message<?> msg = null; if (message.getHeaders().get(HEADER_NAME_REQUEST_ID) == null) { Map<String, Object> headerMap = new HashMap<String, Object>(message.getHeaders()); headerMap.put(HEADER_NAME_REQUEST_ID, message.getHeaders().getId()); msg = MessageBuilder.withPayload(message.getPayload()).copyHeaders(headerMap).build(); } else { msg = message; } return msg; }
From source file:com.qpark.eip.core.spring.JAXBElementValueGetterTransformer.java
/** * @param message// w w w .ja v a 2 s . c o m * @return The value out of the {@link JAXBElement} */ @SuppressWarnings("unchecked") public Message<? extends T> transform(final Message<JAXBElement<?>> message) { JAXBElement<?> payload = message.getPayload(); return MessageBuilder.withPayload((T) payload.getValue()).copyHeaders(message.getHeaders()).build(); }
From source file:ru.asmsoft.p2p.heartbeat.Heartbeat.java
@ServiceActivator(inputChannel = "incoming-heartbeat") public void handleIncomingPing(Message<PingPacket> message) { logger.trace("Received: {}", message); String nodeAddress = (String) message.getHeaders().get("ip_address"); nodeRepository.registerNode(nodeAddress); PingPacket packet = message.getPayload(); // If our DB is outdated if (messageRepository.getDbVersion() < packet.getDbVersion()) { selfUpdateService.startNodeUpdate(nodeAddress); }// w w w . jav a2s . com }
From source file:com.it355.jmsdemo.app.messaging.MessageReceiver.java
@JmsListener(destination = ORDER_RESPONSE_QUEUE) public void receiveMessage(final Message<InventoryResponse> message) throws JMSException { LOG.info("+++++++++++++++++++++++++++++++++++++++++++++++++++++"); MessageHeaders headers = message.getHeaders(); LOG.info("Application : headers received : {}", headers); InventoryResponse response = message.getPayload(); LOG.info("Application : response received : {}", response); rderService.updateOrder(response);/*ww w .ja v a 2 s. c om*/ LOG.info("+++++++++++++++++++++++++++++++++++++++++++++++++++++"); }
From source file:ch.rasc.wampspring.config.WampSubProtocolHandler.java
@Override public String resolveSessionId(Message<?> message) { return (String) message.getHeaders().get(WampMessageHeader.WEBSOCKET_SESSION_ID.name()); }
From source file:nz.co.senanque.messaging.OrderReplyEndpoint.java
public void issueResponseFor(Message<org.w3c.dom.Document> orderResponse) { log.debug("processed orderResponse: correlationId {}", orderResponse.getHeaders().get(IntegrationMessageHeaderAccessor.CORRELATION_ID, Long.class)); org.w3c.dom.Document doc = orderResponse.getPayload(); Document document = new DOMBuilder().build(doc); Element root = document.getRootElement(); Order context = new Order(); @SuppressWarnings("unchecked") Iterator<Text> itr = (Iterator<Text>) root .getDescendants(new ContentFilter(ContentFilter.TEXT | ContentFilter.CDATA)); while (itr.hasNext()) { Text text = itr.next();//from w w w. ja v a2 s .c o m log.debug("name {} value {}", text.getParentElement().getName(), text.getValue()); String name = getName(text); try { Class<?> targetType = PropertyUtils.getPropertyType(context, name); Object value = ConvertUtils.convert(text.getValue(), targetType); PropertyUtils.setProperty(context, name, value); } catch (IllegalAccessException e) { // Ignore these and move on log.debug("{} {}", name, e.getMessage()); } catch (InvocationTargetException e) { // Ignore these and move on log.debug("{} {}", name, e.getMessage()); } catch (NoSuchMethodException e) { // Ignore these and move on log.debug("{} {}", name, e.getMessage()); } } }
From source file:org.opencredo.couchdb.outbound.CouchDbSendingMessageHandler.java
private String createDocumentId(Message<?> message) { String documentId;/*from w w w . ja v a 2s . com*/ if (documentIdExpression == null) { documentId = message.getHeaders().getId().toString(); } else { documentId = documentIdExpression.getValue(evaluationContext, message, String.class); } if (logger.isDebugEnabled()) { logger.debug("created document id [" + documentId + "]"); } return documentId; }
From source file:nz.co.senanque.messaging.ErrorEndpoint.java
public void processErrorMessage(final Message<MessagingException> message) { MessageHeaders messageHeaders = message.getHeaders(); final MessagingException messagingException = (MessagingException) message.getPayload(); Long correlationId = message.getHeaders().get(IntegrationMessageHeaderAccessor.CORRELATION_ID, Long.class); if (correlationId == null) { correlationId = messagingException.getFailedMessage().getHeaders() .get(IntegrationMessageHeaderAccessor.CORRELATION_ID, Long.class); }/*w w w . j av a 2 s . c o m*/ log.debug("ProcessInstance: correlationId {}", correlationId); if (correlationId == null) { log.error("correlation Id is null"); throw new WorkflowException("correlation Id is null"); } final ProcessInstance processInstance = getWorkflowDAO().findProcessInstance(correlationId); if (processInstance == null) { throw new WorkflowException("Failed to find processInstance for " + correlationId); } getBundleSelector().selectBundle(processInstance); List<Lock> locks = ContextUtils.getLocks(processInstance, getLockFactory(), "nz.co.senanque.messaging.ErrorEndpoint.processErrorMessage"); LockTemplate lockTemplate = new LockTemplate(locks, new LockAction() { public void doAction() { if (processInstance.getStatus() != TaskStatus.WAIT) { throw new WorkflowException("Process is not in a wait state"); } getWorkflowManager().processMessage(processInstance, message, getMessageMapper()); } }); if (!lockTemplate.doAction()) { throw new WorkflowRetryableException("Failed to get a lock"); // This will be retried } }
From source file:org.thingsplode.server.bus.executors.AbstractRequestResponseExecutor.java
public Message<?> execute(Message<?> msg) { AbstractRequest req = (AbstractRequest) msg.getPayload(); try {/*from ww w. ja v a2 s .c o m*/ RSP response = executeImpl((REQ) msg.getPayload(), msg.getHeaders(), getDeviceRepo().findByIdentification(req.getDeviceId())); if (response != null) { return MessageBuilder.withPayload(configureCommonFields(req, response)).build(); } else { return MessageBuilder .withPayload(configureCommonFields(req, new Response<>(req.getMessageId(), ExecutionStatus.DECLINED, ResponseCode.REQUIRED_RESPONSE_IS_MISSING, "return payload value is null"))) .build(); } } catch (SrvExecutionException ex) { logger.error(ex.getMessage(), ex); //msgTemplate.send(MessageBuilder.withPayload(new ErrorMessage(ex.getExecutionStatus(), ex.getResponseCode(), ex)).build()); return MessageBuilder.withPayload(configureCommonFields(req, new Response<>(req.getMessageId(), ex.getExecutionStatus(), ex.getResponseCode(), ex.getMessage()))).build(); } catch (Exception ex) { logger.error(ex.getMessage(), ex); //msgTemplate.send(MessageBuilder.withPayload(new ErrorMessage(ExecutionStatus.DECLINED, ResponseCode.INTERNAL_SYSTEM_ERROR, ex)).build()); return MessageBuilder .withPayload(configureCommonFields(req, new Response<>(req.getMessageId(), ExecutionStatus.DECLINED, determineResponseCode(ex), determineExceptionMessage(ex)))) .build(); } }
From source file:opensnap.security.SecurityChannelInterceptor.java
@Override public Message<?> preSend(Message<?> message, MessageChannel channel) { UsernamePasswordAuthenticationToken authentication = (UsernamePasswordAuthenticationToken) message .getHeaders().get(SimpMessageHeaderAccessor.USER_HEADER); String destination = (String) message.getHeaders().get(SimpMessageHeaderAccessor.DESTINATION_HEADER); if ((destination == null) || isAllowed(destination, authentication.getName())) { return message; }/* w w w . ja v a 2 s. c o m*/ throw new AccessDeniedException( "Message to destination " + destination + " not allowed for user " + authentication.getName()); }