Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 

If you are using INotificationService portal service, then this blog is relevant for you.

The basics that describe how to use this portal service to transfer notifications in the portal to the different server nodes of a cluster are documented in the following blog: How to use the INotificationService API in SAP Portal 7.30

This blog extends the knowledge of the previous blog by describing the different types of data that can be used.


The data that is being transferred via the INotificationService is wrapped within a TopicDataContainer object. To the container you should add TopicData objects, recognized by their IDs:


TopicDataContainer container = new TopicDataContainer("TopicContainerName1");

container.addTopicData("Topic2Id", "Topic2Str");


This example adds new TopicData with value "Topic2Str", and with ID "Topic2Id" to the TopicDataContainer "TopicContainerName1".

This example uses the default TopicType – TopicDataContainer.STRING.


This type can be used as long as the string does not contain special characters, such as ‘\n’ and ‘\r’. If your data contains such characters, you will get NULL TopicData on the receiver side (in the handleTopic() method) .


So what should be used when transferring special characters, or other data types?

Well, there are few other supported data types:
TopicDataContainer.STREAM
TopicDataContainer.FILE

TopicDataContainer.INT


In order to use the first two, you should create special TopicData objects respectively:

(clicking on the links redirects to the formal SAP documentation):


StreamData - used to build Topic message data containing a stream of bytes.


FileData - used to exchange File and Directory (uses ZipOutputStream).



Usage examples:


// Type TopicDataContainer.STREAM

ByteArrayInputStream bais = new ByteArrayInputStream("This is my text.\n it contains special characters\r.".getBytes());

StreamData streamData = new StreamData(bais);

container.addTopicData("TopicStreamDataID", streamData);



// Type TopicDataContainer.FILE

FileData fileData = new FileData(directoryPath);

container.addTopicData("TopicFileDataID", fileData);


// Type TopicDataContainer.INT

container.addTopicData("TopicIntID", new TopicData(TopicDataContainer.INT, "13"));



In general you should always consider whether the data is really necessary to be transferred, as using the STRING type or INT type are considered to be faster, and performance is an important aspect during portal runtime :smile: .