ChannelReceiverFunction
represents a channel receiver function that applies fun to any channel message it receives.
Details and Options
- CloudDeploy[ChannelReceiverFunction[…]] yields a CloudObject containing meta-information that specifies the channel to which messages for the channel receiver should be sent.
- CloudDeploy[ChannelReceiverFunction[…]"curi"] deploys the receiver to ChannelObject["curi"].
- CloudDeploy[ChannelReceiverFunction[…]channel] deploys the receiver to the specified channel, given as ChannelObject[…].
- CloudDeploy[ChannelReceiverFunction[…]] is equivalent to CloudDeploy[ChannelReceiverFunction[…]Automatic].
- In a deployed ChannelReceiverFunction[fun], fun[assoc] is evaluated whenever a channel message is received. The association assoc contains the same elements as in ChannelListen, except for ones specific to the ChannelListener object.
- CloudDeploy[ChannelReceiverFunction[fun]] sets up a channel receiver function that is executed in the cloud and does not require active listeners in any specific Wolfram Language session.
- The function fun is evaluated in the environment of the owner of the channel receiver function.
- Channel receiver functions cannot be triggered by messages that were themselves sent from within channel receiver functions.
Examples
open allclose allBasic Examples (3)
Apply the function to an association representing a channel broker message:
Define a receiver function that logs the incoming message to a cloud object:
Obtain the target channel of the receiver:
Send a message to the channel:
Define a receiver function that logs the incoming message to a databin:
Obtain the target channel of the receiver function:
Send a message to the channel:
Check the contents of the databin:
Timestamps are treated specially by the Wolfram Data Drop and are available in a separate property (or together with the entry body in the “FullEntries” property):
Scope (7)
Applications (3)
Deploy a channel that adds incoming messages to a databin:
Send a message to the channel and retrieve its content from the databin:
Define a receiver function that sends messages containing the string "URGENT" to a priority channel and the rest to a bulk channel:
Create the two channels and deploy the receiver function to a third channel, which is automatically created:
Start listening on the channels:
Send a regular and an urgent message on the dispatcher channel:
Deploy a receiver function that sends an email alert if a message arrives when nobody is listening on the channel:
Send a message on the channel and check your mailbox for an email alert:
Properties & Relations (1)
Deploying ChannelReceiverFunction sets ChannelBrokerAction for the associated channel object:
Text
Wolfram Research (2017), ChannelReceiverFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/ChannelReceiverFunction.html (updated 2020).
CMS
Wolfram Language. 2017. "ChannelReceiverFunction." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/ChannelReceiverFunction.html.
APA
Wolfram Language. (2017). ChannelReceiverFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ChannelReceiverFunction.html