C H A P T E R  8

Messaging API

This chapter describes the Sun Java System Content Delivery Server Messaging API. The Messaging API provides a mechanism for carriers or application vendors to integrate their WAP, SMS, and MMS push implementations with the Content Delivery Server by creating a push adapter. The Messaging API is used to create both push sender adapters and push listener adapters.

The following figure illustrates the high-level architecture of the Messaging API and the different components that use this API.


FIGURE 8-1 Architecture of the Messaging API

Overview of the Messaging API. This figure is described in the text.


An external push system can interact or receive push messages from the Content Delivery Server.

For information on classes or methods not described in this section, see the HTML output of the Javadoc tool for the Messaging API at $CDS_HOME/javadoc/cdsapi/index.html.


8.1 PushMsgSender Interface

The PushMsgSender interface declares the methods needed for a push message sender implementation. This interface is called by the Content Delivery Server Messaging Service when the Content Delivery Server sends a push message.

8.1.1 pushMessage()

public PushResponse pushMessage(PushMessage msg, int retryNum) throws PushMessageFailException;

Sends the message. This method is called when the Content Delivery Server sends a push message.


8.2 PushMsgListener Interface

The PushMsgListener interface declares the methods needed for a push message listener implementation.

8.2.1 connect()

public boolean connect()

Returns true if the Content Delivery Server is connected to the SMSC, otherwise, returns false. This method is called by Content Delivery Server Messaging Service when the SMSC sends a push message.

8.2.2 initialize()

public void initialize(String pushActionType) throws InitializationFailedException

Initializes SMSC parameters before making a connection to the SMSC. This is the first method called by the Content Delivery Server Messaging Service.

8.2.3 listen()

public void listen()

Listens for the message coming from the device. This method is called by Content Delivery Server Messaging Service after PushMsgListener is connected to the SMSC.

8.2.4 sendKeepAliveMsg()

public void sendKeepAliveMsg()

Sends signal to keep message alive. This method is called by the Content Delivery Server Messaging Service if the SMSC requires that a "Keep Alive" signal be sent to keep the connection active.


8.3 PushMessage Class

PushMessage is the base class for all of the different types of push messages generated by the Content Delivery Server. The MMSPushMessage class used for MMS messages extends PushMessage.

All of the set methods are used by the Content Delivery Server during message construction. All of the get methods can be used by a sender's implementation of a push message.

8.3.1 addUserAgent()

public void addUserAgent(String ua)

Sets the user agent for the receiver's device.

8.3.2 getAllUserAgents()

public ArrayList getAllUserAgents()

Returns all user agents for the receiver's device.

8.3.3 getAttribute()

public Object getAttribute(String attributeName)

Returns any message attribute.

8.3.4 getContentBinary()

public Object getContentBinary()

Gets the binary content included in the message.

8.3.5 getContentType()

public String getContentType()

Gets the content type of a message.

8.3.6 getDestinationAddress()

public String getDestinationAddress()

Returns the destination address, which is the phone number or email ID of the receiver.

8.3.7 getJMSMessageId()

This method is deprecated. Use getMessageId().

8.3.8 getKeyword()

public String getKeyword()

Returns the keyword that is associated with the requested content.

8.3.9 getMessageId()

public String getMessageId()

Returns the ID of the message.

8.3.10 getMessageText()

public String getMessageText()

Returns the message text.

8.3.11 getMimeType()

public String getMimeType()

Gets the MIME type.

8.3.12 getPushCategory()

public long getPushCategory()

Returns the push message category.

8.3.13 getPushDomain()

public long getPushDomain()

Returns the domain of the push message.

8.3.14 getPushType()

public String getPushType()

Returns the message type.

8.3.15 getShortCode()

public String getShortCode()

Returns the short code to which the message is sent.

8.3.16 getSubscriberId()

public long getSubscriberId()

Returns the subscriber ID.

8.3.17 getUniqueDeviceId()

public String getUniqueDeviceId()

Returns the unique device ID.

8.3.18 getVendingContentId()

