Sometimes you may need to filter incoming in a port messages by contents – i.e. accept only messages containing the required information, or matching the specified format, and discard other ones.
In AnyLogic you can easily implement any message contents checking mechanism in the On Receive property of the port. Here you can specify your own contents checking code and ignore or accept the arrived message by writing return false; or return true; statement correspondingly.
To make a port filter incoming messages by contents
if ( msg.name==null || msg.address==null )
// process the request
Note that returning false we prohibit the default processing of the message. Thus received messages will not be forwarded further according to the message routing rules.