本文整理汇总了Java中org.springframework.cloud.stream.messaging.Sink.INPUT属性的典型用法代码示例。如果您正苦于以下问题:Java Sink.INPUT属性的具体用法?Java Sink.INPUT怎么用?Java Sink.INPUT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.springframework.cloud.stream.messaging.Sink
的用法示例。
在下文中一共展示了Sink.INPUT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
@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);
}
}
示例2: shipGoodsCommandReceived
@StreamListener(target = Sink.INPUT,
condition="payload.messageType.toString()=='ShipGoodsCommand'")
@Transactional
public void shipGoodsCommandReceived(String messageJson) throws Exception {
Message<ShipGoodsCommandPayload> message = new ObjectMapper().readValue(messageJson, new TypeReference<Message<ShipGoodsCommandPayload>>(){});
String shipmentId = shippingService.createShipment( //
message.getPayload().getPickId(), //
message.getPayload().getRecipientName(), //
message.getPayload().getRecipientAddress(), //
message.getPayload().getLogisticsProvider());
messageSender.send( //
new Message<GoodsShippedEventPayload>( //
"GoodsShippedEvent", //
message.getTraceId(), //
new GoodsShippedEventPayload() //
.setRefId(message.getPayload().getRefId())
.setShipmentId(shipmentId)));
}
示例3: retrievePaymentCommandReceived
@StreamListener(target = Sink.INPUT,
condition="payload.messageType.toString()=='RetrievePaymentCommand'")
@Transactional
public void retrievePaymentCommandReceived(String messageJson) throws JsonParseException, JsonMappingException, IOException {
Message<RetrievePaymentCommandPayload> message = new ObjectMapper().readValue(messageJson, new TypeReference<Message<RetrievePaymentCommandPayload>>(){});
RetrievePaymentCommandPayload retrievePaymentCommand = message.getPayload();
System.out.println("Retrieve payment: " + retrievePaymentCommand.getAmount() + " for " + retrievePaymentCommand.getRefId());
camunda.getRuntimeService().createMessageCorrelation(message.getMessageType()) //
.processInstanceBusinessKey(message.getTraceId())
.setVariable("amount", retrievePaymentCommand.getAmount()) //
.setVariable("remainingAmount", retrievePaymentCommand.getAmount()) //
.setVariable("refId", retrievePaymentCommand.getRefId()) //
.correlateWithResult();
}
示例4: orderPlacedReceived
/**
* Handles incoming OrderPlacedEvents.
*
* Using the conditional {@link StreamListener} from
* https://github.com/spring-cloud/spring-cloud-stream/blob/master/spring-cloud-stream-core-docs/src/main/asciidoc/spring-cloud-stream-overview.adoc
* in a way close to what Axion
* would do (see e.g. https://dturanski.wordpress.com/2017/03/26/spring-cloud-stream-for-event-driven-architectures/)
*/
@StreamListener(target = Sink.INPUT,
condition="payload.messageType.toString()=='OrderPlacedEvent'")
@Transactional
public void orderPlacedReceived(String messageJson) throws JsonParseException, JsonMappingException, IOException {
Message<Order> message = new ObjectMapper().readValue(messageJson, new TypeReference<Message<Order>>(){});
Order order = message.getPayload();
System.out.println("New order placed, start flow. " + order);
// persist domain entity
repository.persistOrder(order);
// and kick of a new flow instance
camunda.getRuntimeService().createMessageCorrelation(message.getMessageType())
.processInstanceBusinessKey(message.getTraceId())
.setVariable("orderId", order.getId())
.correlateWithResult();
}
示例5: retrievePaymentCommandReceived
@StreamListener(target = Sink.INPUT,
condition="payload.messageType.toString()=='FetchGoodsCommand'")
@Transactional
public void retrievePaymentCommandReceived(String messageJson) throws JsonParseException, JsonMappingException, IOException {
Message<FetchGoodsCommandPayload> message = new ObjectMapper().readValue(messageJson, new TypeReference<Message<FetchGoodsCommandPayload>>(){});
FetchGoodsCommandPayload fetchGoodsCommand = message.getPayload();
String pickId = inventoryService.pickItems( //
fetchGoodsCommand.getItems(), fetchGoodsCommand.getReason(), fetchGoodsCommand.getRefId());
messageSender.send( //
new Message<GoodsFetchedEventPayload>( //
"GoodsFetchedEvent", //
message.getTraceId(), //
new GoodsFetchedEventPayload() //
.setRefId(fetchGoodsCommand.getRefId())
.setPickId(pickId)));
}
示例6: messageReceived
@StreamListener(target = Sink.INPUT)
@Transactional
public void messageReceived(String messageJson) throws Exception {
Message<JsonNode> message = new ObjectMapper().readValue( //
messageJson, //
new TypeReference<Message<JsonNode>>() {});
String type = "Event";
if (message.getMessageType().endsWith("Command")) {
type = "Command";
}
PastEvent event = new PastEvent( //
type, //
message.getMessageType(), //
message.getTraceId(), //
message.getSender(), //
message.getPayload().toString());
// save
LogRepository.instance.addEvent(event);
// and probably send to connected websocket (TODO: Not a good place for the code here!)
simpMessageTemplate.convertAndSend("/topic/events", event);
}
示例7: redisSinkMessageHandler
@Bean
@ServiceActivator(inputChannel = Sink.INPUT)
public MessageHandler redisSinkMessageHandler() {
if (this.redisSinkProperties.isKey()) {
RedisStoreWritingMessageHandler redisStoreWritingMessageHandler = new RedisStoreWritingMessageHandler(
this.redisConnectionFactory);
redisStoreWritingMessageHandler.setKeyExpression(this.redisSinkProperties.keyExpression());
return redisStoreWritingMessageHandler;
}
else if (this.redisSinkProperties.isQueue()) {
return new RedisQueueOutboundChannelAdapter(this.redisSinkProperties.queueExpression(),
this.redisConnectionFactory);
}
else { // must be topic
RedisPublishingMessageHandler redisPublishingMessageHandler = new RedisPublishingMessageHandler(
this.redisConnectionFactory);
redisPublishingMessageHandler.setTopicExpression(this.redisSinkProperties.topicExpression());
return redisPublishingMessageHandler;
}
}
示例8: process
@ServiceActivator(inputChannel = Sink.INPUT)
public void process(Message<?> message) {
Object payload = message.getPayload();
if (payload instanceof String) {
try {
payload = jsonToTupleTransformer.transformPayload(payload.toString());
}
catch (Exception e) {
throw new MessageTransformationException(message, e.getMessage(), e);
}
}
if (payload instanceof Tuple) {
processTuple(computeMetricName(message), (Tuple) payload);
}
else {
processPojo(computeMetricName(message), payload);
}
}
开发者ID:spring-cloud-stream-app-starters,项目名称:field-value-counter,代码行数:18,代码来源:FieldValueCounterSinkConfiguration.java
示例9: websocketSink
@ServiceActivator(inputChannel = Sink.INPUT)
public void websocketSink(Message<?> message) {
if (logger.isTraceEnabled()) {
logger.trace(String.format("Handling message: %s", message));
}
SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.wrap(message);
headers.setMessageTypeIfNotSet(SimpMessageType.MESSAGE);
String messagePayload = message.getPayload().toString();
for (Channel channel : WebsocketSinkServer.channels) {
if (logger.isTraceEnabled()) {
logger.trace(String.format("Writing message %s to channel %s", messagePayload, channel.localAddress()));
}
channel.write(new TextWebSocketFrame(messagePayload));
channel.flush();
}
if (traceEndpointEnabled) {
addMessageToTraceRepository(message);
}
}
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:22,代码来源:WebsocketSinkConfiguration.java
示例10: process
@ServiceActivator(inputChannel=Sink.INPUT)
public void process(Message<?> message) {
Object payload = message.getPayload();
if (payload instanceof String) {
try {
payload = jsonToTupleTransformer.transformPayload(payload.toString());
}
catch (Exception e) {
throw new MessageTransformationException(message, e.getMessage(), e);
}
}
if (payload instanceof Tuple) {
processTuple(computeMetricName(message), (Tuple) payload);
}
else {
processPojo(computeMetricName(message), payload);
}
}
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:18,代码来源:FieldValueCounterSinkConfiguration.java
示例11: amazonS3MessageHandler
@Bean
@ServiceActivator(inputChannel = Sink.INPUT)
public MessageHandler amazonS3MessageHandler(AmazonS3 amazonS3, ResourceIdResolver resourceIdResolver,
AmazonS3SinkProperties s3SinkProperties) {
S3MessageHandler s3MessageHandler;
if (s3SinkProperties.getBucket() != null) {
s3MessageHandler = new S3MessageHandler(amazonS3, s3SinkProperties.getBucket());
}
else {
s3MessageHandler = new S3MessageHandler(amazonS3, s3SinkProperties.getBucketExpression());
}
s3MessageHandler.setResourceIdResolver(resourceIdResolver);
s3MessageHandler.setKeyExpression(s3SinkProperties.getKeyExpression());
if (s3SinkProperties.getAcl() != null) {
s3MessageHandler.setObjectAclExpression(new ValueExpression<>(s3SinkProperties.getAcl()));
}
else {
s3MessageHandler.setObjectAclExpression(s3SinkProperties.getAclExpression());
}
s3MessageHandler.setUploadMetadataProvider(this.uploadMetadataProvider);
s3MessageHandler.setProgressListener(this.s3ProgressListener);
return s3MessageHandler;
}
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:23,代码来源:AmazonS3SinkConfiguration.java
示例12: broadcast
@StreamListener(Sink.INPUT)
public void broadcast(Comment comment) {
if (webSocketCommentSink != null) {
log.info("Publishing " + comment.toString() +
" to websocket...");
webSocketCommentSink.next(comment);
}
}
示例13: validateEmployee
@ServiceActivator(inputChannel=Sink.INPUT)
public void validateEmployee(Integer deptId) {
Department dept = null;
try{
dept = departmentServiceImpl.findDeptByid(deptId);
}catch(Exception e){
dept = new Department();
dept.setName("Non-existent");
}
log.info("{}", dept.getName());
}
示例14: addDepartment
@ServiceActivator(inputChannel=Sink.INPUT)
public void addDepartment(Department dept) {
try{
departmentServiceImpl.saveDeptRec(dept);
}catch(Exception e){
log.info("{}", e.getMessage());
}
log.info("{}", dept.getName());
}
示例15: updatePayment
@ServiceActivator(inputChannel = Sink.INPUT)
public void updatePayment(Payment payment) throws Exception {
log.info("Payment received for orderId: " + payment.getOrderId());
paymentService.processPayment(payment);
//consume payment data in queue
//同时将payment发到updater
}