Github user mdunker commented on a diff in the pull request:
https://github.com/apache/usergrid/pull/575#discussion_r141446957
--- Diff:
stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SNSQueueManagerImpl.java
---
@@ -541,7 +541,49 @@ public long getQueueDepth() {
@Override
- public <T extends Serializable> void sendMessageToAllRegions(final T
body ) throws IOException {
+ public <T extends Serializable> void sendMessageToAllRegions(final T
body, Boolean async) throws IOException {
+ boolean sendAsync = async == null ? fig.isAsyncQueue() :
async.booleanValue();
+ if (sendAsync) {
+ sendMessageToAllRegionsAsync(body);
+ } else {
+ sendMessageToAllRegionsSync(body);
+ }
+ }
+
+
+ private <T extends Serializable> void
sendMessageToAllRegionsSync(final T body) throws IOException {
+ if ( sns == null ) {
+ logger.error( "SNS client is null, perhaps it failed to
initialize successfully" );
+ return;
+ }
+
+ final String stringBody = toString( body );
+
+ String topicArn = getWriteTopicArn();
+
+ if ( logger.isTraceEnabled() ) {
+ logger.trace( "Publishing Message...{} to arn: {}",
stringBody, topicArn );
+ }
+
+ try {
+ PublishResult publishResult = sns.publish(topicArn,
toString(body));
+ if ( logger.isTraceEnabled() ) {
+ logger.trace( "Successfully published... messageID=[{}],
arn=[{}]", publishResult.getMessageId(),
+ topicArn );
+ }
+ } catch (Exception e) {
+ if (logger.isErrorEnabled()) {
+ logger.error("Failed to send this message {} to SNS queue
at {}", stringBody, topicArn);
--- End diff --
"Failed to send this message [{}] to SNS queue at {}, sending
asynchronously" -- should this be logger.info?
Or maybe we should have same format in all these logs for ease of parsing
if we need to use a cron job?
"FAILED INDEX REQUEST: Failed to send message to SNS Queue, sending
asynchronously. Message:[{}] URL:[{}]"
---