我在使用队列中的消息时遇到问题。我已经定义了一个侦听器,但是由于某些原因,我不能使用任何消息。我在onmessage函数中设置了断点,但它们从未被命中。这是我的代码文件。不确定这里出了什么问题:
配置文件:
<rabbit:connection-factory id="emailAccountConnectionFactory" host="localhost"/>
<rabbit:template id="amqpTemplate" connection-factory="emailAccountConnectionFactory"
exchange="emailAccountExchange" routing-key="email.Account"/>
<!-- <rabbit:admin connection-factory="emailAccountConnectionFactory" />-->
<rabbit:queue id="emailAccount" name="emailAccountQueue"/>
<rabbit:direct-exchange name="emailAccountExchange">
<rabbit:bindings>
<rabbit:binding queue="emailAccount" key="email.Account" />
</rabbit:bindings>
</rabbit:direct-exchange>
<rabbit:listener-container connection-factory="emailAccountConnectionFactory" acknowledge="none">
<rabbit:listener ref="emailAccountAckListener" queue-names="emailAccountQueue" />
</rabbit:listener-container>
<bean id="emailAccountAckListener" class="start.web.listener.registration.EmailAccountAckListener" />
消息侦听器类:
package start.web.listener.registration;
import java.util.Map;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageListener;
import org.springframework.stereotype.Component;
import start.web.common.EventHandler;
import start.web.common.Events;
@Component
public class EmailAccountAckListener implements MessageListener {
public void onMessage(Message message) {
System.out.print("Message Received");
EventHandler.handler((Events) ((Map<String, Object>)
message).get("event"), ((Map<String, Object>)
message).get("message"));
}
}
我无法在onmessage函数中命中断点。另外,在rabbitmq的管理控制台上,我看不到队列的任何使用者。我不确定我在配置中做错了什么。以下是队列管理控制台的屏幕截图:
暂无答案!
目前还没有任何答案,快来回答吧!