当前位置: 首页>>代码示例>>Java>>正文


Java Message.getPayload方法代码示例

本文整理汇总了Java中org.springframework.messaging.Message.getPayload方法的典型用法代码示例。如果您正苦于以下问题:Java Message.getPayload方法的具体用法?Java Message.getPayload怎么用?Java Message.getPayload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.messaging.Message的用法示例。


在下文中一共展示了Message.getPayload方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: restOutbound

import org.springframework.messaging.Message; //导入方法依赖的package包/类
@ServiceActivator(inputChannel = "outbound-rest", outputChannel = "mark-outboud")
public String restOutbound(Message<?> msg) {
	try {
		ExportString exportString = (ExportString) msg.getPayload();
		logger.debug("message arrived at REST outbound sender: " + exportString.getEventId());
		Addressable addressable = exportString.getRegistration().getAddressable();
		String uri = addressable.getAddress() + ":" + addressable.getPort() + addressable.getPath();
		HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler(uri);
		handler.setHttpMethod(HttpMethod.POST);
		handler.setExpectReply(false);
		Message<String> message = MessageBuilder.withPayload(exportString.getEventString()).build();
		handler.handleMessage(message);
		logger.info("message sent to REST address:  " + uri + " : " + exportString.getEventId());
		return exportString.getEventId();
	} catch (Exception e) {
		logger.error("Problem with sending message via REST: " + e.getMessage());
		return null;
	}
}
 
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:20,代码来源:RESTOutboundServiceActivator.java

示例2: zmqOutbound

import org.springframework.messaging.Message; //导入方法依赖的package包/类
@ServiceActivator(inputChannel = "outbound-zmq", outputChannel = "mark-outboud")
public String zmqOutbound(Message<?> msg) {
	try {
		ExportString exportString = (ExportString) msg.getPayload();
		logger.debug("message arrived at 0MQ outbound sender: " + exportString.getEventId());
		// today, for ZMQ, subscribers will listen to pre-subscribed EdgeX
		// ZMQ outbound port.
		// TODO - someday, reverse the direction and allow clients to set up
		// individual ZMQ port to publish out of
		logger.debug(".....sending: " + exportString.getEventString());
		sendor.sendEventMessage(exportString.getEventString());
		// logger.error("--->" + exportString.getEventId() + " [email protected]
		// " + System.currentTimeMillis());
		logger.info("message sent via 0MQ " + exportString.getEventId());
		return exportString.getEventId();
	} catch (Exception e) {
		logger.error("Problem with sending message via 0MQ: " + e.getMessage());
	}
	return null;
}
 
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:21,代码来源:ZMQOutboundServiceActivator.java

示例3: mqttOutbound

import org.springframework.messaging.Message; //导入方法依赖的package包/类
@ServiceActivator(inputChannel = "outbound-azure", outputChannel = "mark-outboud")
public String mqttOutbound(Message<?> msg) {
	try {
		ExportString exportString = (ExportString) msg.getPayload();
		logger.debug("message arrived at Azure MQTT outbound sender: " + exportString.getEventId());
		Addressable addressable = exportString.getRegistration().getAddressable();
		if (addressable != null) {
			// TODO - someday cache and reuse clients
			AzureMQTTSender sender = new AzureMQTTSender(exportString.getRegistration().getAddressable(),
					exportString.getDeviceId());
			sender.sendMessage(exportString.getEventString().getBytes());
			logger.info("message sent to Azure MQTT broker:  " + exportString.getRegistration().getAddressable()
					+ " : " + exportString.getEventId());
			return exportString.getEventId();
		} else
			logger.error(
					"No MQTT address information provided with registration.  Event message not sent for client.");
	} catch (Exception e) {
		logger.error("Problem with sending message via MQTT: " + e.getMessage());
	}
	return null;
}
 
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:23,代码来源:AzureMQTTOutboundServiceActivator.java

示例4: splitMessage

