# Gateway-Scoped Event Handler Script

**URL:** <https://forum.inductiveautomation.com/t/gateway-scoped-event-handler-script/71263>\
**Category:** Module Development\
**Created:** [March 17, 2023, 9:46pm UTC](https://forum.inductiveautomation.com/t/gateway-scoped-event-handler-script/71263 "2023-03-17T21:46:43Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 17, 2023, 10:00pm UTC](https://forum.inductiveautomation.com/t/gateway-scoped-event-handler-script/71263/2 "2023-03-17T22:00:06Z")

</div>

There's lots of _possible_ ways to do this, but one of the easiest on you and your end users is to just send a message (from your module code) to a specific project's named message handler.

[https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.25/com/inductiveautomation/ignition/gateway/model/GatewayContext.html#getMessageDispatchManager()](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.25/com/inductiveautomation/ignition/gateway/model/GatewayContext.html#getMessageDispatchManager())  
[https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.25/com/inductiveautomation/ignition/common/script/message/MessageDispatchManager.html#dispatch(java.lang.String,java.lang.String,org.python.core.PyDictionary,java.util.Properties)](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.25/com/inductiveautomation/ignition/common/script/message/MessageDispatchManager.html#dispatch(java.lang.String,java.lang.String,org.python.core.PyDictionary,java.util.Properties))

> [@Calling the system.util.sendMessage function from a Module?](https://forum.inductiveautomation.com/t/calling-the-system-util-sendmessage-function-from-a-module/12063/4):
>
> What you will have to do is dispatch the message using MessageDispatchManager, and then you need to set up a message handler in a project that can call a script function in your module (example shown below). Send code (Java): MessageDispatchManager mdm = gatewayContext.getMessageDispatchManager(); PyDictionary payload = new PyDictionary(new PyObject[] { new PyString("Source"), new PyString("Gateway"), new PyString("Message"), new PyString("testMessage") }); // Limit to Gatewa…

---

_[View the full topic](https://forum.inductiveautomation.com/t/gateway-scoped-event-handler-script/71263)._
