RabbitMQ

RabbitMQ中文文档PHP版本(六)--远程过程调用(RPC)

喜欢而已 提交于 2020-01-07 00:21:18
2019年12月10日10:05:54 原文: https://www.rabbitmq.com/tutorials/tutorial-six-php.html 远程过程调用(RPC) (使用 php-amqplib ) 先决条件 本教程假定RabbitMQ 已 在标准端口( 5672 )的 本地主机 上 安装 并运行 。 如果您使用其他主机,端口或凭据,则连接设置需要进行调整。 在哪里获得帮助 如果您在阅读本教程时遇到困难,可以 通过邮件列表 与我们 联系。 在 第二篇教程中, 我们学习了如何使用 工作队列 在多个工作人员之间分配耗时的任务。 但是,如果我们需要在远程计算机上运行功能并等待结果怎么办? 好吧,那是一个不同的故事。 这种模式通常称为“ 远程过程调用” 或“ RPC” 。 在本教程中,我们将使用RabbitMQ构建RPC系统:客户端和可伸缩RPC服务器。 由于我们没有值得分配的耗时任务,因此我们将创建一个虚拟RPC服务,该服务返回斐波那契数。 客户端界面 为了说明如何使用RPC服务,我们将创建一个简单的客户端类。 它将公开一个名为 call 的方法,该方法 发送RPC请求并阻塞,直到收到答案为止: $ fibonacci_rpc = 新的 FibonacciRpcClient(); $ response = $ fibonacci_rpc-> call(30);

RabbitMQ中文文档PHP版本(七)--发布者确认

久未见 提交于 2020-01-07 00:20:10
2019年12月10日10:07:12 原文: https://www.rabbitmq.com/tutorials/tutorial-seven-java.html 注意这里目前没有PHP版本只有java版本 发布者确认 发布者确认 是实现可靠发布的RabbitMQ扩展。 在通道上启用发布者确认后,代理将异步确认客户端发布的消息,这意味着它们已在服务器端处理。 (使用Java客户端) 先决条件 本教程假定RabbitMQ 已 在标准端口( 5672 )的 本地主机 上 安装 并运行 。 如果您使用其他主机,端口或凭据,则连接设置需要进行调整。 在哪里获得帮助 如果您在阅读本教程时遇到困难,可以 通过邮件列表 与我们 联系。 总览 在本教程中,我们将使用发布者确认来确保发布的消息已安全到达代理。 我们将介绍几种使用发布者确认并解释其优缺点的策略。 在频道上启用发布者确认 发布者确认是AMQP 0.9.1协议的RabbitMQ扩展,因此默认情况下未启用它们。 发布者确认在通道级别使用 confirmSelect 方法 启用 : Channel channel = connection.createChannel(); channel.confirmSelect(); 必须在希望使用发布者确认的每个频道上调用此方法。 确认仅应启用一次,而不是对每个已发布的消息都启用。 策略1

Is RabbitMQ Clustering including scalability too?

对着背影说爱祢 提交于 2020-01-07 00:03:30
问题 I want to build a RabbitMQ system which is able to scale out for the sake of performance. I've gone through the official document of RabbitMQ Clustering. However, its clustering doesn't seem to support scalability. That's because only through master queue we can publish/consume, even though the master queue is reachable from any node of a cluster. Other than the node on which a master queue resides, we can't process any publish/consume. Why do we cluster then? 回答1: Why do we cluster then? To

RabbitMQ Header Exchange using a “NOT” or “Didn't fit anyone else go here”

霸气de小男生 提交于 2020-01-06 23:49:53
问题 I've been learning RabbitMQ the last couple weeks. I'm trying to setup a desicision tree type routing using a "Header" Exchange. I know how to brach it out if it matches. But I want a "catch all" queue that's only sent to if the header didn't match anything else in the tree. So Exchange1 -> if header.value1 = "company1" then goto queue "company1" -> if header.value1 = "company2" then goto queue "company2" -> if header.value1 didn't match anyone else then goto queue "catch all" I got the first