import org.springframework.messaging.Message; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
@Splitter(inputChannel = "valid-inbound-events", outputChannel = "inbound-eventmessages")
public Object splitMessage(Message<?> msg) {
	try {
		Message<Event> eventMsg = (Message<Event>) msg;
		Event event = eventMsg.getPayload();
		logger.debug("message arrived at client message splitter: " + event.getId());
		List<ExportRegistration> clients = getClients();
		Object o = clients.stream().map(c -> createExportMessage(c, event)).collect(Collectors.toList());
		logger.debug("message leaving client message splitter: " + event.getId());
		return o;
	} catch (Exception e) {
		logger.error("problem splitting messages per client request:  " + e.getMessage());
		throw e;
	}
}
 
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:18,代码来源:ClientMessageSplitter.java

示例5: splitMessage

import org.springframework.messaging.Message; //导入方法依赖的package包/类
@Override
@Splitter(inputChannel = "device-filtered-eventmessages", outputChannel = "reading-filtered-eventmessages")
public Object splitMessage(Message<?> msg) {
	try {
		ExportMessage exportMsg = (ExportMessage) msg.getPayload();
		logger.debug("message arrived at value description filter/splitter: " + exportMsg.getEvent().getId());
		ExportFilter filter = exportMsg.getRegistration().getFilter();
		if (filter != null && filter.getValueDescriptorIdentifiers() != null
				&& (!filter.getValueDescriptorIdentifiers().isEmpty())) {
			return filterReadings(exportMsg, filter.getValueDescriptorIdentifiers());
		}
		logger.debug("message leaving value description filter/splitter: " + exportMsg.getEvent().getId());
		return exportMsg;
	} catch (Exception e) {
		logger.error("problem removing non-relevant readings based on value descriptor:  " + e.getMessage());
		throw e;
	}
}
 
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:19,代码来源:ValueDescriptorSplitter.java

示例6: tensorflowInputConverter

import org.springframework.messaging.Message; //导入方法依赖的package包/类
@Bean
@ConditionalOnMissingBean(name = "tensorflowInputConverter")
public TensorflowInputConverter tensorflowInputConverter() {
	return new TensorflowInputConverter() {

		@Override
		public Map<String, Object> convert(Message<?> input, Map<String, Object> processorContext) {

			if (input.getHeaders().containsKey(TF_INPUT_HEADER)) {
				return (Map<String, Object>) input.getHeaders().get(TF_INPUT_HEADER, Map.class);
			}
			else if (input.getPayload() instanceof Map) {
				return (Map<String, Object>) input.getPayload();
			}

			throw new RuntimeException("Unsupported input format: " + input);

		}
	};
}
 
开发者ID:tzolov,项目名称:tensorflow-spring-cloud-stream-app-starters,代码行数:21,代码来源:TensorflowProcessorConfiguration.java

示例7: convert

import org.springframework.messaging.Message; //导入方法依赖的package包/类
@Override
public Map<String, Object> convert(Message<?> input, Map<String, Object> processorContext) {

	try {
		Object payload = input.getPayload();

		if (payload instanceof String) {
			Map tweetJsonMap = objectMapper.readValue((String) payload, Map.class);
			processorContext.put(PROCESSOR_CONTEXT_TWEET_JSON_MAP, tweetJsonMap);
			return getStringObjectMap(tweetJsonMap);
		}
		else if (payload instanceof Map) {
			processorContext.put(PROCESSOR_CONTEXT_TWEET_JSON_MAP, payload);
			return getStringObjectMap((Map) payload);
		}

		throw new IllegalArgumentException("Unsupported payload type:" + input.getPayload());
	}
	catch (IOException e) {
		throw new RuntimeException("Can't parse input tweet json: " + input.getPayload());
	}

}
 
开发者ID:tzolov,项目名称:tensorflow-spring-cloud-stream-app-starters,代码行数:24,代码来源:TwitterSentimentTensorflowInputConverter.java

示例8: accept