public long getVendingContentId()

Returns the vending content ID.

8.3.19 setAllUserAgents()

public void setAllUserAgents(ArrayList list)

Sets multiple user agents for the receiver's device.

8.3.20 setAttribute()

public void setAttribute(String attributeName, Object attributeVal)

Sets any message attribute.

8.3.21 setContentBinary()

public void setContentBinary(byte[] content)

Sets the content binary included in the message.

8.3.22 setContentType()

public void setContentType(String contentType)

Sets the content type of the message.

8.3.23 setDestinationAddress()

public void setDestinationAddress(String receiverId)

Sets the destination address of the receiver of the push message. The destination address can be either a phone number or email ID.

8.3.24 setJMSMessageId()

This method is deprecated. Use setMessageId().

8.3.25 setKeyword()

public void setKeyword(String inputKeyword)

Sets the keyword that is associated with the requested content.

8.3.26 setMessageId()

public void setMessageId(String msgId)

Sets the ID of the message.

8.3.27 setMessageText()

public void setMessageText(String text)

Sets the message text.

8.3.28 setMimeType()

public void setMimeType(String mType)

Sets the MIME type.

8.3.29 setPushCategory()

public void setPushCategory(long category)

Sets the push message category.

8.3.30 setPushDomain()

public void setPushDomain(long domain)

Sets the domain of the push message.

8.3.31 setShortCode()

public void setShortCode(String inputShortCode)

Sets the short code to which the message is sent.

8.3.32 setSubscriberId()

public void setSubscriberId(long subId)

Sets the subscriber ID.

8.3.33 setUniqueDeviceId()

public void setUniqueDeviceId(String uniqueId)

Sets the unique ID of the device.

8.3.34 setVendingContentId()

public void setVendingContentId(long contentId)

Sets the vending content ID.

8.3.35 toString()

public String toString()

Displays the PushMessage object's data to the log. This method is mainly for debugging purposes.


8.4 SMSMessage Class

This class is deprecated. The following methods are now part of PushMessage class:

To get and set the content name or download URL, use the getAttribute() and setAttribute() methods in PushMessage with the appropriate constant defined in PushConstants. See the output of the Javadoc tool for these classes at $CDS_HOME/javadoc/cdsapi/index.html for more information.


8.5 WapPushMessage Class

This class is deprecated. To get and set the download URL, use the getAttribute() and setAttribute() methods in PushMessage with the appropriate constant defined in PushConstants. See the output of the Javadoc tool for these classes at $CDS_HOME/javadoc/cdsapi/index.html for more information.


8.6 SMTPMessage Class

This class is deprecated. To get and set the subject or message's From address, use the getAttribute() and setAttribute() methods in PushMessage with the appropriate constant defined in PushConstants. See the output of the Javadoc tool for these classes at $CDS_HOME/javadoc/cdsapi/index.html for more information.


8.7 ContentSlide Class

This class stores the binary data from the MMS push message. The binary data can have a MIME type and a unique ID associated with it. All of the set methods are used by the server during message construction. All the get methods can be used by an implementation of a push message.

8.7.1 getContentData()

public byte[] getContentData()

Returns the MMS push message's binary data.

8.7.2 getContentId()

public String getContentId()

Returns the unique ID associated with an MMS push message's binary data.

8.7.3 getContentMimeType()

public String getContentMimeType()

Returns the MIME type of an MMS push message's binary data.

8.7.4 setContentData()

public void setContentData(byte[] contentData)

Sets the MMS push message's binary data.

8.7.5 setContentId()

public void setContentId(String contentId)

Sets the unique ID associated with an MMS push message's binary data.

8.7.6 setContentMimeType()

public void setContentMimeType(String contentMimeType)

Sets the MIME type of an MMS push message's binary data.


8.8 MMSSlide Class

This class is a wrapper for ContentSlide objects and is used to construct MMS push messages. All of the set methods are used by the Content Delivery Server during message construction. All the get methods can be used by an implementation of a push message.

