Sending Messages to Amazon SNS from a Production
Amazon SNSOpens in a new tab is a cloud service that delivers messages from a publisher to a subscriber. You can configure your interoperability production to be an SNS publisher by using the built-in SNS business operation or by creating a custom business operation using the SNS outbound adapter. There is also an API for use outside of a production.
There are three components to a message sent to SNS: a topic, a subject, and the content of the message. Each message sent by a publisher to SNS must be associated with a specific topic. SNS pushes messages to subscribers who have subscribed to a particular topic. A message sent to SNS can also include a subject, which SNS uses as the Subject line when the message is distributed to subscribers as an email.
Using the Business Operation
InterSystems provides a built-in business operation that can be used to publish messages to SNS without needing to write custom code. To use this business operation:
-
Add EnsLib.AmazonSNS.BusinessOperationOpens in a new tab to your production. See Adding Business Hosts.
-
Configure settings of this business host as described in Amazon SNS Settings. The settings include the topic and optional subject.
If you need to be able to specify the topic and subject on a message-by-message basis, use the adapter instead.
-
Configure other business hosts to send EnsLib.AmazonSNS.PublishRequestOpens in a new tab requests to this business operation.
A message of type EnsLib.AmazonSNS.PublishRequestOpens in a new tab has one string property: Message.
When this business operation receives a message of type EnsLib.AmazonSNS.PublishRequestOpens in a new tab, it publishes that message to SNS, using the topic and subject configured for the business operation.
Using the Adapter
If the built-in SNS business operation does not meet your needs, you can directly use the SNS adapter as follows:
-
Create a custom business operation class:
-
The class should extend Ens.BusinessOperationOpens in a new tab.
-
The ADAPTER parameter should equal EnsLib.AmazonSNS.OutboundAdapterOpens in a new tab.
-
The class should define a message map:
XData MessageMap { <MapItems> <MapItem MessageType="messageclass"> <Method>methodname</Method> </MapItem> ... </MapItems> }
-
The class should define all the methods in the message map. These methods are known as message handlers. Each message handler should have the following signature:
Method Sample(pReq As RequestClass, Output pResp As ResponseClass) As %Status { }
The message handlers can call the instance methods of the adapter, which is accessible as the Adapter property of the business operation. The general syntax for calling these methods is as follows:
do ..Adapter.MethodName(arguments)
The SNS outbound adapter has one instance method, named Publish(), with the following signature:
Method Publish(arnTopic As %String, message As %String, subject As %String) As %Status{ }
-
-
Add your business operation to your production. See Adding Business Hosts.
-
Configure settings of this business host as described in Amazon SNS Settings.
-
Configure other business hosts to send requests to this business operation.
The SNS outbound adapter was developed using the InterSystems PEX framework, so the source code for the adapter looks different from most other adapters. For example, the adapter methods are actually wrappers for methods written in a Java PEX component.
See Also
-
Using the Amazon SNS Messaging API (for use without a production)