import org.springframework.messaging.Message; //导入方法依赖的package包/类
@Override
@Filter(inputChannel = "inbound-eventmessages", outputChannel = "device-filtered-eventmessages")
public boolean accept(Message<?> msg) {
	try {
		boolean accepted = true;
		ExportMessage exportMsg = (ExportMessage) msg.getPayload();
		logger.debug("message arrived at device filter: " + exportMsg.getEvent().getId());
		ExportFilter filter = exportMsg.getRegistration().getFilter();
		if (filter != null && filter.getDeviceIdentifiers() != null && (!filter.getDeviceIdentifiers().isEmpty())) {
			accepted = checkFilters(filter.getDeviceIdentifiers(), exportMsg.getEvent());
		}
		logger.debug("message leaving device filter: " + exportMsg.getEvent().getId());
		return accepted;
	} catch (Exception e) {
		logger.error("Problem with device filter: " + e.getMessage());
		return false;
		//throw e;
	}
}
 
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:20,代码来源:DeviceFilter.java

示例9: transformJSON

import org.springframework.messaging.Message; //导入方法依赖的package包/类
@Transformer(inputChannel = "json-inbound-eventmessages", outputChannel = "outbound-eventstring")
public ExportString transformJSON(Message<?> msg) {
	try {
		ExportMessage exportMsg = (ExportMessage) msg.getPayload();
		String eventId = exportMsg.getEvent().getId();
		logger.debug("message arrived at JSON format transformer: " + eventId);
		ExportString export = new ExportString();
		export.setRegistration(exportMsg.getRegistration(), eventId);
		export.setEventString(eventToJSON(exportMsg.getEvent()));
		logger.debug("message leaving JSON format transformer " + eventId);
		return export;
	} catch (Exception e) {
		logger.error("Problem with JSON format transformation: " + e.getMessage());
		throw e;
	}
}
 
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:17,代码来源:JSONFormatTransformer.java

示例10: transformIotCoreJSON

import org.springframework.messaging.Message; //导入方法依赖的package包/类
@Transformer(inputChannel = "iotcore-json-inbound-eventmessages", outputChannel = "outbound-eventstring")
public ExportString transformIotCoreJSON(Message<?> msg) {
	try {
		ExportMessage exportMsg = (ExportMessage) msg.getPayload();
		String eventId = exportMsg.getEvent().getId();
		logger.debug("message arrived at IoT Core JSON format transformer: " + eventId);
		ExportString export = new ExportString();
		export.setRegistration(exportMsg.getRegistration(), eventId);
		export.setEventString(eventToJSON(exportMsg.getEvent()));
		logger.debug("message leaving IoT Core JSON format transformer " + eventId);
		return export;
	} catch (Exception e) {
		logger.error("Problem with IoT Core JSON format transformation: " + e.getMessage());
		throw e;
	}
}
 
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:17,代码来源:JSONFormatTransformer.java

示例11: transformAzureJSON

import org.springframework.messaging.Message; //导入方法依赖的package包/类
@Transformer(inputChannel = "azure-json-inbound-eventmessages", outputChannel = "outbound-eventstring")
public ExportString transformAzureJSON(Message<?> msg) {
	try {
		ExportMessage exportMsg = (ExportMessage) msg.getPayload();
		String eventId = exportMsg.getEvent().getId();
		logger.debug("message arrived at Azure JSON format transformer: " + eventId);
		ExportString export = new ExportString();
		export.setRegistration(exportMsg.getRegistration(), eventId);
		export.setEventString(eventToAzureJSON(exportMsg.getEvent()));
		export.setDeviceId(exportMsg.getEvent().getDevice());
		logger.debug("message leaving Azure JSON format transformer " + eventId);
		return export;
	} catch (Exception e) {
		logger.error("Problem with Azure JSON format transformation: " + e.getMessage());
		throw e;
	}
}
 
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:18,代码来源:JSONFormatTransformer.java

示例12: transform

