Using DJMessage and DJComponent Objects in Expressions
Within the expression language, you can call messaging objects, namely the
DJMessage Object Type and
DJComponent Object Type objects. Some examples of how you can write the expressions to call the objects follow.
The DJMessage object can be used as a source or target connection using the DJMessage:/// URI scheme with any file-based connector.
Syntax
djMessage:///myMsg
The DJMessage object is not tied to the DJComponent object. DJMessage is independent and can be used without the use of the DJComponent object to do "virtual messaging" without a formal messaging middleware.
Note: It is often preferable to use the Process window to call these objects, because you can invoke an object, and use that object over multiple steps in a process. For a map example, see
Using a DJMessage Object with a Map.
The following example uses the Websphere MQ object in conjunction with the DJMessage object:
Dim q As DJComponent
Set q = New DJComponent "Websphere MQ"
q.connectstring = "queue = queue1"
Dim msg As DJMessage
Set msg As q.GetMessage()
msg.name = "foo"
LogMessage(FileRead("djmessage:///foo"))
This brings the message into memory, not to the disk, thereby increasing speed. If the queue is readable, the message is removed from the queue when the transaction is committed.
If the browse mode of the queue is set to true, the message will not be removed from the queue when the transaction is committed. Message objects are process-specific. They can be used within a single process only. Therefore, multiple processes can have an object called "foo" and they will not conflict.
Destroy all objects at the end of the process by calling DeleteMessage. See
DJMessage Object Type and
DJComponent Object Type for details on objects properties and methods.
Tip... You can use macros in conjunction with the DJMessage object.
Examples
Example of Putting a Message on a Queue
Dim q As DJComponent
Set q = New DJComponent "Websphere MQ"
q.ConnectString = "queue=queue1"
Dim msg As DJMessage ' The message name is optional here
Set msg = New DJMessage "msg1"
' Alternative method to set the message name:
' msg.Name = "msg1"
msg.Body = "Test Message 1"
q.PutMessage(msg)
Set q = Nothing
Example of Getting a Message from a Queue
Dim q As DJComponent
Set q = New DJComponent "Websphere MQ"
q.ConnectString = "queue=queue1"
Dim msg As DJMessage
Set msg = q.GetMessage()
LogMessage(msg.Body)
Set q = Nothing
Example of Putting a Message Using Specific Encoding
Dim q As DJComponent
Set q = New DJComponent "Websphere MQ"
q.ConnectString = "queue=queue1"
Dim msg As DJMessage
Set msg = New DJMessage "msg1"
msg.Encoding = -3
' Alternative method to set encoding:
' msg.Encoding = ENC_UTF8
msg.Body = "Test Message 1"
q.PutMessage(msg)
Set q = Nothing
Last modified date: 10/22/2024