Java Azure with Spring JMS接收相同的消息并多次接收,消息被移动到DLQ中
我正在使用qpid amqp-1-0-client和相关JAR创建消费者,以连接到Azure服务总线。我能够连接到Azure队列并接收消息,但问题是,尽管我在处理消息之前已确认,但我仍多次从队列接收到同一消息。大多数时候,我的邮件都会被移动到DLQ中 例如,若队列中有500条消息,那个么覆盖MessageListener.onMessage()的onMessage()方法将执行500多次。将近200条消息被推送到DLQ中。我正在从队列中读取消息并将其存储在数据库中。这些数字并不总是一样的。为了在DB中读取和存储消息,我的应用程序需要600毫秒。 PFB我的代码,其中包含用于连接Azure的配置Java Azure with Spring JMS接收相同的消息并多次接收,消息被移动到DLQ中,java,azure,azureservicebus,azure-servicebus-queues,qpid,Java,Azure,Azureservicebus,Azure Servicebus Queues,Qpid,我正在使用qpid amqp-1-0-client和相关JAR创建消费者,以连接到Azure服务总线。我能够连接到Azure队列并接收消息,但问题是,尽管我在处理消息之前已确认,但我仍多次从队列接收到同一消息。大多数时候,我的邮件都会被移动到DLQ中 例如,若队列中有500条消息,那个么覆盖MessageListener.onMessage()的onMessage()方法将执行500多次。将近200条消息被推送到DLQ中。我正在从队列中读取消息并将其存储在数据库中。这些数字并不总是一样的。为了在
@Configuration
public class AzureConfiguration {
@Bean
public ConnectionFactory jmsConnectionFactory() {
CachingConnectionFactory cachingConnectionFactory = null;
try {
ConnectionFactoryImpl a = ConnectionFactoryImpl.createFromURL(url);
a.setMaxPrefetch(0);
a.setSyncPublish(true);
cachingConnectionFactory = new CachingConnectionFactory(a);
cachingConnectionFactory.setReconnectOnException(true);
cachingConnectionFactory.setClientId(applicationName);
exceptionListener.setCachedConnFactory(cachingConnectionFactory);
} catch (MalformedURLException e) {
}
return cachingConnectionFactory;
}
@Bean
public MessageListenerContainer getContainer() {
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
container.setConnectionFactory(jmsConnectionFactory());
container.setDestinationName(queueName);
container.setMessageListener(messageConsumer);
container.setConcurrency(concurrency);
exceptionListener.setContainer(container);
container.setExceptionListener(exceptionListener);
container.setAutoStartup(true);
container.setSessionAcknowledgeMode(2);
return container;
}
}
以及我的依赖关系:
org.springframework
SpringJMS
org.apache.commons
commons-lang3
3.5
org.springframework.boot
弹簧靴起动器执行器
org.springframework.boot
SpringBootStarterWeb
org.apache.geronimo.specs
geronimo-jms_1.1_规范
1.1.1
org.apache.qpid
qpid-amqp-1-0-client
0.30
org.apache.qpid
qpid-amqp-1-0-client-jms
0.30
org.apache.qpid
qpid-amqp-1-0-common
0.30
请提供帮助。您使用的是旧版AMQP 1.0 JMS客户端,该客户端不受支持,并且未实现当前的AMQP JMS映射规范。它不起作用并不奇怪。使用更新的、现在只支持Qpid中的AMQP JMS客户机,您应该会有更好的运气
org.apache.qpid
qpid jms客户端
0.21.0
<dependency>
<groupId>org.apache.qpid</groupId>
<artifactId>qpid-jms-client</artifactId>
<version>0.21.0</version>
</dependency>