import org.springframework.messaging.Message; //导入方法依赖的package包/类
@Transformer(inputChannel = "xml-inbound-eventmessages", outputChannel = "outbound-eventstring")
public ExportString transform(Message<?> msg) throws JAXBException {
	try {
		ExportMessage exportMsg = (ExportMessage) msg.getPayload();
		String eventId = exportMsg.getEvent().getId();
		logger.debug("message arrived at XML format transformer: " + eventId);
		ExportString export = new ExportString();
		export.setRegistration(exportMsg.getRegistration(), eventId);
		export.setEventString(eventToXML(exportMsg.getEvent()));
		logger.debug("message leaving XML format transformer " + eventId);
		return export;
	} catch (Exception e) {
		logger.error("Problem with XML format transformation: " + e.getMessage());
		throw e;
	}
}
 
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:17,代码来源:XMLFormatTransformer.java

示例13: transform

import org.springframework.messaging.Message; //导入方法依赖的package包/类
@Transformer(inputChannel = "serial-inbound-eventmessages", outputChannel = "outbound-eventstring")
public ExportString transform(Message<?> msg) throws Exception {
	try {
		ExportMessage exportMsg = (ExportMessage) msg.getPayload();
		String eventId = exportMsg.getEvent().getId();
		logger.debug("message arrived at serialized format transformer: " + eventId);
		ExportString export = new ExportString();
		export.setRegistration(exportMsg.getRegistration(), eventId);
		export.setEventString(toString(exportMsg.getEvent()));
		logger.debug("message leaving Serialized format transformer " + eventId);
		return export;
	} catch (Exception e) {
		logger.error("Problem with Serialized format transformation: " + e.getMessage());
		throw e;
	}
}
 
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:17,代码来源:SerializedFormatTransformer.java

示例14: transform

import org.springframework.messaging.Message; //导入方法依赖的package包/类
@Transformer(inputChannel = "outbound-compressed-eventstring", outputChannel = "outbound-encrypted-eventstring")
public ExportString transform(Message<?> msg) throws Exception {
	try {
		ExportString exportString = (ExportString) msg.getPayload();
		logger.debug("message arrived at encryption transformer: " + exportString.getEventId());
		EncryptionDetails encryptDetails = exportString.getRegistration().getEncryption();
		if (encryptDetails != null) {
			switch (encryptDetails.getEncryptionAlgorithm()) {
			case AES:
				exportString.setEventString(getEncryptedString(exportString.getEventString(),
						encryptDetails.getEncryptionKey(), encryptDetails.getInitializingVector()));
				break;
			case NONE:
				break;
			}
		}
		logger.debug("message leaving encryption transformer " + exportString.getEventId());
		return exportString;
	} catch (Exception e) {
		logger.error("Problem with encryption transformation: " + e.getMessage());
		throw e;
	}
}
 
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:24,代码来源:EncryptionTransformer.java

示例15: handle

import org.springframework.messaging.Message; //导入方法依赖的package包/类
@StreamListener(value = Sink.INPUT)
public void handle(Message<ProjectEvent> message) {
    ProjectEvent projectEvent = message.getPayload();
    log.info("Received new event: " + "{ projectId " + projectEvent.getProjectId() + " -> " +
            projectEvent.getType() + " }");

    if (projectEvent.getType() == ProjectEventType.CREATED_EVENT) {
        try {
            commitProcessor.importCommits(projectEvent);
        } catch (IOException e) {
            throw new RuntimeException("Could not import GitHub project", e);
        }
    }

    if (projectEvent.getType() == ProjectEventType.COMMIT_EVENT) {
        // Update query models
        LambdaResponse<Map<String, Object>> response =
                projectQueries.getTightCoupling().apply(projectEvent);
    }
}
 
开发者ID:kbastani,项目名称:service-block-samples,代码行数:21,代码来源:EventProcessor.java


注:本文中的org.springframework.messaging.Message.getPayload方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。