问题标签 [spring-rabbit]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
1423 浏览

spring - 带有 AMQP 侦听器的春季批处理

我想将 Spring Batch 与 RabbitMQ 侦听器一起使用

当收到一条消息时,会调用第一步,并在每条消息接收后重复处理

这是我的听众:公共类 MyMessageListener 实现 MessageListener {

}

0 投票
1 回答
1856 浏览

java - 如何在死字中使用 RepublishMessageRecoverer?

我为我正在使用的几个队列设置了死字。在我使用的配置中:

如果我希望死信队列上的消息具有 x-exception-stacktrace ,我读到我需要使用 RepublishMessageRecoverer。在死字中使用它就像在上述设置中用 RepublishMessageRecoverer 替换 RejectAndDontRequeueRecoverer 一样简单,还是我需要编写自定义 messageRecoverer?

0 投票
0 回答
124 浏览

java - 尝试从 RabbitMQ 队列读取消息时出错

我有一个 MBean 试图获取队列中的消息:

当它从给定的 xml 文件创建上下文时,它不会替换属性值。例如:

它将主机值设置为 ${rabbit.connection.host} 而不是用属性文件中的值替换它。

需要进行哪些更改才能从属性文件中读取值?

0 投票
2 回答
7604 浏览

java - Spring AMQP RabbitMQ implementing priority queue

After Google for a few days, and i believe i am totally lost. I would like to implement a kind of priority queue that has about 3 queues:

  1. high priority queue (daily), that needs to be process first.
  2. mid priority queue (weekly), that will process if no items in queue #1. (it is ok message in this queue it never process at all)
  3. low priority queue (monthly), that will process if no items in queue #1 & #2. (it is ok message in this queue it never process at all)

Initially I have the following flow, to have a consumer to consume messages from all three queues and checks whether there is any items in queue #1, #2 and #3. and then I realize that this is wrong because:

  1. I am totally lost with a question: "How do I know which queue it is coming from?".
  2. I'm already consuming a message regardless from any queue, So if I get an object from lower priority queue, am I gonna put it back to the queue if I discover there is a message at the higher priority queue?

Following is my current configurations, which shows what an idiot I am.

Any idea how should I tackle this with priority queue?

ps: I also wonder, if Apache Camel has something I can depend on?

UPDATE 1: I just saw this from Apache Camel: "https://issues.apache.org/jira/browse/CAMEL-2537" the sequencer on JMSPriority seems to be what im looking for, anyone has tried this before?

UPDATE 2: assuming i am to use RabbitMQ's plugin base on @Gary Russell recommendation, I have the following spring-rabbitmq context XML configuration, which seems to make sense (by guest..):

The above xml configuration has successfully create a Queue, with name: "ad_google_dfa_reporting_queue", and with Parameter arguments: x-max-priority: 10 & durable: true

But not when comes to the code that send the message with priority, I totally lost it. How to define the priority as mention in the Sample URL: https://github.com/rabbitmq/rabbitmq-priority-queue/blob/master/examples/java/src/com/rabbitmq/examples/PriorityQueue.java

UPDATE 3: Based on the @Gary's answer, i manage to sent message with priority set in the message, as per image below: message priority screenshot However, when i sent in 1000 messages with random priority between 1-10, the consumer is consuming message with all kinds of priority. (I was expecting only the high priority message to be consume first). following is the code for Message producer:

And following is the code for Message consumer:

The result im getting:

UPDATE 4: Problem solved! Knowing the sample code from https://github.com/rabbitmq/rabbitmq-priority-queue is working in my environment, I presume that the problem is around the spring context. Hence, after countless time on try and error with different type of configurations, and I pin point the exact combination that will make this works! and is as per following:

Without specifically define the value is Integer type, the priority queue does not work. Finally, it is solved. Yay!

0 投票
1 回答
1256 浏览

spring-amqp - 抛出异常时更改消息头

在 MessageListener 内部我抛出异常。消息侦听器容器的默认行为是重新排队消息。我的问题 - 重新排队消息时是否可以更改消息标题?

0 投票
1 回答
3381 浏览

spring - spring rabbitmq 自动恢复启用

我们可以用这个bean来做spring-rabbitmq自动恢复吗,因为spring rabbit不支持

0 投票
1 回答
1208 浏览

java - RabbitMQ 固定回复和消费者配置

我的目标是实现以下目标:php代码向队列发送请求-java代码从代码中读取-java代码将回复发送到固定回复队列-php代码读取回复。我已经设置了以下测试(生产者现在在 java 中):

POJO:

配置:

调用main方法:

我有两个问题:

当我运行它时,我收到以下错误: RabbitTemplate [ERROR] 尽管我看到两个队列都收到了消息,但回复中没有相关标头。

第二个问题是我如何只运行消费者代码(监听器)而不发送消息(因为最终调用者不会是我的 java 代码)?

0 投票
1 回答
638 浏览

java - 在 rabbitmq 中配置优先级

我尝试更改以下配置以支持优先级队列。根据已完成的研究,它说我应该为每个优先级设置两个队列。我从以下调整了我的配置:

到以下:

我是否以正确的方式解决这个问题?现在我应该如何继续让消费者消费一个而不是另一个?

这就是我调用测试的方式:

这是我的 pojo 课:

两条消息都是通过发送的,但不确定如何使用已实现的配置和类实现优先级。

请注意,我试图避免使用任何插件来支持优先级。

0 投票
1 回答
7664 浏览

rabbitmq - 通过 RabbitMQ 发送文件

通过 RabbitMQ 发送大小约为 1Mb 的文件是个好主意吗?我想以 json 格式发送消息,其中包含与文件对应的二进制字段。

以及如何使用 spring-amqp 正确地做到这一点?只是通过下一个班级发布对象?

0 投票
1 回答
1274 浏览

java - 在 RabbitMQ 中检索队列的参数和属性

在 RabbitMQ 的 REST API 中,您可以获得现有队列的各种信息(http://rabbit.example.com:15672/api/queues/):

但是对于 Java 的 Spring-AMQP 或 RabbitMQ-client,这似乎是不可能的。

例如,像这样:

或者