Java ActiveMQ JMS正在丢失消息
我正在开发一个应用程序,后端是J2EE和Spring,前端是applet 在一些用户操作之后,后端发送有关activeMQ主题的消息,通知前端更新IHM 我面临一个问题,调用ActiveMQ代理发送消息,但前端没有接收所有消息,Java ActiveMQ JMS正在丢失消息,java,applet,jms,message,Java,Applet,Jms,Message,我正在开发一个应用程序,后端是J2EE和Spring,前端是applet 在一些用户操作之后,后端发送有关activeMQ主题的消息,通知前端更新IHM 我面临一个问题,调用ActiveMQ代理发送消息,但前端没有接收所有消息,MessageListener的onMessage()方法有时不会被调用。前端接收来自同一主题的同一类型的一些消息,但不是全部。这是一种随机行为 我的配置如下: activemq.xml broker-config.xml WEB-INF/config/jms/ac
MessageListener
的onMessage()
方法有时不会被调用。前端接收来自同一主题的同一类型的一些消息,但不是全部。这是一种随机行为
我的配置如下:
activemq.xml
broker-config.xml
WEB-INF/config/jms/activemq.xml
producer-config.xml
vm://localhost
真的
提醒
在客户端站点中,连接设置为:
hostName = (String) Applet.getCtx().getAttribute(Constants.SERVER_HOSTNAME);
//serverPort = (String) Applet.getCtx().getAttribute(Constants.SERVER_PORT);
serverPort = "18135";
if (log.isInfoEnabled()){
log.info("hostName :"+ hostName );
log.info("serverPort :"+ serverPort );}
if (StringUtils.isNotEmpty(hostName)&& StringUtils.isNotEmpty(serverPort)) {
connectionFactory = new ActiveMQConnectionFactory("tcp://"+ hostName + ":" + serverPort);
if (log.isInfoEnabled()){
log.info("connectionFactory: "+ connectionFactory);}
connection = (TopicConnection) connectionFactory.createConnection();
if (log.isInfoEnabled()){
log.info("connection : "+ connection ); }
connection.setClientID(myId);
createConsumer(connection);
connection.start();
// Permet une reconnexion du client avec une phase
// d'initialisation en cas de problème de connexion.
connection.setExceptionListener(new AbstractJMSExceptionListener(connectionFactory, connection) {
public void reinitialize() throws JMSException {
createConsumer(getExListenerConnection());
}
});
while (isRunning) {
Thread.sleep(5000);
}......
private void createConsumer(TopicConnection topicConnection)
throws JMSException {
if (log.isInfoEnabled()){
log.info("STEP createConsumer");}
// securise la reception de l'alerte
// Vis a vis du broker le message est acquitté seulement si on passe
// sur la methode acknowledge()
TopicSession session = topicConnection.createTopicSession(false,Session.CLIENT_ACKNOWLEDGE);
Topic topic = session.createTopic(SUBJECT);
TopicSubscriber subscriber = session.createSubscriber(topic);
subscriber.setMessageListener(this);
}
我已尝试使用KahaDB使消息持久化,并将
createSubscriber
更改为createDurableSubscriber
,但没有结果。我可以补充一下这个问题吗!?