List of usage examples for com.amazonaws.services.sns.model MessageAttributeValue MessageAttributeValue
MessageAttributeValue
From source file:SNSMobilePush.java
License:Open Source License
private static Map<String, MessageAttributeValue> addBaiduNotificationAttributes() { Map<String, MessageAttributeValue> notificationAttributes = new HashMap<String, MessageAttributeValue>(); notificationAttributes.put("AWS.SNS.MOBILE.BAIDU.DeployStatus", new MessageAttributeValue().withDataType("String").withStringValue("1")); notificationAttributes.put("AWS.SNS.MOBILE.BAIDU.MessageKey", new MessageAttributeValue().withDataType("String").withStringValue("default-channel-msg-key")); notificationAttributes.put("AWS.SNS.MOBILE.BAIDU.MessageType", new MessageAttributeValue().withDataType("String").withStringValue("0")); return notificationAttributes; }
From source file:SNSMobilePush.java
License:Open Source License
private static Map<String, MessageAttributeValue> addWNSNotificationAttributes() { Map<String, MessageAttributeValue> notificationAttributes = new HashMap<String, MessageAttributeValue>(); notificationAttributes.put("AWS.SNS.MOBILE.WNS.CachePolicy", new MessageAttributeValue().withDataType("String").withStringValue("cache")); notificationAttributes.put("AWS.SNS.MOBILE.WNS.Type", new MessageAttributeValue().withDataType("String").withStringValue("wns/badge")); return notificationAttributes; }
From source file:SNSMobilePush.java
License:Open Source License
private static Map<String, MessageAttributeValue> addMPNSNotificationAttributes() { Map<String, MessageAttributeValue> notificationAttributes = new HashMap<String, MessageAttributeValue>(); notificationAttributes.put("AWS.SNS.MOBILE.MPNS.Type", new MessageAttributeValue().withDataType("String").withStringValue("token")); // This attribute is required. notificationAttributes.put("AWS.SNS.MOBILE.MPNS.NotificationClass", new MessageAttributeValue().withDataType("String").withStringValue("realtime")); // This attribute is required. return notificationAttributes; }
From source file:com.adeptj.modules.aws.sns.internal.AwsSnsService.java
License:Apache License
@Activate protected void start(SmsConfig smsConfig) { this.smsAttributes = new HashMap<>(); this.smsAttributes.put("AWS.SNS.SMS.SenderID", new MessageAttributeValue().withStringValue(smsConfig.senderId()).withDataType("String")); this.smsAttributes.put("AWS.SNS.SMS.SMSType", new MessageAttributeValue().withStringValue(smsConfig.smsType()).withDataType("String")); try {// www. j ava 2s.c o m this.asyncSNS = AmazonSNSAsyncClient.asyncBuilder() .withEndpointConfiguration( AwsUtil.getEndpointConfig(smsConfig.serviceEndpoint(), smsConfig.signingRegion())) .withCredentials(AwsUtil.getCredentialsProvider(smsConfig.accessKey(), smsConfig.secretKey())) .build(); } catch (Exception ex) { LOGGER.error("Exception while starting SmsService!!", ex); throw new AwsException(ex.getMessage(), ex); } }
From source file:com.onemenu.server.util.awsnotification.SNSMobilePush.java
License:Open Source License
private static Map<String, MessageAttributeValue> addMPNSNotificationAttributes() { Map<String, MessageAttributeValue> notificationAttributes = new HashMap<String, MessageAttributeValue>(); notificationAttributes.put("AWS.SNS.MOBILE.MPNS.Type", new MessageAttributeValue().withDataType("String").withStringValue("token")); // This // attribute//from w ww.ja v a2s . c om // is // required. notificationAttributes.put("AWS.SNS.MOBILE.MPNS.NotificationClass", new MessageAttributeValue().withDataType("String").withStringValue("realtime")); // This // attribute // is // required. return notificationAttributes; }
From source file:io.starter.messaging.SNSMobilePush.java
License:Open Source License
private static Map<String, MessageAttributeValue> addMPNSNotificationAttributes() { Map<String, MessageAttributeValue> notificationAttributes = new HashMap<String, MessageAttributeValue>(); notificationAttributes.put("AWS.SNS.MOBILE.MPNS.Type", new MessageAttributeValue().withDataType("String").withStringValue("token")); // This attribute is // required.// www . j av a2s . c o m notificationAttributes.put("AWS.SNS.MOBILE.MPNS.NotificationClass", new MessageAttributeValue().withDataType("String").withStringValue("realtime")); // This attribute is // required. return notificationAttributes; }
From source file:org.apache.nifi.processors.aws.sns.PutSNS.java
License:Apache License
@Override public void onTrigger(final ProcessContext context, final ProcessSession session) { FlowFile flowFile = session.get();//from w w w . j a va2 s. c om if (flowFile == null) { return; } if (flowFile.getSize() > MAX_SIZE) { getLogger().error( "Cannot publish {} to SNS because its size exceeds Amazon SNS's limit of 256KB; routing to failure", new Object[] { flowFile }); session.transfer(flowFile, REL_FAILURE); return; } final Charset charset = Charset .forName(context.getProperty(CHARACTER_ENCODING).evaluateAttributeExpressions(flowFile).getValue()); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); session.exportTo(flowFile, baos); final String message = new String(baos.toByteArray(), charset); final AmazonSNSClient client = getClient(); final PublishRequest request = new PublishRequest(); request.setMessage(message); if (context.getProperty(USE_JSON_STRUCTURE).asBoolean()) { request.setMessageStructure("json"); } final String arn = context.getProperty(ARN).evaluateAttributeExpressions(flowFile).getValue(); final String arnType = context.getProperty(ARN_TYPE).getValue(); if (arnType.equalsIgnoreCase(ARN_TYPE_TOPIC.getValue())) { request.setTopicArn(arn); } else { request.setTargetArn(arn); } final String subject = context.getProperty(SUBJECT).evaluateAttributeExpressions(flowFile).getValue(); if (subject != null) { request.setSubject(subject); } for (final Map.Entry<PropertyDescriptor, String> entry : context.getProperties().entrySet()) { if (entry.getKey().isDynamic() && !StringUtils.isEmpty(entry.getValue())) { final MessageAttributeValue value = new MessageAttributeValue(); value.setStringValue( context.getProperty(entry.getKey()).evaluateAttributeExpressions(flowFile).getValue()); value.setDataType("String"); request.addMessageAttributesEntry(entry.getKey().getName(), value); } } try { client.publish(request); session.transfer(flowFile, REL_SUCCESS); session.getProvenanceReporter().send(flowFile, arn); getLogger().info("Successfully published notification for {}", new Object[] { flowFile }); } catch (final Exception e) { getLogger().error("Failed to publish Amazon SNS message for {} due to {}", new Object[] { flowFile, e }); flowFile = session.penalize(flowFile); session.transfer(flowFile, REL_FAILURE); } }
From source file:org.finra.herd.dao.impl.SnsDaoImpl.java
License:Apache License
@Override public PublishResult publish(AwsParamsDto awsParamsDto, String topicArn, String messageText, List<MessageHeader> messageHeaders) { Map<String, MessageAttributeValue> messageAttributes = null; if (CollectionUtils.isNotEmpty(messageHeaders)) { messageAttributes = new HashMap<>(); for (MessageHeader messageHeader : messageHeaders) { messageAttributes.put(messageHeader.getKey(), new MessageAttributeValue().withDataType("String") .withStringValue(messageHeader.getValue())); }//from ww w . j a v a 2 s. c o m } return snsOperations.publish(topicArn, messageText, messageAttributes, awsClientFactory.getAmazonSNSClient(awsParamsDto)); }
From source file:org.springframework.cloud.aws.messaging.core.TopicMessageChannel.java
License:Apache License
private MessageAttributeValue getBinaryMessageAttribute(ByteBuffer messageHeaderValue) { return new MessageAttributeValue().withDataType(MessageAttributeDataTypes.BINARY) .withBinaryValue(messageHeaderValue); }
From source file:org.springframework.cloud.aws.messaging.core.TopicMessageChannel.java
License:Apache License
private MessageAttributeValue getContentTypeMessageAttribute(Object messageHeaderValue) { if (messageHeaderValue instanceof MimeType) { return new MessageAttributeValue().withDataType(MessageAttributeDataTypes.STRING) .withStringValue(messageHeaderValue.toString()); } else if (messageHeaderValue instanceof String) { return new MessageAttributeValue().withDataType(MessageAttributeDataTypes.STRING) .withStringValue((String) messageHeaderValue); }/* w w w . jav a2 s. co m*/ return null; }