SpringBoot整合RabbitMQ

霸气de小男生 提交于 2020-01-06 18:53:02
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> SpringBoot框架已经提供了RabbitMQ的使用jar包,开发人员在使用RabbitMQ的时候只需要引用jar包简单的配置一下就可以使用RabbitMQ,这极大的简化了开发人员的开发成本,提升开发效率。 话不多说,直接上代码: 先在 pom.xml 文件添加依赖 spring-boot-starter-amqp 如下: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <artifactId>spring-boot-rabbitmq</artifactId> <version>1.0-SNAPSHOT</version> <description>springboot整合RabbitMQ的示例<

Amqp client not connecting to activemq server.

不羁的心 提交于 2020-01-06 17:41:37
问题 I'm trying connect from a amqp client to a aqtivemq server with default settings. It always gives the error message saying connection refused. Then I tried it with a rabbitmq server instead of a activemq server and it works fine. I wonder whether activemq needs a linux library to communicate. Activemq server versions used which does not connects: 5.4.2 / 5.10.0 Rabitmq version used: 3.3.5 rabitmq sample client code import com.rabbitmq.client.ConnectionFactory; import com.rabbitmq.client

rabbitmq 消息队列消息数量变化示例

孤街醉人 提交于 2020-01-06 17:18:46
rabbitmq 消息队列消息数量变化示例 rabbitmq 消息队列消息数量变化说明(后附go代码) 服务器和消费者之间的网络缓冲为1 服务器和消费者之间的网络缓冲为2 生产者代码 消费者代码 rabbitmq 消息队列消息数量变化说明(后附go代码) 预先给消息队列发布5条信息 服务器和消费者之间的网络缓冲为1 依次读取五条消息后,消息队列消息数量变化 服务器和消费者之间的网络缓冲为2 生产者代码 package main import ( "fmt" "log" "test1/amqp" "strconv" ) func failOnError(err error, msg string) { if err != nil { fmt.Printf("%s: %s\n", msg, err) } } func f6(){ conn, err := amqp.Dial("amqp://fm:1@192.168.7.29:5672/fm") failOnError(err, "Failed to connect to RabbitMQ") defer conn.Close() ch, err := conn.Channel() failOnError(err, "Failed to open a channel") defer ch.Close() q, err := ch

AMQP (rabbitmq) identify origin of bad message

99封情书 提交于 2020-01-06 05:29:08
问题 What is the best way to identify the origin of a (bad) AMQP message in rabbitmq? The scenario is several clients posts messages to a server which if successful result in messages posted to a fanout exchange (for pub/sub use). The client is also a subscriber to this queue and does not have a reply queue of its own. If the server decides a message is invalid it nacks and discards it. There are two additional things we want: to publish a message which either the client or a monitoring system

Handling dead letter queue with delay

大憨熊 提交于 2020-01-06 04:38:07
问题 I want to do the following: when a message fails and falls to my dead letter queue, I want to wait 5 minutes and republishes the same message on my queue. Today, using Spring Cloud Streams and RabbitMQ, I did the following code Based on this documentation: @Component public class HandlerDlq { private static final Logger LOGGER = LoggerFactory.getLogger(HandlerDlq.class); private static final String X_RETRIES_HEADER = "x-retries"; private static final String X_DELAY_HEADER = "x-delay"; private

How to log Queue name in SimpleMessageListenerContainer.java

て烟熏妆下的殇ゞ 提交于 2020-01-06 04:17:04
问题 We're having issues with one of the consumers, and need to debug the code. SimpleRabbitListenerContainerFactory allows to set a ConsumerTagStrategy, which should add tags during logging. @Bean public SimpleRabbitListenerContainerFactory analyzeTransactionListenerContainerFactory(ConnectionFactory connectionFactory, AsyncTaskExecutor asyncTaskExecutor) { connectionFactory.getVirtualHost()); SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory(); factory