({{, (RefLink[ChannelDatabin, paclet:ref/ChannelDatabin]) 
is an option to (RefLink[ChannelListen, paclet:ref/ChannelListen]) that specifies a databin in which to store incoming messages. }})

OpenersNotesSection(Spacer1)Details

A channel databin persists even after the listener that provided data is removed.

The following settings can be used:

The databin created with listener=(RefLink[ChannelListen, paclet:ref/ChannelListen])[…,ChannelDatabin->(RefLink[Automatic, paclet:ref/Automatic])] can be retrieved with listener["Databin"].

OpenersPrimaryExamplesSection(Spacer1)Examples  (5)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Start listening on a channel, storing incoming messages in a new databin:

listener=ChannelListen["x",ChannelDatabin->Automatic]

Send a few messages to the channel:

ChannelSend["x",#]&/@{"Hello","World"}

The databin associated with the channel:

bin=listener["Databin"]

Messages stored in the databin:

bin["Entries"]

Databin entries persist after the listener is removed:

RemoveChannelListener[listener]

bin["Entries"]

OpenersExampleSection1(Spacer1)Scope  (2)

A channel listener with a new, automatically created databin:

listener=ChannelListen["x",ChannelDatabin->Automatic]

Send a few messages:

ChannelSend["x",#]&/@Range[3]

Find the associated databin and retrieve the messages:

bin=listener["Databin"]

bin["Entries"]

Start listening on a channel, adding incoming messages to an existing databin:

bin=CreateDatabin[]

listener=ChannelListen["y",ChannelDatabin->bin]

Send a few messages to the channel:

ChannelSend["y",#]&/@{2,1}

Plot the data accumulated in the databin:

DateListPlot[bin]

OpenersExampleSection3(Spacer1)Properties & Relations  (2)

While a listener is active, data sent to a databin using the (RefLink[ChannelDatabin, paclet:ref/ChannelDatabin]) option can also be retrieved from the (RefLink[ChannelListener, paclet:ref/ChannelListener]) object:

listener=ChannelListen["x",ChannelDatabin->Automatic]

ChannelSend["x",#]&/@RandomReal[{0,1},3];

listener["Databin"]["Entries"]

listener["Message",All]

Using (RefLink[ChannelReceiverFunction, paclet:ref/ChannelReceiverFunction]), data can be added to a databin without an active listener:

bin = CreateDatabin[]

With[{bin=bin},CloudDeploy[ChannelReceiverFunction[DatabinAdd[bin,<|"Data"->#Message|>]&]->"channel"]]

ChannelSend["channel","hello"]

The stored message:

bin["Latest"]["Data"]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Databin, paclet:ref/Databin])  ▪  (RefLink[ChannelSend, paclet:ref/ChannelSend])  ▪  (RefLink[ChannelListen, paclet:ref/ChannelListen])  ▪  (RefLink[CreateChannel, paclet:ref/CreateChannel])  ▪  (RefLink[DatabinAdd, paclet:ref/DatabinAdd])  ▪  (RefLink[ChannelReceiverFunction, paclet:ref/ChannelReceiverFunction])  ▪  (RefLink[ChannelBrokerAction, paclet:ref/ChannelBrokerAction])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Channel-Based Communication, paclet:guide/Channel-BasedCommunication])}})}})