ColdFusion Event Gateways gives you the ability to communicate with external systems and services in real-time by managing events or messages asynchronously. Event Gateways basically functions as listeners for specific events and are able to trigger ColdFusion components (CFCs) which process the code and return response to these events. These are especially used for building applications which operate in real-time.
Event gateways operate asynchronously. A gateway typically gets a message and dispatches it for processing, without requiring or waiting for a response.
ColdFusion delivers the message to a CFC method named onIncomingMessage. You can specify any method name, however, in the SendGatewayMessage method’s data parameter.
ColdFusion Event Gateways
- This function dispatches a message through a ColdFusion event gateway and yields a String as a result. The specific output is contingent upon the type of gateway in use.
- Syntax : SendGatewayMessage(gatewayID, data)
- GatewayId : The identifier for the gateway intended to receive the message. It should correspond to the Gateway ID of a ColdFusion event gateway instance set up in the Gateways page of the ColdFusion Administrator’s Event Gateways section.
- Data : A ColdFusion structure. The contents of the structure depend on the event gateway type, but typically include a MESSAGE field that contains the message to send and a field that contains the destination address.
“onIncomingMessage” is presumably the designation for a method or function within a Component (CFC) or an event handler linked with an event gateway. Typically, this method is employed to manage incoming messages or events. For example, in the context of an event gateway, you might have a custom CFC which will be configured in the coldfusion event gateway instance in coldfusion administrator.
Now Let’s create our Event Gateway Instance from coldfusion administrator to see the configuration in detail and practically. Attaching an image for reference for configurations
Return type for different gateway types :
- Asynchronous CFML : If the message was placed in a queue for delivery to the ColdFusion Component (CFC), the function returns True; otherwise, it returns False
- Lotus SameTime : If the message or command is successful, it returns “OK.” In case of an error, it returns a string indicating the cause of the error.
- SMS : If the gateway is in asynchronous mode, it immediately returns an empty string. In synchronous mode, the function waits for the gateway to provide a response. If the message has been successfully sent to the short message service center (SMSC), it returns the message ID from the SMSC. If there’s an error, it returns a string indicating the cause of the error
- XMPP : It is the same as Lotus SameTime. If the message or command is successful, it returns “OK.” In case of an error, it returns a string indicating the cause of the error
Once we have created an event gateway instance then It will be visible under Configured Coldfusion Event Gateway Instances. Initially it will not be in an active status but we canperform some actions like start, refresh edit from the Actions column.
Code Snippet :
Dispatching an event to the CFML event gateway registered in the ColdFusion
Administrator as “Asynch Logger.”
Receiving data in cfc component. CFC component must have OnIncomingMessage
Applications of Coldfusion Event Gateways :
● Real-time chat applications are one of the uses of this feature where users can send messages instantly.
● Pushing real time updates and notifications to clients Data Synchronization
● We can also take this in use to keep multiple instances of CF application synchronized pushing changes from one instance to another.
● Can also update records from DB in real time when changes are visible in external systems. Workflow Automation
● We can create automation on the basis of any request triggered from the first server.
Once a request is triggered then the coldfusion event gateway can handle the next process. Collaboration Tools
● More than one(different applications) can share and update events simultaneously. Server Performance
● CF event gateway can be set up on different secondary servers which can only be used to generate reports and other things which can be done in the
Trust and Worth
We are having a diversified portfolio and serving customers in the domains namely Sports Management, Online Laundry System, Matrimonial, US Mortgage, EdTech and so on.
Would you like to start a project with us?
DAStek team would be happy to hear from you and would love to turn your ‘Imaginations to Reality’.