8.8.1 getAudioContent()

public ContentSlide getAudioContent()

Returns the audio content of an MMSSlide object.

8.8.2 getImageContent()

public ContentSlide getImageContent()

Returns the image content of an MMSSlide object.

8.8.3 getTextContent()

public ContentSlide getTextContent()

Returns the text content of an MMSSlide object.

8.8.4 getVideoContent()

public ContentSlide getVideoContent()

Returns the video content of an MMSSlide object.

8.8.5 setAudioContent()

public void setAudioContent(String contentId, String contentMimeType, byte[] contentData)

Sets the audio content of an MMSSlide object.

8.8.6 setImageContent()

public void setImageContent(String contentId, String contentMimeType, byte[] contentData)

Sets the image content of an MMSSlide object.

8.8.7 setTextContent()

public void setTextContent(String contentId, String contentMimeType, byte[] contentData)

Sets the text content of an MMSSlide object.

8.8.8 setVideoContent()

public void setVideoContent(String contentId, String contentMimeType, byte[] contentData)

Sets the video content of an MMSSlide object.


8.9 MMSPushMessage Class

The MMSPushMessage class extends PushMessage and represents an MMS push message. All of the set methods are used by the Content Delivery Server during message construction. All of the get methods can be used by an implementation of a push message. This class contains the From address, the To addresses, MMSC-related data, the user agent, and any Synchronized Multimedia Integration Language (SMIL) data, if available. It also encapsulates the MMSSlide object.

8.9.1 addMMSSlide()

public void addMMSSlide(MMSSlide mmsSlide)

Sets the MMSSlide object.

8.9.2 addRecipient()

public void addRecipient(String to)

Sets the receiver's phone number or email ID.

8.9.3 getAllMMSSlides()

public ArrayList getAllMMSSlides()

Returns all of the MMSSlide objects associated with this MMSPushMessage.

8.9.4 getAllRecipients()

public ArrayList getAllRecipients()

Returns the phone number or email ID of all of the recipients of the message.

8.9.5 getDeliveryReportRequired()

public boolean getDeliveryReportRequired()

Returns the value for DeliveryReportRequired attribute.

8.9.6 getFromAddress()

public String getFromAddress()

Returns the sender's phone number or email ID.

8.9.7 getMessageClass()

public String getMessageClass()

Returns the value for MessageClass attribute.

8.9.8 getMessagePriority()

public String getMessagePriority()

Returns the value for MessagePriority attribute.

8.9.9 getReadReportRequired()

public boolean getReadReportRequired()

Returns the value for ReadReportRequired attribute.

8.9.10 getSenderVisibility()

public String getSenderVisibility()

Returns the value for SenderVisibility attribute.

8.9.11 getSMILPresentation()

public byte[] getSMILPresentation()

Returns the SMIL data.

8.9.12 setDeliveryReportRequired()

public void setDeliveryReportRequired(boolean deliveryReportRequired)

Sets the value for DeliveryReportRequired attribute.

8.9.13 setFromAddress()

public void setFromAddress(String from)

Sets the sender's phone number or email ID.

8.9.14 setMessageClass()

public void setMessageClass(String messageClass)

Sets the value for MessageClass attribute.

8.9.15 setMessagePriority()

public void setMessagePriority(String messagePriority)

Sets the value for MessagePriority attribute.

8.9.16 setReadReportRequired()

public void setReadReportRequired(boolean readReportRequired)

Sets the value for the ReadReportRequired attribute.

8.9.17 setSenderVisibility()

public void setSenderVisibility(String senderVisibility)

Sets the value for SenderVisibility attribute.

8.9.18 setSMILPresentation()

public void setSMILPresentation(byte[] smil)

Sets the SMIL data.


8.10 MMSSender Interface

The MMSSender interface declares the method that sends an MMS message. This interface must be implemented for the vendor-specific MMSC during integration if you want to support MMS messages.

8.10.1 sendMMS()

sendMMS(com.sun.content.server.server.messaging.message.MMSPushMessage message) 

