User Guide > Scripting > Script Objects > DJComponent Object Type
Was this helpful?
DJComponent Object Type
The DJComponent object provides enhanced support for queue sessions, iterators, aggregators, transformers, invokers, and validators. This object is available through the expression language and API.
Used in conjunction with the DJMessage Object Type, the DJComponent object can be referenced in any expression within the Map window and any expression step within the Process window. This object provides transactional handling support of messages and conditional message puts and gets. The DJComponent ConnectString option is specific to the messaging middleware supported.
Messaging Support
The DJComponent object can call any MCF component. The message body is set and retrieved using the DJMessage object.
Properties
The DJComponent object type provides a generic interface for MCF components that support message queue-like operations.
Property
Type
Access
Description
String
WO
Set the connection string for the message adaptor.
String
RW
Get/set a message adaptor property by name or by ordinal position.
Integer
RO
Get the number of message adaptor properties.
String
RO
Get the name of the Nth property in the property list.
ConnectString Property
Set the connection string for a DJComponent object. The connection string is a set of semicolon separated attribute-value pairs that specify all the information the DJComponent object needs to establish a connection with the data source.
The following attributes are supported for the DJComponent connection strings.
Attribute
Description
PASSWORD
Password used for authentication with the security system for the data source.
QUEUE
Name of the queue. This attribute is used for messaging systems.
QUEUEMGR
Name of a queue manager. This attribute is primarily used with server based messaging systems.
USERID
User name used for authentication with the security system for the data source
Syntax
msgadaptor.ConnectString = connection_string
Parameters
 
Type
Required
Description
DJComponent
Yes
Reference to the DJComponent, which is the subject of the property or method invocation.
String
Yes
Expression that evaluates to a character string with connection information. Deprecated. Use Connect method.
Exceptions
ConnectString returns exceptions if there is an error. The following exceptions can be returned.
Exception
Description
ERR_PROPASSGN
Returned when an error is returned from the adaptor.
Example
' The following example shows a connection string for connecting to a queue with the Websphere MQ adaptor:
Dim q As DJComponent
Set q = New DJComponent "Websphere MQ"
q.ConnectString = "queue=q_in"
Dim msg As DJMessage
On Error Resume Next
Set msg = q.GetMessage()
Properties Property
Get/set a message property value for an element of the property array. Properties property is used to get or set values for the properties that are part of the message adaptor configuration.
Property values can be read using either an integer representing the ordinal position of the property in the array or a string representing the property name. An exception is returned if the specified property does not exist.
Syntax
msgadaptor.Properties(n)
'OR
msgadaptor.Properties = value
You can also retrieve a property of the GetMessage action.
Dim djtrg As DJMessage
Dim comp As DJComponent
Set djtrg = New DJMessage "trg"
Set comp = New DJComponent "HideIterator"
comp.properties("hide") = "true"
comp.properties("opt1","GetMessage") = "This is a test for DJComponent"
' Retrieves the value of the option 'opt1' of the 'GetMessage' action
Set djtrg = comp.GetMessage()
filewrite(macrovalue("MCFTarget") & "TC24584DJComponentIterator.txt", djtrg.body)
Parameters
 
Type
Required
Description
DJComponent
Yes
Reference to the DJComponent, which is the subject of the property or method invocation.
Variant
Yes
Integer value representing the ordinal position of the property in the property array, or the name of the property.
String
Yes
Value to assign to specified property.
Exceptions
The Properties property may return the following exceptions if the array index parameter is invalid.
Exception
Description
ERR_INDEX
Returned if index parameter is out of the valid range of indexes for the array.
ERR_NOSUCHPROP
Returned if the index is a name and there is no property with the given name.
Example
' The following code sets the timeout for a message adaptor named 'q' to 200 milliseconds:
q.Properties("timeout") = "200"
PropertiesCount Property
Get a count of the number of message adaptor properties in the property array.
PropertiesCount is used to determine how many properties are supported by the message adaptor and associated with a DJComponent object.
Syntax
msgadaptor.PropertiesCount
Parameters
 
