Publish method: Message class
Syntax
Publish([NodeName] [, Deferred_Mode] )
Description
The Publish method publishes a message to the application message queue for the default message version.
Note:
This method has been desupported and remains for backward compatibility only. Use the IntBroker class Publish method instead.
This method does not publish the message if the IsActive property is False.
This method publishes a message asynchronously, that is, a reply message is not automatically generated. To publish a message synchronously, use the SyncRequest method.
Note:
This method supports nonrowset-based messages only if the data is populated using the SetXmlDoc method.
If the Publish method is called and the message isn't populated (either using SetXmlDoc or one of the rowset methods,) an empty message is published.
The Publish method can be called from any PeopleCode event, but is generally called from an Application Engine PeopleCode step or from a component.
When publishing from a component, you should publish messages only from the SavePostChange event, either from record field or component PeopleCode. This way, if there’s an error in your publish code, the data isn’t committed to the database. Also, since SavePostChange is the last Save event fired, you avoid locking the database while the other save processing is happening.
However, until the message is published, the tables involved with the component are locked and are not saved. To avoid problems with this, specify the Deferred_Mode property as true, so the message is published after the table data has been committed to the database.
Generally, if the message is successfully published, the PubID, and PubNodeName properties are set to the publication ID and publishing system node name, respectively. The only exception is when the Publish is performed as part of your notification PeopleCode. The notification process is always executed in deferred mode, due to performance considerations, and so the PubID is not populated.
Note:
If you’re publishing a message from within an Application Engine program, the message won’t actually be published until the calling program performs a Commit.
Parameters
| Parameter | Description |
|---|---|
|
NodeName |
Specify the node to which the message should be published. |
|
Deferred_Mode |
Specify whether the message should be published immediately or at the end of the transaction. This parameter takes a Boolean value: False, publish the message immediately, or True, defer the publication. The default value is False. |
Returns
None.
Example
The following copies all the data from a page into a message and publishes it.
Local Message &MSG;
Local Rowset &ROWSET;
&MSG = CreateMessage(OPERATION.MESSAGE_PO):
&ROWSET = GetLevel0();
&MSG.CopyRowset(&ROWSET);
&MSG.Publish;
The following is an example of putting the Incremental Publish PeopleCode on a Record at Level 1 (or 2, 3). If you just do the normal publishing PeopleCode, you get as many messages as there are records at that level (because the code fires for each record).
To make sure the code fires only once, use the following code.
/*NAMES.EMPLID.WORKFLOW */
Local Message &MSG;
Local Rowset &RS;
&LEVEL = CurrentLevelNumber();
&CURRENT_ROW = CurrentRowNumber(&LEVEL);
&TOT_ROW = ActiveRowCount(EMPLID);
/* Only Publish the message once for all records on */
/* this level */
If &CURRENT_ROW = &TOT_ROW Then
&MSG = CreateMessage(OPERATION.NAMES);
&RS = GetRowset();
&MSG.CopyRowsetDelta(&RS);
&MSG.Publish();
End-If;