Encapsulates the functionality for sending an MMS message. This method is called by the Content Delivery Server Messaging Service when it receives an MMSPushMessage from the Content Delivery Server.

The Content Delivery Server sends an MMSPushMessage object to the Content Delivery Server Messaging Service. The Messaging Service uses the value of the mms.senderclass property in the MsgService.properties file to identify the fully qualified name of the class that provides the vendor-specific implementation of MMSSender.sendMMS. The code within the implementation of sendMMS transforms the MSSPushMessage object into a vendor-specific version of the MMS message object and sends it to the vendor-specific MMSC for processing. The following figure shows this process.


FIGURE 8-2 Process Flow for Sending an MMS Message

Process flow for sending an MMS message. This figure is described in the text.


To implement a vendor-specific version of MMSSender.sendMMS, include the following items:

1. Connect to the vendor-specific MMSC.

2. Implement MMSSender.sendMMS to do the following tasks:


8.11 PushResponse Class

The PushResponse class is the base class for all of the different types of push responses generated by the external push services. All of the set methods are used by an implementation of a push message sender. All of the get methods can be used by the Content Delivery Server to log the push message in the database.

8.11.1 getMessageId()

public String getMessageId()

Returns the message ID.

8.11.2 getResponseDescription()

public String getResponseDescription()

Returns the response description.

8.11.3 getResponseStatus()

public String getResponseStatus()

Returns the response status.


8.12 PushConstants Class

The PushConstants class contains all of the constants that the push services can support. A specific push service implementation compares these constants with the values received from the PushMessage object. See the output of the Javadoc tool at $CDS_HOME/javadoc/cdsapi/index.html for information on the constants defined.


8.13 Using the Messaging API

A push sender adapter must implement the PushMsgSender interface. During deployment, the implementation class needs to be registered with the Content Delivery Server. An XML file is used for registration. This XML file is located in the $CDS_HOME/deployment/deployment-name/conf directory and is named pushsenderfactory.xml.

The following example shows the structure of this file.


CODE EXAMPLE 8-1 Sample pushsenderfactory.xml File
<?xml version="1.0" encoding='UTF-8' ?>
<PushSenderConfig nodeid="0">
  <pushmsgsenderset nodeid ="1">
    <pushmsgsender nodeid ="2" class = 
"com.sun.content.server.server.msgserver.push.HTTPSMSPushMsgSender" protocol="sms"/>
    <pushmsgsender nodeid ="3" class = 
"com.sun.content.server.server.msgserver.push.WAPPushMsgSender" protocol="wap"/>
    <pushmsgsender nodeid ="4" class = 
"com.sun.content.server.server.msgserver.push.SMTPushMsgSender" protocol="smtp"/>
    <pushmsgsender3 class = 
"com.sun.content.server.server.msgserver.push.MMSPushMsgSender" protocol="mms"/>
</pushmsgsenderset>
</PushSenderConfig>

Four adapters are registered in this file. Specify the fully qualified class name and the protocol that the adapter supports. For example, if you have an adapter for SMS push, the protocol is sms. Make sure the adapter class and dependent classes are set in the classpath.

If you are using the default implementation of a push sender adapter for MMS, MMSPushMsgSender, you must implement the MMSSender interface. Set the mms.senderclass property in the MsgServices.properties file to the fully qualified name of your class. This class is in the $CDS_HOME/deployment/deployment-name/conf directory.

A push listener adapter implements the PushMsgListener interface. The implementation class needs to be registered with the Content Delivery Server. An XML file is used for registration. This XML file is located in the $CDS_HOME/deployment/deployment-name/conf directory and is named pushlistenerfactory.xml.

The following example shows the structure of this file.


CODE EXAMPLE 8-2 Sample pushlistenerfactory.xm l File
<pushmsglistenerset>
    <pushmsglistener0 class=
"com.sun.content.server.server.msgserver.protocol.cimd2.CIMD2PushMsgListener" protocol="sms"/>
</pushmsglistenerset>