Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding docs around subscriptions

  • Loading branch information...
commit dd2f17224faf006264a2662c8f338c3d1bee4e8c 1 parent d563aa4
@drusellers drusellers authored
Showing with 186 additions and 16 deletions.
  1. +69 −0 _sources/config.txt
  2. +114 −15 config.html
  3. +2 −0  index.html
  4. +1 −1  searchindex.js
View
69 _sources/config.txt
@@ -53,3 +53,72 @@ you covered too.
sbc.ReceiveFrom("msmq://localhost/test_queue");
});
+
+Subscription Management By Hand
+'''''''''''''''''''''''''''''''
+
+To subscribe a consumer to a message, we have a very fine grain set of functions
+that will allow you to subscribe you consumers with just what you need. Now
+given that it is very fine grained, we also provide a lot of methods to help
+you avoid dealing with it.
+
+.. sourcecode:: csharp
+ :linenos:
+
+ Bus.Initialize(sbc=>
+ {
+ sbc.Subscribe(sc=>
+ {
+ //untyped
+ sc.Consumer(typeof(MyConsumer), t =>
+ {
+ //begin consumer life cycle
+ return Activator.CreateInstance(t);
+ //end consumer life cycle
+ });
+
+ //type
+ sc.Consumer<MyConsumer>(() =>
+ {
+ return a =>
+ {
+ //begin consumer life cycle
+ var c = new MyConsumer();
+ a(c);
+ //end consumer life cycle
+ };
+ });
+
+ //if you had a container
+ sc.Consumer(typeof(MyConsumer), t=>
+ {
+ return container.GetInstance(t);
+ });
+
+ sc.Consumer<MyConsumer>(() =>
+ {
+ return a =>
+ {
+ //windsor
+ var c = container.Resolve<MyConsumer>();
+ a(c);
+ container.Release(c);
+ };
+ });
+ });
+ });
+
+Subscription Management Simplified
+''''''''''''''''''''''''''''''''''
+
+Ok, so all of that above is pretty nasty, and its not something that I want to
+use, but it did allow me to write an extension method that simplified it to the
+following.
+
+.. sourcecode:: csharp
+ :linenos:
+
+ Bus.Initialize(sbc =>
+ sbc.LoadConsumersFromContainer(container);
+ //other bits of course
+ );
View
129 config.html
@@ -23,8 +23,7 @@
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="MassTransit v2.0 documentation" href="index.html" />
- <link rel="next" title="Service Bus" href="servicebus.html" />
- <link rel="prev" title="Overview" href="overview.html" />
+ <link rel="prev" title="Installation" href="installation.html" />
</head>
<body>
<div class="related">
@@ -34,10 +33,7 @@
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
- <a href="servicebus.html" title="Service Bus"
- accesskey="N">next</a> |</li>
- <li class="right" >
- <a href="overview.html" title="Overview"
+ <a href="installation.html" title="Installation"
accesskey="P">previous</a> |</li>
<li><a href="index.html">MassTransit v2.0 documentation</a> &raquo;</li>
</ul>
@@ -97,6 +93,113 @@
</pre></div>
</td></tr></table></div>
</div>
+<div class="section" id="subscription-management-by-hand">
+<h2>Subscription Management By Hand<a class="headerlink" href="#subscription-management-by-hand" title="Permalink to this headline">¶</a></h2>
+<p>To subscribe a consumer to a message, we have a very fine grain set of functions
+that will allow you to subscribe you consumers with just what you need. Now
+given that it is very fine grained, we also provide a lot of methods to help
+you avoid dealing with it.</p>
+<div class="highlight-csharp"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42</pre></div></td><td class="code"><div class="highlight"><pre><span class="n">Bus</span><span class="p">.</span><span class="n">Initialize</span><span class="p">(</span><span class="n">sbc</span><span class="p">=&gt;</span>
+<span class="p">{</span>
+ <span class="n">sbc</span><span class="p">.</span><span class="n">Subscribe</span><span class="p">(</span><span class="n">sc</span><span class="p">=&gt;</span>
+ <span class="p">{</span>
+ <span class="c1">//untyped</span>
+ <span class="n">sc</span><span class="p">.</span><span class="n">Consumer</span><span class="p">(</span><span class="k">typeof</span><span class="p">(</span><span class="n">MyConsumer</span><span class="p">),</span> <span class="n">t</span> <span class="p">=&gt;</span>
+ <span class="p">{</span>
+ <span class="c1">//begin consumer life cycle</span>
+ <span class="k">return</span> <span class="n">Activator</span><span class="p">.</span><span class="n">CreateInstance</span><span class="p">(</span><span class="n">t</span><span class="p">);</span>
+ <span class="c1">//end consumer life cycle</span>
+ <span class="p">});</span>
+
+ <span class="c1">//type</span>
+ <span class="n">sc</span><span class="p">.</span><span class="n">Consumer</span><span class="p">&lt;</span><span class="n">MyConsumer</span><span class="p">&gt;(()</span> <span class="p">=&gt;</span>
+ <span class="p">{</span>
+ <span class="k">return</span> <span class="n">a</span> <span class="p">=&gt;</span>
+ <span class="p">{</span>
+ <span class="c1">//begin consumer life cycle</span>
+ <span class="n">var</span> <span class="n">c</span> <span class="p">=</span> <span class="k">new</span> <span class="n">MyConsumer</span><span class="p">();</span>
+ <span class="n">a</span><span class="p">(</span><span class="n">c</span><span class="p">);</span>
+ <span class="c1">//end consumer life cycle</span>
+ <span class="p">};</span>
+ <span class="p">});</span>
+
+ <span class="c1">//if you had a container</span>
+ <span class="n">sc</span><span class="p">.</span><span class="n">Consumer</span><span class="p">(</span><span class="k">typeof</span><span class="p">(</span><span class="n">MyConsumer</span><span class="p">),</span> <span class="n">t</span><span class="p">=&gt;</span>
+ <span class="p">{</span>
+ <span class="k">return</span> <span class="n">container</span><span class="p">.</span><span class="n">GetInstance</span><span class="p">(</span><span class="n">t</span><span class="p">);</span>
+ <span class="p">});</span>
+
+ <span class="n">sc</span><span class="p">.</span><span class="n">Consumer</span><span class="p">&lt;</span><span class="n">MyConsumer</span><span class="p">&gt;(()</span> <span class="p">=&gt;</span>
+ <span class="p">{</span>
+ <span class="k">return</span> <span class="n">a</span> <span class="p">=&gt;</span>
+ <span class="p">{</span>
+ <span class="c1">//windsor</span>
+ <span class="n">var</span> <span class="n">c</span> <span class="p">=</span> <span class="n">container</span><span class="p">.</span><span class="n">Resolve</span><span class="p">&lt;</span><span class="n">MyConsumer</span><span class="p">&gt;();</span>
+ <span class="n">a</span><span class="p">(</span><span class="n">c</span><span class="p">);</span>
+ <span class="n">container</span><span class="p">.</span><span class="n">Release</span><span class="p">(</span><span class="n">c</span><span class="p">);</span>
+ <span class="p">};</span>
+ <span class="p">});</span>
+ <span class="p">});</span>
+<span class="p">});</span>
+</pre></div>
+</td></tr></table></div>
+</div>
+<div class="section" id="subscription-management-simplified">
+<h2>Subscription Management Simplified<a class="headerlink" href="#subscription-management-simplified" title="Permalink to this headline">¶</a></h2>
+<p>Ok, so all of that above is pretty nasty, and its not something that I want to
+use, but it did allow me to write an extension method that simplified it to the
+following.</p>
+<div class="highlight-csharp"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1
+2
+3
+4</pre></div></td><td class="code"><div class="highlight"><pre><span class="n">Bus</span><span class="p">.</span><span class="n">Initialize</span><span class="p">(</span><span class="n">sbc</span> <span class="p">=&gt;</span>
+ <span class="n">sbc</span><span class="p">.</span><span class="n">LoadConsumersFromContainer</span><span class="p">(</span><span class="n">container</span><span class="p">);</span>
+ <span class="c1">//other bits of course</span>
+<span class="p">);</span>
+</pre></div>
+</td></tr></table></div>
+</div>
</div>
@@ -113,16 +216,15 @@
</ul>
</li>
<li><a class="reference internal" href="#basic-configuration-multi-instance">Basic Configuration (Multi Instance)</a></li>
+<li><a class="reference internal" href="#subscription-management-by-hand">Subscription Management By Hand</a></li>
+<li><a class="reference internal" href="#subscription-management-simplified">Subscription Management Simplified</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
- <p class="topless"><a href="overview.html"
- title="previous chapter">Overview</a></p>
- <h4>Next topic</h4>
- <p class="topless"><a href="servicebus.html"
- title="next chapter">Service Bus</a></p>
+ <p class="topless"><a href="installation.html"
+ title="previous chapter">Installation</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/config.txt"
@@ -152,10 +254,7 @@
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
- <a href="servicebus.html" title="Service Bus"
- >next</a> |</li>
- <li class="right" >
- <a href="overview.html" title="Overview"
+ <a href="installation.html" title="Installation"
>previous</a> |</li>
<li><a href="index.html">MassTransit v2.0 documentation</a> &raquo;</li>
</ul>
View
2  index.html
@@ -53,6 +53,8 @@
<li class="toctree-l1"><a class="reference internal" href="config.html">Configuration</a><ul>
<li class="toctree-l2"><a class="reference internal" href="config.html#basic-configuration-singlton">Basic Configuration (Singlton)</a></li>
<li class="toctree-l2"><a class="reference internal" href="config.html#basic-configuration-multi-instance">Basic Configuration (Multi Instance)</a></li>
+<li class="toctree-l2"><a class="reference internal" href="config.html#subscription-management-by-hand">Subscription Management By Hand</a></li>
+<li class="toctree-l2"><a class="reference internal" href="config.html#subscription-management-simplified">Subscription Management Simplified</a></li>
</ul>
</li>
</ul>
View
2  searchindex.js
@@ -1 +1 @@
-Search.setIndex({objects:{},terms:{all:1,code:[1,2],receivefrom:1,help:[],just:[],oss:[],move:[],controlbu:[],access:1,thank:[],tconsum:[],fix:[],configur:[0,1],param:[],should:1,shudder:1,platform:[],init:[],program:[],messagenam:[],zmq:[],arrai:[],build:[],consum:[],variou:[],get:[1,2],read:[],"void":[],initi:1,msmqtransportfactori:[],made:[],"new":1,veri:[],world:[],iendpointresolv:[],now:[],discuss:[],like:[],itransportfactori:[],builder:[],name:[],specif:1,rabbitmq:2,"public":[],team:[],where:[],page:0,set:[],singlton:[0,1],cfg:[],some:[],intern:[],sampl:[],pattarn:1,follow:1,close:1,inboundpipelin:[],servic:[],transport:1,excit:[],index:0,what:[],sub:[],space:[],publish:[],content:0,consumertyp:[],"import":[],subscript:1,factori:[],localhost:1,unsubscribeact:[],machin:[],usemsmq:1,kei:[],gener:[],iservicebu:[],envelop:[],bodi:[],sbc:1,believ:[],tservic:[],org:[],outboundpipelin:[],structuremapobjectbuild:[],search:0,actual:[],convent:[],queue:1,thing:[],multicast:1,imessagepipelin:[],action:[],lambda:1,inmemori:[],singleton:1,point:[],zguid:[],overview:[],modul:0,address:1,iendpoint:[],done:1,instal:[0,2],open:1,your:1,select:1,from:1,describ:[],wai:[],few:1,interact:[],regist:[],messag:1,custom:1,compon:[],attach:[],interfac:[],too:1,basic:[0,1],"var":1,call:[],zeromq:[],idispos:[],"final":[],more:[],udp:[],offer:[],inbound:[],getconsumeract:[],subscrib:[],about:[],link:2,gain:1,func:[],line:1,activemq:[],than:[],multi:[0,1],endpoint:[],type:[],setup:1,commerci:[],structur:[],tell:1,getservic:[],below:1,mostli:[],"typeof":[],abov:[],servicebusfactori:1,problem:[],poisonendpoint:[],want:1,can:1,year:[],share:1,ani:[],indic:0,right:[],have:1,tabl:0,need:1,serial:[],subscribeconsum:[],yadadadada:[],welcom:0,msmq:[1,2],callback:[],receiv:1,power:[],binari:2,instanc:[0,1],role:[],take:[],which:[],usemulticastsubscriptioncli:1,environ:1,you:1,document:0,start:1,map:[],product:[],http:[],see:1,"class":[],object:[],test_queu:1,busconfigur:[],plai:1,masstransit:[0,1],contain:[],respons:[],why:[],built:[],framework:[],condit:[],urn:[],loopback:[],cover:1,uri:[],predic:[],thought:1,inform:1,exampl:1,combin:[],thi:1,structuremap:[],model:[],first:[],talk:[],servicebu:[]},objtypes:{},titles:["Welcome to MassTransit&#8217;s documentation!","Configuration","Installation"],objnames:{},filenames:["index","config","installation"]})
+Search.setIndex({objects:{},terms:{all:1,code:[2,1],receivefrom:1,help:1,just:1,oss:[],move:[],follow:1,fine:1,bit:1,content:0,getinst:1,urn:[],thank:[],tconsum:[],also:1,fix:[],configur:[0,1],activ:1,param:[],should:1,shudder:1,platform:[],init:[],program:[],messagenam:[],tell:1,zmq:[],modul:0,take:[],consum:1,"return":1,variou:[],get:[2,1],read:[],wai:[],"void":[],cover:1,initi:1,msmqtransportfactori:[],endpoint:[],"import":[],veri:1,world:[],iendpointresolv:[],now:1,discuss:[],like:[],name:[],specif:1,did:1,resolv:1,rabbitmq:2,"public":[],team:[],where:[],page:0,can:1,set:1,singlton:[0,1],map:[],cfg:[],some:[],product:[],intern:[],sampl:[],pattarn:1,controlbu:[],close:1,inboundpipelin:[],transport:1,excit:[],index:0,what:1,sub:[],space:[],avoid:1,publish:[],access:1,method:1,consumertyp:[],"new":1,subscript:[0,1],factori:[],localhost:1,unsubscribeact:[],machin:[],usemsmq:1,kei:[],gener:[],iservicebu:[],envelop:[],bodi:[],sbc:1,believ:[],tservic:[],releas:1,org:[],combin:[],outboundpipelin:[],describ:[],search:0,actual:[],pretti:1,cycl:1,nasti:1,manag:[0,1],queue:1,thing:[],multicast:1,grain:1,action:[],lambda:1,inmemori:[],singleton:1,point:[],zguid:[],overview:[],arrai:[],address:1,iendpoint:[],done:1,instal:[0,2],myconsum:1,open:1,your:1,select:1,compon:[],given:1,from:1,structuremapobjectbuild:[],convent:[],attach:[],interact:[],regist:[],messag:1,custom:1,itransportfactori:[],few:1,setup:1,interfac:[],too:1,lot:1,basic:[0,1],"var":1,call:[],zeromq:[],idispos:[],loadconsumersfromcontain:1,more:[],"function":1,udp:[],offer:[],inbound:[],getconsumeract:[],subscrib:1,about:[],untyp:1,link:2,gain:1,func:[],line:1,extens:1,activemq:[],than:[],had:1,multi:[0,1],made:[],createinst:1,instanc:[0,1],provid:1,type:1,servic:[],commerci:[],structur:[],"final":[],below:1,mostli:[],"typeof":1,abov:1,servicebusfactori:1,problem:[],poisonendpoint:[],have:1,getservic:[],year:[],share:1,ani:[],indic:0,right:[],want:1,tabl:0,need:1,serial:[],subscribeconsum:[],yadadadada:[],cours:1,end:1,welcom:0,msmq:[2,1],inform:1,receiv:1,windsor:1,write:1,binari:2,other:1,role:[],build:[],which:[],usemulticastsubscriptioncli:1,imessagepipelin:[],you:1,document:0,start:1,simplifi:[0,1],begin:1,http:[],allow:1,see:1,why:[],object:[],test_queu:1,busconfigur:[],hand:[0,1],plai:1,power:[],masstransit:[0,1],contain:1,respons:[],"class":[],built:[],framework:[],condit:[],builder:[],loopback:[],life:1,uri:[],deal:1,predic:[],thought:1,callback:[],exampl:1,environ:1,thi:1,structuremap:[],model:[],first:[],someth:1,talk:[],servicebu:[]},objtypes:{},titles:["Welcome to MassTransit&#8217;s documentation!","Configuration","Installation"],objnames:{},filenames:["index","config","installation"]})
Please sign in to comment.
Something went wrong with that request. Please try again.