<p>Does anyone have an example of using selectors in GO? According to the STOMP documentation, they are passed in at subscription time, but I've yet to find an example of this.</p>
<hr/>**评论:**<br/><br/>metakeule: <pre><p>Not being familiar with STOMP, may I ask what you mean exactly with "selectors"?</p></pre>salopru: <pre><p>Selectors are, in a nutshell, message filters. See the table "ActiveMQ Extensions to STOMP"
at <a href="http://activemq.apache.org/stomp.html" rel="nofollow">http://activemq.apache.org/stomp.html</a> for a description</p></pre>schoenobates: <pre><p>This library <a href="https://godoc.org/github.com/jjeffery/stomp" rel="nofollow">https://godoc.org/github.com/jjeffery/stomp</a> seems to let you set subscribe option headers:</p>
<p><a href="https://godoc.org/github.com/jjeffery/stomp#Conn.Subscribe" rel="nofollow">https://godoc.org/github.com/jjeffery/stomp#Conn.Subscribe</a></p>
<p>See example 2 - looking at the spec, I'm guessing these selectors are server specific?</p>
<p><a href="http://stomp.github.io/stomp-specification-1.1.html#SUBSCRIBE" rel="nofollow">http://stomp.github.io/stomp-specification-1.1.html#SUBSCRIBE</a></p></pre>salopru: <pre><p>Great, thank you! This works:</p>
<pre><code>amqSelector = `_category='books' AND _attr='title'`
sub, err := conn.Subscribe("/queue/SomeQueue", stomp.AckClient,
stomp.SubscribeOpt.Header("selector", amqSelector))
</code></pre></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传