本文整理汇总了Java中org.springframework.cloud.stream.messaging.Processor.INPUT属性的典型用法代码示例。如果您正苦于以下问题:Java Processor.INPUT属性的具体用法?Java Processor.INPUT怎么用?Java Processor.INPUT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.springframework.cloud.stream.messaging.Processor
的用法示例。
在下文中一共展示了Processor.INPUT属性的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: 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;
});
}
示例3: 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;
});
}
示例4: 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();
});
}
示例5: 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;
}
示例6: 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
示例7: uppercase
@StreamListener(value = Processor.INPUT, condition = "headers['stream_routekey']=='words'")
public void uppercase(Message<String> input) {
// TODO: this won't work without the Message<?> wrapper for the input because
// the headers don't get copied.
processor.output()
.send(MessageBuilder.withPayload(input.getPayload().toUpperCase())
.copyHeaders(input.getHeaders()).build());
}
开发者ID:spring-cloud,项目名称:spring-cloud-function,代码行数:8,代码来源:SinkWithResponseMessageChannelBinderTests.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: 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
示例10: 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
示例11: receive
@StreamListener(Processor.INPUT)
@SendTo(Processor.OUTPUT)
public StreamListenerTestUtils.BarPojo receive(StreamListenerTestUtils.FooPojo fooMessage) {
this.receivedPojos.add(fooMessage);
StreamListenerTestUtils.BarPojo barPojo = new StreamListenerTestUtils.BarPojo();
barPojo.setBar(fooMessage.getFoo());
return barPojo;
}
示例12: receive
@StreamListener(Processor.INPUT)
public @Output(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
示例13: receive
@StreamListener(Processor.INPUT)
@SendTo(Processor.OUTPUT)
public StreamListenerTestUtils.BarPojo receive(Message<String> fooMessage) {
this.receivedMessages.add(fooMessage);
StreamListenerTestUtils.BarPojo barPojo = new StreamListenerTestUtils.BarPojo();
barPojo.setBar(fooMessage.getPayload());
return barPojo;
}
示例14: receive
@StreamListener
public void receive(@Input(Processor.INPUT) SubscribableChannel input,
@Output(Processor.OUTPUT) final MessageChannel output) {
input.subscribe(new MessageHandler() {
@Override
public void handleMessage(Message<?> message) throws MessagingException {
output.send(MessageBuilder.withPayload(message.getPayload().toString().toUpperCase()).build());
}
});
}
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:10,代码来源:StreamListenerWithAnnotatedInputOutputArgsTests.java
示例15: evaluate
@ServiceActivator(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public Object evaluate(Message<?> input) {
Object inputData =
this.properties.getExpression() == null
? input.getPayload()
: this.properties.getExpression().getValue(this.evaluationContext, input, Object.class);
// The processorContext allows to convey metadata from the Input to Output converter.
Map<String, Object> processorContext = new ConcurrentHashMap<>();
Map<String, Object> inputDataMap = this.tensorflowInputConverter.convert(inputData, processorContext);
Tensor outputTensor = this.tensorFlowService.evaluate(inputDataMap, this.properties.getModelFetch(),
this.properties.getModelFetchIndex());
Object outputData = tensorflowOutputConverter.convert(outputTensor, processorContext);
switch (this.properties.getMode()) {
case tuple:
TupleBuilder outTupleBuilder = TupleBuilder.tuple().put(properties.getOutputName(), outputData);
Object payload = input.getPayload();
if (payload instanceof Tuple && ((Tuple) payload).hasFieldName(ORIGINAL_INPUT_DATA)) {
// If the payload is already a tuple that contains ORIGINAL_INPUT_DATA entry then copy the
// content of the input tuple in the new tuple to be returned.
outTupleBuilder.putAll((Tuple) payload);
}
else {
// This is a new tuple so preserve the input data.
outTupleBuilder.put(ORIGINAL_INPUT_DATA, payload);
}
return outTupleBuilder.build();
case header:
return MessageBuilder
.withPayload(input.getPayload())
.setHeader(this.properties.getOutputName(), outputData);
default:
return outputData;
}
}
开发者ID:spring-cloud-stream-app-starters,项目名称:tensorflow,代码行数:47,代码来源:TensorflowCommonProcessorConfiguration.java