46
46
import com .fasterxml .jackson .databind .JsonNode ;
47
47
48
48
/**
49
- * The {@link HttpRequestHandlingMessagingGateway} extension for the Amazon WS SNS HTTP(S) endpoints.
50
- * Accepts all {@code x-amz-sns-message-type}s, converts the received Topic JSON message to the
51
- * {@link Map} using {@link MappingJackson2HttpMessageConverter} and send it to the provided
52
- * {@link #getRequestChannel()} as {@link Message} {@code payload}.
49
+ * The {@link HttpRequestHandlingMessagingGateway} extension for the Amazon WS SNS HTTP(S)
50
+ * endpoints. Accepts all {@code x-amz-sns-message-type}s, converts the received Topic
51
+ * JSON message to the {@link Map} using {@link MappingJackson2HttpMessageConverter} and
52
+ * send it to the provided {@link #getRequestChannel()} as {@link Message}
53
+ * {@code payload}.
53
54
* <p>
54
- * The mapped url must be configured inside the Amazon Web Service platform as a subscription.
55
- * Before receiving any notification itself this HTTP endpoint must confirm the subscription.
55
+ * The mapped url must be configured inside the Amazon Web Service platform as a
56
+ * subscription. Before receiving any notification itself this HTTP endpoint must confirm
57
+ * the subscription.
56
58
* <p>
57
59
* The {@link #handleNotificationStatus} flag (defaults to {@code false}) indicates that
58
60
* this endpoint should send the {@code SubscriptionConfirmation/UnsubscribeConfirmation}
59
- * messages to the the provided {@link #getRequestChannel()}.
60
- * If that, the {@link AwsHeaders#NOTIFICATION_STATUS} header is populated
61
- * with the {@link NotificationStatus} value. In that case it is a responsibility of
62
- * the application to {@link NotificationStatus#confirmSubscription()} or not.
61
+ * messages to the the provided {@link #getRequestChannel()}. If that, the
62
+ * {@link AwsHeaders#NOTIFICATION_STATUS} header is populated with the
63
+ * {@link NotificationStatus} value. In that case it is a responsibility of the
64
+ * application to {@link NotificationStatus#confirmSubscription()} or not.
63
65
* <p>
64
- * By default this endpoint just does {@link NotificationStatus#confirmSubscription()}
65
- * for the {@code SubscriptionConfirmation} message type.
66
- * And does nothing for the {@code UnsubscribeConfirmation}.
66
+ * By default this endpoint just does {@link NotificationStatus#confirmSubscription()} for
67
+ * the {@code SubscriptionConfirmation} message type. And does nothing for the
68
+ * {@code UnsubscribeConfirmation}.
67
69
* <p>
68
- * For the convenience on the underlying message flow routing a {@link AwsHeaders#SNS_MESSAGE_TYPE}
69
- * header is present.
70
+ * For the convenience on the underlying message flow routing a
71
+ * {@link AwsHeaders#SNS_MESSAGE_TYPE} header is present.
70
72
*
71
73
* @author Artem Bilan
72
74
* @author Kamil Przerwa
@@ -75,8 +77,7 @@ public class SnsInboundChannelAdapter extends HttpRequestHandlingMessagingGatewa
75
77
76
78
private final NotificationStatusResolver notificationStatusResolver ;
77
79
78
- private final MappingJackson2HttpMessageConverter jackson2HttpMessageConverter =
79
- new MappingJackson2HttpMessageConverter ();
80
+ private final MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter ();
80
81
81
82
private volatile boolean handleNotificationStatus ;
82
83
@@ -94,8 +95,8 @@ public SnsInboundChannelAdapter(AmazonSNS amazonSns, String... path) {
94
95
requestMapping .setMethods (HttpMethod .POST );
95
96
requestMapping .setHeaders ("x-amz-sns-message-type" );
96
97
requestMapping .setPathPatterns (path );
97
- this .jackson2HttpMessageConverter . setSupportedMediaTypes (
98
- Arrays .asList (MediaType .APPLICATION_JSON_UTF8 , MediaType .TEXT_PLAIN ));
98
+ this .jackson2HttpMessageConverter
99
+ . setSupportedMediaTypes ( Arrays .asList (MediaType .APPLICATION_JSON , MediaType .TEXT_PLAIN ));
99
100
super .setRequestMapping (requestMapping );
100
101
super .setStatusCodeExpression (new ValueExpression <>(HttpStatus .NO_CONTENT ));
101
102
super .setMessageConverters (Collections .singletonList (this .jackson2HttpMessageConverter ));
@@ -148,8 +149,9 @@ protected void send(Object object) {
148
149
return ;
149
150
}
150
151
}
151
- messageToSendBuilder .setHeader (AwsHeaders .SNS_MESSAGE_TYPE , type )
152
- .setHeader (AwsHeaders .MESSAGE_ID , payload .get ("MessageId" ));
152
+ messageToSendBuilder .setHeader (AwsHeaders .SNS_MESSAGE_TYPE , type ).setHeader (AwsHeaders .MESSAGE_ID ,
153
+ payload .get ("MessageId" ));
154
+
153
155
super .send (messageToSendBuilder .build ());
154
156
}
155
157
@@ -203,7 +205,6 @@ public void setStatusCodeExpression(Expression statusCodeExpression) {
203
205
throw new UnsupportedOperationException ();
204
206
}
205
207
206
-
207
208
private static class NotificationStatusResolver extends NotificationStatusHandlerMethodArgumentResolver {
208
209
209
210
NotificationStatusResolver (AmazonSNS amazonSns ) {
0 commit comments