本文整理汇总了Java中org.springframework.cloud.stream.messaging.Processor.OUTPUT属性的典型用法代码示例。如果您正苦于以下问题:Java Processor.OUTPUT属性的具体用法?Java Processor.OUTPUT怎么用?Java Processor.OUTPUT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.springframework.cloud.stream.messaging.Processor
的用法示例。
在下文中一共展示了Processor.OUTPUT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFilename
@Bean
@Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public MessageProcessor<?> transformer() {
String language = this.properties.getLanguage();
String script = this.properties.getScript();
logger.info(String.format("Input script is '%s', language is '%s'", script, language));
Resource scriptResource = new ByteArrayResource(decodeScript(script).getBytes()) {
// TODO until INT-3976
@Override
public String getFilename() {
// Only the groovy script processor enforces this requirement for a name
return "StaticScript";
}
};
return Scripts.script(scriptResource)
.lang(language)
.variableGenerator(this.scriptVariableGenerator)
.get();
}
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:21,代码来源:ScriptableTransformProcessorConfiguration.java
示例2: setupRequest
@Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public Object setupRequest(String message) {
Map<String, String> properties = new HashMap<String,String>();
if(StringUtils.hasText(processorProperties.getDataSourceUrl())){
properties.put("spring_datasource_url",processorProperties.getDataSourceUrl());
}
if(StringUtils.hasText(processorProperties.getDataSourceDriverClassName())){
properties.put("spring_datasource_driverClassName",processorProperties.getDataSourceDriverClassName());
}
if(StringUtils.hasText(processorProperties.getDataSourceUserName())){
properties.put("spring_datasource_username",processorProperties.getDataSourceUserName());
}
if(StringUtils.hasText(processorProperties.getDataSourcePassword())){
properties.put("spring_datasource_password",processorProperties.getDataSourcePassword());
}
properties.put("payload", message);
TaskLaunchRequest request = new TaskLaunchRequest(
processorProperties.getUri(), null, properties, null,
processorProperties.getApplicationName());
return new GenericMessage<TaskLaunchRequest>(request);
}
示例3: save
@StreamListener
@Output(Processor.OUTPUT)
public Flux<Comment> save(@Input(Processor.INPUT) Flux<Comment> newComment) {
return repository
.saveAll(newComment)
.map(comment -> {
meterRegistry
.counter("comments.consumed", "imageId", comment.getImageId())
.increment();
return comment;
});
}
示例4: save
@StreamListener
@Output(Processor.OUTPUT)
public Flux<Comment> save(@Input(Processor.INPUT) Flux<Comment> newComment) {
return repository
.saveAll(newComment)
.map(comment -> {
log.info("Saving new comment " + comment);
meterRegistry
.counter("comments.consumed", "imageId", comment.getImageId())
.increment();
return comment;
});
}
示例5: save
@StreamListener
@Output(Processor.OUTPUT)
public Flux<Void> save(@Input(Processor.INPUT) Flux<Comment> newComment) {
return repository
.saveAll(newComment)
.flatMap(comment -> {
meterRegistry
.counter("comments.consumed", "imageId", comment.getImageId())
.increment();
return Mono.empty();
});
}
示例6: verifyEmpString
@StreamListener
@Output(Processor.OUTPUT)
public Flux<String> verifyEmpString(@Input(Processor.INPUT) Flux<String> id) {
System.out.println("first");
id.delayElements(Duration.ofMillis(2))
.log();
return id;
}
示例7: evaluate
@ServiceActivator(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public Message<?> evaluate(Message<?> input) {
Map<String, Object> processorContext = new ConcurrentHashMap<>();
Map<String, Object> inputData = tensorflowInputConverter.convert(input, processorContext);
Tensor outputTensor = tensorFlowService.evaluate(
inputData, properties.getOutputName(), properties.getOutputIndex());
Object outputData = tensorflowOutputConverter.convert(outputTensor, processorContext);
if (properties.isSaveOutputInHeader()) {
// Add the result to the message header
return MessageBuilder
.withPayload(input.getPayload())
.copyHeadersIfAbsent(input.getHeaders())
.setHeaderIfAbsent(TF_OUTPUT_HEADER, outputData)
.build();
}
// Add the outputData as part of the message payload
Message<?> outputMessage = MessageBuilder
.withPayload(outputData)
.copyHeadersIfAbsent(input.getHeaders())
.build();
return outputMessage;
}
开发者ID:tzolov,项目名称:tensorflow-spring-cloud-stream-app-starters,代码行数:29,代码来源:TensorflowProcessorConfiguration.java
示例8: toUpperCase
@StreamListener
@Output(Processor.OUTPUT)
public Flux<String> toUpperCase(@Input(Processor.INPUT) Flux<String> inbound) {
return inbound.
log()
.window(Duration.ofSeconds(10), Duration.ofSeconds(5))
.flatMap(w -> w.reduce("", (s1,s2)->s1+s2))
.log();
}
开发者ID:spring-cloud,项目名称:spring-cloud-stream-samples,代码行数:9,代码来源:ReactiveKafkaProcessorApplication.java
示例9: receive
@StreamListener(Processor.INPUT)
@SendTo(Processor.OUTPUT)
public Bar receive(Bar barMessage) {
System.out.println("******************");
System.out.println("At the transformer");
System.out.println("******************");
System.out.println("Received value "+ barMessage.getValue() + " of type " + barMessage.getClass());
System.out.println("Transforming the value to " + TRANSFORMATION_VALUE + " and with the type " + barMessage.getClass());
barMessage.setValue(TRANSFORMATION_VALUE);
return barMessage;
}
示例10: uppercase
@StreamListener(Processor.INPUT)
@SendTo(Processor.OUTPUT)
public Message<String> uppercase(Message<String> input) {
return MessageBuilder.withPayload(input.getPayload().toUpperCase())
.copyHeadersIfAbsent(input.getHeaders()).setHeader("x-foo", "bar")
.build();
}
开发者ID:spring-cloud,项目名称:spring-cloud-function,代码行数:7,代码来源:HeaderProcessorMessageChannelBinderTests.java
示例11: processor
@StreamListener(Processor.INPUT)
@SendTo(Processor.OUTPUT)
public Observable<String> processor(Observable<String> inputStream) {
return inputStream.map(data -> {
logger.info("Got data = " + data);
return data;
}).buffer(5).map(data -> String.valueOf(avg(data)));
}
示例12: setupRequest
@Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public Object setupRequest(String message) {
Map<String, String> properties = new HashMap<String, String>();
Map<String, String> deploymentProperties = null;
List<String> commandLineArgs = null;
if (StringUtils.hasText(processorProperties.getDataSourceUrl())) {
properties.put("spring_datasource_url", processorProperties.getDataSourceUrl());
}
if (StringUtils.hasText(processorProperties.getDataSourceDriverClassName())) {
properties.put("spring_datasource_driverClassName", processorProperties.getDataSourceDriverClassName());
}
if (StringUtils.hasText(processorProperties.getDataSourceUserName())) {
properties.put("spring_datasource_username", processorProperties.getDataSourceUserName());
}
if (StringUtils.hasText(processorProperties.getDataSourcePassword())) {
properties.put("spring_datasource_password", processorProperties.getDataSourcePassword());
}
if (StringUtils.hasLength(processorProperties.getDeploymentProperties())) {
deploymentProperties = parse(processorProperties.getDeploymentProperties());
}
if (StringUtils.hasLength(processorProperties.getCommandLineArguments())) {
commandLineArgs = parseParams(processorProperties.getCommandLineArguments());
}
TaskLaunchRequest request = new TaskLaunchRequest(
processorProperties.getUri(), commandLineArgs, properties,
deploymentProperties);
return request;
}
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:31,代码来源:TasklaunchrequestTransformProcessorConfiguration.java
示例13: process
@ServiceActivator(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public Object process(Message<?> message) {
try {
/* construct headers */
HttpHeaders headers = new HttpHeaders();
if (properties.getHeadersExpression() != null) {
Map<?, ?> headersMap = properties.getHeadersExpression().getValue(message, Map.class);
for (Entry<?, ?> header : headersMap.entrySet()) {
if (header.getKey() != null && header.getValue() != null) {
headers.add(header.getKey().toString(),
header.getValue().toString());
}
}
}
Class<?> responseType = properties.getExpectedResponseType();
HttpMethod method = properties.getHttpMethod();
String url = properties.getUrlExpression().getValue(message, String.class);
Object body = null;
if (properties.getBody() != null) {
body = properties.getBody();
}
else if (properties.getBodyExpression() != null) {
body = properties.getBodyExpression().getValue(message);
}
else {
body = message.getPayload();
}
URI uri = new URI(url);
RequestEntity<?> request = new RequestEntity<>(body, headers, method, uri);
ResponseEntity<?> response = restTemplate.exchange(request, responseType);
return properties.getReplyExpression().getValue(response);
}
catch (Exception e) {
LOG.warn("Error in HTTP request", e);
return null;
}
}
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:38,代码来源:HttpclientProcessorConfiguration.java
示例14: receive
@StreamListener(Processor.INPUT)
public @SendTo(Processor.OUTPUT) Flux<String> receive(Flux<String> input) {
return input.map(m -> {
if (!m.equals("fail")) {
return m.toUpperCase();
}
else {
throw new RuntimeException();
}
});
}
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:11,代码来源:StreamListenerReactiveReturnWithFailureTests.java
示例15: receive
@StreamListener(Processor.INPUT)
@SendTo(Processor.OUTPUT)
public Message<?> receive(StreamListenerTestUtils.FooPojo fooPojo) {
this.receivedPojos.add(fooPojo);
StreamListenerTestUtils.BarPojo barPojo = new StreamListenerTestUtils.BarPojo();
barPojo.setBar(fooPojo.getFoo());
return MessageBuilder.withPayload(barPojo).setHeader("foo", "bar").build();
}
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:8,代码来源:StreamListenerMethodWithReturnMessageTests.java