RabbitMQ Exchange排除队列(RabbitMQ Exchange exclude queue)
我尝试使用RabbitMQ制作聊天应用程序。
每个会话组都有
fanout
交换,组成员推送消息并绑定队列。但是由于这样的路由成员会收到自己的消息,所以我必须在客户端代码中过滤它们。
有没有办法如何进行排除模式匹配,所以交换不会使用相同的密钥向队列发送消息?
I try to make chat application using RabbitMQ.
Every conversation group has
fanout
exchange, to which group members push messages and bind their queues.But with such routing members receive their own messages, so I have to filter them in the client code.
Is there any way how to make exclude pattern matching, so exchange would not send message to the queue with the same key?
原文:https://stackoverflow.com/questions/37880974
最满意答案
Rails的部分渲染过程是评估该视图中的所有erb代码。 一旦代码评估完成后,rails会渲染文件(无论是javascript,html等)。
所以当你说你很惊讶地看到Rails可以响应变化的变化时,这是因为视图并没有真正呈现在这个点上......它正在渲染过程中。
Part of the rendering process for rails is to evaluate all the erb code within that view. Once the evaluation of the code is completed, rails will then render the file(whether it is javascript, html, etc).
So when you say that you were surprised to see that rails could respond to a variable change, it's because the view wasn't actually rendered at that point... it was in the process of rendering.
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
-
你真的应该使用AJAX(我推荐jQuery )。 您将希望让JS将请求中的JavaScript变量作为参数发送回您的Rails服务器。 You really should use AJAX (I recommend jQuery) for this. You'll want to have JS send a request back to your Rails server with the JavaScript variable as a param in the request.
-
Rails - 确定在JavaScript函数中设置Rails变量?(Rails - OK to set a Rails variable inside a javascript function?)[2024-03-14]
Rails的部分渲染过程是评估该视图中的所有erb代码。 一旦代码评估完成后,rails会渲染文件(无论是javascript,html等)。 所以当你说你很惊讶地看到Rails可以响应变化的变化时,这是因为视图并没有真正呈现在这个点上......它正在渲染过程中。 Part of the rendering process for rails is to evaluate all the erb code within that view. Once the evaluation of the code ... -
如果您使用的是rails 3.1,则可以利用资产管道对javascript文件进行一些预处理,然后再进行提供。 要执行此操作,只需更改文件扩展名: items.js.coffee 至 items.js.coffee.erb 然后你就可以像使用<%= %>标签在视图中一样为你的javascript添加ruby。 您可能遇到的唯一问题是,您的items.js文件将被提供给您的任何应用程序控制器方法的每个请求。 因此,最好编写一个辅助方法,只有在初始化实例变量时才会返回值 例如,在items_helper.r ...
-
如何在javascript escape_javascript rails中使用变量?(How to use variable in javascript escape_javascript rails?)[2022-10-18]
从 "<%= escape_javascript(render :partial =>'my_partial', :locals => { id:id} ) %>" 至 "<%= escape_javascript(render :partial =>'my_partial', :locals => { id:"+id+"} ) %>" From "<%= escape_javascript(render :partial =>'my_partial', :locals => { id:id} ) %> ... -
在这种情况下,将upvote计数传递给upDateCount可能更容易 format.js {render :js =>"upDateCount(#{@source.upvotes.count})"} 并使用参数而不是gon数据。 In this case it might be easier to pass upvote count to upDateCount format.js {render :js =>"upDateCount(#{@source.upvotes.count})"} and u ...
-
这不起作用,因为: 让我们说这个表单在控制器'Post'的'new'中被渲染,然后@less_per_unit需要被初始化以在你正在使用的那个动作的视图文件中使用它。 当您使用AJAX调用时以及在调用期间,您正在定义一个实例变量,该变量肯定不会被已呈现的html文件访问。 因此,您需要从check_increment动作中返回JSON数据,并在AJAX调用响应中接收该数据,然后使用它。 This is not working because: Let us say this form is rendered ...
-
正如Aleks所说,你不能这样做,因为你在回调中调用的函数中使用ruby代码。 实现您想要做的最简单的方法是在服务器获取的json数据中传递公司名称。 如果您使用to_json呈现json响应,请尝试以下操作 render json: @records.to_json(methods: [:company_name]) 然后在模型中添加company_name方法 def company_name company.name end As Aleks said, you can't do th ...