Type
Required
Description
DJComponent
Yes
Reference to the DJComponent, which is the subject of the property or method invocation.
Example
' The following code logs the message property names and values for each of the properties of the message adaptor for the DJComponent object.
' Since the count will start at 1 but the array index starts at zero, subtract one from the PropertiesCount to determine the number of times to loop.
For i = 0 To (msg1.PropertiesCount - 1)
  LogMessage("Info", q.PropertyNames(i) & " = " & q.Properties(i)
Next i
PropertyNames Property
Get a message adaptor property name for an element of the property array. PropertyNames property is used to look up the name for a message adaptor property by its ordinal position in the property array.
Syntax
msgadaptor.PropertyNames(n)
Parameters
 
Type
Required
Description
DJComponent
Yes
Reference to the DJComponent, which is the subject of the property or method invocation.
Integer
Yes
Integer value representing the ordinal position of the property in the property array.
Exceptions
The PropertyNames property may return the following exceptions if the array index parameter is invalid.
Exception
Description
ERR_INDEX
Returned if index parameter is out of the valid range of indexes for the array.
Example
' The following code logs the message property names and values for each of the properties of the message adaptor for the DJComponent object.
' Since the count will start at 1 but the array index starts at zero, subtract one from the PropertiesCount to determine the number of times to loop.
For i = 0 To (msg1.PropertiesCount - 1)
  LogMessage("Info", q.PropertyNames(i) & " = " & q.Properties(i)
Next i
Methods
 
Method
Description
Mark the start of processing by a component so that it can be committed or rolled back as a single unit of work.
Commit work performed since the start of a transaction.
Return data from a component in a djmessage object.
Send data to a component in a djmessage object.
Roll back work performed since the start of a transaction.
Passe data to a component in the source message and returns processed data in the target message.
Reset a component to an initial state.
Connect a component to required resources.
Disconnecs a component from required resources.
BeginTransaction Method
Start a new transaction on the message adaptor connected to a DJComponent object. BeginTransaction starts a transactional session on a message adaptor. If the message adaptor does not support transactions, calls to this method do nothing.
Syntax
msgadaptor.BeginTransaction()
Parameters
 
Type
Required
Description
DJComponent
Yes
Reference to the DJComponent that is the subject of the property or method invocation.
Example
'The following example starts a transaction for the message adaptor instance myQueue, reads a message, and commits the change.
Dim msg As DJMessage
On Error Resume Next
myQueue.BeginTransaction()
Set msg = myQueue.GetMessage()
myQueue.CommitTransaction()
CommitTransaction Method
Commit work done during a transaction on the message adaptor connected to a DJComponent object. CommitTransaction makes work done to a message adaptor during a transactional session permanent. If the message adaptor does not support transactions, calls to this method do nothing.
Syntax
msgadaptor.CommitTransaction()
Parameters
 
Type
Required
Description
DJComponent
Yes
Reference to the DJComponent, which is the subject of the property or method invocation.
Example
'The following example starts a transaction for the message adaptor instance myQueue, reads a message, and commits the change.
Dim msg As DJMessage
On Error Resume Next
myQueue.BeginTransaction()
Set msg = myQueue.GetMessage()
myQueue.CommitTransaction()
GetMessage Method
Receive a message from the message adaptor connected to a DJComponent object. The GetMessage method returns a reference to a DJMessage object.
Note:  In any component step, the component’s getMessage method is responsible for populating the message and returning a relevant return code. In a successful getMessage invocation (if source data is available), the component will populate the message body and associated message properties and return a (0) return code. If the component’s getMessage method encounters an issue (like no more data or EOF), the component is responsible for setting an appropriate return code.  It’s up to the individual component to populate the message with information relevant to the encountered error.  Some components getMessage method may add relevant information to the message, whereas other components do not add anything (leaving the message empty).
Syntax
msgadaptor.GetMessage()
Parameters
 
Type
Required
Description
DJComponent
Yes
Reference to the DJComponent, the subject of the property or method invocation.
Exceptions
If there is an error at run time, the GetMessage method may return one of the following exceptions.
Exception
Description
ERR_EOF
Returned if there are no more messages to retrieve from the message adaptor.
ERR_OBJNOTSET
Returned when there is an error receiving messages from the message adaptor.
Example
'The following example starts a transaction for the message adaptor instance myQueue, reads a message, and commits the change.
Dim msg As DJMessage
On Error Resume Next
myQueue.BeginTransaction()
Set msg = myQueue.GetMessage()
myQueue.CommitTransaction()
PutMessage Method
Send a message to the message adaptor connected to a DJComponent object. The PutMessage method sends the contents of a DJMessage object to the message adaptor.
Syntax
msgadaptor.PutMessage(msg)
Note:  Component and step options are copied to djmessage properties before the PutMessage action is called on the component UNLESS the djmessage already has a property with the same name. This means that djmessage property values take precedent over (override) option values.
Parameters
 
Type
Required
Description
DJComponent
Yes
Reference to the DJComponent, which is the subject of the property or method invocation.
DJMessage
Yes
Reference to the DJMessage object containing the message to send.
Exceptions
The PutMessage method may return one of the following exceptions if there is an error at run time.
Exception
Description
ERR_PROPFAIL
Returned when there is an error sending the message from the message adaptor.
Example
'The following example starts a transaction for the message adaptor instance myQueue, writes a message, and commits the change.
Dim msg As DJMessage
Set msg = New DJMessage
msg.Body = "<Test>This is a test</Test>"
On Error Resume Next
myQueue.BeginTransaction()
myQueue.PutMessage(msg)
myQueue.CommitTransaction()
Execute Method
Use the Execute method to execute a component associated with a DJComponent object.
Syntax
myComponent.execute(srcmsg, trgmsg)
Parameters
 
Type
Required
Description
DJMessage
No (optional)
Source message for DJComponent.
DJMessage
No (optional)
Target message for DJComponent.
Example
' The following example shows how to create a DJComponent object to execute a Transformer component.
Dim srcmsg As DJMessage
Set srcmsg = New DJMessage
Dim trgmsg As DJMessage
Set trgmsg = New DJMessage
srcmsg.Body = "<Test>This is a test</Test>"
Dim myTransformer As DJComponent
Set myTransformer = New DJComponent "NullTransformer"
myTransformer.execute(srcmsg,trgmsg) ' Do something with the target message...
RollbackTransaction Method
Rollback a pending transaction on the MCF component connected to a DJComponent object. RollbackTransaction back out changes made during a transaction with the MCF component. If the MCF component does not support transactions, calls to this method do nothing.
Syntax
msgadaptor.RollbackTransaction()
Parameters
 
Type
Required
Description
DJComponent
Yes
Reference to the DJComponent, which is the subject of the property or method invocation.
Example
' The following example starts a transaction for the MCF component instance myQueue, reads a message, and undoes the effect of the GetMessage on the component by calling RollbackTransaction.
Dim msg As DJMessage
On Error Resume Next
myQueue.BeginTransaction()
Set msg = myQueue.GetMessage()
myQueue.RollbackTransaction()
Connect Method
Establishes a connection to the message source/destination. Connect calls the component referenced by DJComponent.
Syntax
myComponent.connect(connectString)
Parameters
 
Type
Required
Description
String
No
Establishes the component connection.
Disconnect Method
Instructs the component to disconnect from its currently established connection. Disconnect calls the component referenced by DJComponent.
Syntax
myComponent.disconnect()
Parameters
 
Type
Required
Description
DJComponent
Yes
Disconnects the component from an established connection.
Reset Method
Called explicitly as an action to request that the component reset to initialized state, the beginning of the component lifecycle. Reset calls the component referenced by DJComponent.
Syntax
myComponent.reset()
Parameters
 
Type
Required
Description
DJComponent
Yes
DJComponent to reset.
Exceptions
The component is expected to set an error condition if it fails to reset.
Operators
 
Operator
Type
Description
DJComponent
Create a new object.
New Operator
The New operator creates a new instance of a DJComponent object. It takes one parameter, the name of the MCF component.
Once an object is created, the choice of component can not be changed without recreating the object. The operator returns a reference to the new object. Typically, this reference is assigned to an object variable that has been declared with a compatible type. The assignment is done using the Set statement.
Syntax
Set myComponent = New DJComponent componentName
Parameters
 
Type
Required
Description
String
Yes
Expression that evaluates to a string with the name of the data adaptor to create for the DJComponent object. If a string literal, use quotation marks.
The string parameter can include a reference to a specific version of a component if more than one is deployed (in the format #.#.#). If the version number is not provided, the newest version of the component is used by default.
Examples
' Use the newest version of the REST Invoker
Set restInvoker = New DJComponent "REST Invoker"

' Use REST Invoker 1 instead of the newest version
Set restInvoker = New DJComponent "REST Invoker 1.0.0"
Exceptions
The New operator returns exceptions if there is an error creating the object. The following exceptions can be returned.
Exception
Description
ERR_TYPEMISMATCH
Returned if the adaptor type name does not match a registered or licensed adaptor type.
ERR_OBJNOTSET
Returned if there is an error creating the adaptor instance.
Last modified date: 10/22/2024