This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.amazonaws.services.s3.model.CannedAccessControlList; | |
import com.amazonaws.services.s3.model.DeleteObjectRequest; | |
import com.amazonaws.services.s3.model.PutObjectRequest; | |
import com.springbootdev.amazon.s3.example.aws.service.AmazonS3ClientService; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.scheduling.annotation.Async; | |
import org.springframework.stereotype.Component; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface AmazonS3ClientService | |
{ | |
void uploadFileToS3Bucket(MultipartFile multipartFile, boolean enablePublicReadAccess); | |
void deleteFileFromS3Bucket(String fileName); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.beans.factory.annotation.Value; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import com.amazonaws.auth.AWSCredentialsProvider; | |
import com.amazonaws.auth.AWSStaticCredentialsProvider; | |
import com.amazonaws.auth.BasicAWSCredentials; | |
import com.amazonaws.regions.Region; | |
import com.amazonaws.regions.Regions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Slf4j | |
@EnableBinding(OrderSink.class) | |
public class OrderListener | |
{ | |
@StreamListener(target = OrderSink.INPUT,condition = "headers['payment_mode']=='cash'") | |
public void listenForCashOrder(Order order) | |
{ | |
log.info(" received new CASH order {} ",order.toString()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Slf4j | |
@EnableBinding(OrderSource.class) | |
@RestController | |
public class OrderController | |
{ | |
@Autowired | |
private OrderSource source; | |
@PostMapping("/orders/publish") | |
public String publishOrder(@RequestBody Order order, @RequestParam("payment_mode") String paymentMode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lombok.extern.slf4j.Slf4j; | |
import org.springframework.cloud.stream.annotation.EnableBinding; | |
import org.springframework.cloud.stream.annotation.StreamListener; | |
@Slf4j | |
@EnableBinding(OrderSink.class) | |
public class OrderListener | |
{ | |
@StreamListener(target = OrderSink.INPUT) | |
public void listenForOrder(Order order) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.cloud.stream.annotation.Input; | |
import org.springframework.messaging.SubscribableChannel; | |
public interface OrderSink | |
{ | |
String INPUT = "orderReceiveChannel"; | |
@Input(INPUT) | |
SubscribableChannel receive(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Slf4j | |
@EnableBinding(OrderSource.class) | |
@RestController | |
public class OrderController | |
{ | |
@Autowired | |
private OrderSource source; | |
@PostMapping("/orders/publish") | |
public String publishOrder(@RequestBody Order order) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.cloud.stream.annotation.Output; | |
import org.springframework.messaging.MessageChannel; | |
public interface OrderSource | |
{ | |
String OUTPUT = "orderPublishChannel"; | |
@Output(OUTPUT) | |
MessageChannel create(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import org.springframework.cloud.stream.annotation.EnableBinding; | |
import org.springframework.cloud.stream.annotation.StreamListener; | |
import org.springframework.cloud.stream.messaging.Sink; | |
@EnableBinding(Sink.class) | |
public class OrderListener | |
{ | |
private static final Logger logger = LoggerFactory.getLogger(OrderListener.class); |