activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexpeng <penzhen...@hotmail.com>
Subject activemq5.0,why can not recieve failure message.
Date Thu, 20 Mar 2008 19:02:57 GMT


question:

After I send message, I recieve it, then email this message using
processMsgInfo() function.
after that, I disconnect the network,then send message,processMsgInfo has
error,because it can not connect email server, the system gives me
information that can not send. but the message i can not find it in
database. why? 
I think it should be in database, when I reconnect network, the message
should be resend. 
Is there some thing wrong with my configuration. 


environment: activemq5.0, tomcat6, spring2.05. mysql5(localhost database)

applicationContext-jmx.xml 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:amq="http://activemq.org/config/1.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
         http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
         http://activemq.org/config/1.0
http://activemq.apache.org/schema/core/activemq-core-5.0.0.xsd">

	<bean id="connectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
		<property name="brokerURL" value="vm://localhost" />
		<property name="redeliveryPolicy">
			<bean class="org.apache.activemq.RedeliveryPolicy">
  				<property name="backOffMultiplier" value="2" /> 
  				<property name="initialRedeliveryDelay" value="10" /> 
  				<property name="maximumRedeliveries" value="3" /> 
  				<property name="useExponentialBackOff" value="true" /> 
  			</bean>
  		</property>
	</bean>

	<bean id="msgDestination"
class="org.apache.activemq.command.ActiveMQQueue">
		<constructor-arg index="0" value="myQueue" />
	</bean>

	<!-- Message converter bean -->
	<bean id="msgConverter" class="com.golemur.jms.MsgMessageConverter" />

	<!-- The JmsTemplate -->
	<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
		<property name="connectionFactory">
		     <bean
class="org.springframework.jms.connection.SingleConnectionFactory">
        		<property name="targetConnectionFactory">
          			<ref local="connectionFactory" />
        		</property>
      		</bean>
		</property>
		<property name="defaultDestination" ref="msgDestination" />
		<property name="messageConverter" ref="msgConverter"></property>
		<property name="receiveTimeout" value="60000" />
	</bean>

	<!-- JMS transaction manager -->
	<bean id="jmsTransactionManager"
class="org.springframework.jms.connection.JmsTransactionManager">
		<property name="connectionFactory" ref="connectionFactory" />
	</bean>

	<!-- DefaultMessageListenerContainer-->

	<bean
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
		<property name="connectionFactory" ref="connectionFactory" />
		<property name="destination" ref="msgDestination" />
		<property name="concurrentConsumers" value="1" />
		<property name="messageListener" ref="msgMdp" />
		<property name="sessionAcknowledgeModeName" value="CLIENT_ACKNOWLEDGE"/>
		<property name="transactionManager" ref="jmsTransactionManager" />
		<property name="receiveTimeout" value="-1"/>
	</bean>

	<!-- message sender beans -->
	<bean id="msgMessageImpl" class="com.golemur.jms.MsgMessageImpl">
		<property name="jmsTemplate" ref="jmsTemplate" />
		<property name="destination" ref="msgDestination" />
	</bean>

    <bean id="messageProducer" class="com.golemur.jms.MessageProducer">
		<property name="msgMessageImpl">
			<ref bean="msgMessageImpl" />
		</property>
	</bean>

	<!-- MessageMdp-->
	<bean id="msgMdp" class="com.golemur.jms.MessageMdp" />

	<!-- 
	<bean id="pureMdp"
class="org.springframework.jms.listener.adapter.MessageListenerAdapter">
    	<property name="delegate" ref="msgMdp" />
    	<property name="defaultListenerMethod" value="processMsgInfo" />
    	<property name="messageConverter" ref="msgConverter" />
  	</bean>
	-->
</beans>


applicationContext-jmx.xml   this is for the broker

<?xml version="1.0" encoding="UTF-8"?>
<beans 
  xmlns="http://www.springframework.org/schema/beans" 
  xmlns:amq="http://activemq.org/config/1.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
  http://activemq.org/config/1.0
http://activemq.apache.org/schema/core/activemq-core-5.0.0.xsd">

  <amq:broker useJmx="true" persistent="true"> 
    <amq:persistenceAdapter> 
        <amq:jdbcPersistenceAdapter dataSource="#mysql-ds"/> 
        <!-- 
      	<journaledJDBC journalLogFiles="5"
dataDirectory="${basedir}/activemq-data" dataSource="#mysql-ds"/>
       	-->
      </amq:persistenceAdapter> 
    <amq:transportConnectors> 
       <amq:transportConnector
uri="tcp://localhost:0?broker.persistent=true"/> 
    </amq:transportConnectors> 
   </amq:broker>
  
  <!-- MySql DataSource Setup -->
  <bean id="mysql-ds" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
    <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
    <property name="url"
value="jdbc:mysql://localhost/activemq?relaxAutoCommit=true"/>
    <property name="username" value="activemq"/>
    <property name="password" value="activemq"/>
    <property name="poolPreparedStatements" value="true"/>
  </bean>
</beans>


messageMDP.java for asychronized to recieve the message. 
	public void onMessage(Message message) {

		try {
			System.out.println("delivermode::" + message.getJMSDeliveryMode());

			if (message.getJMSRedelivered()) {
				log.error("This message was redelivered:" + message);
			} else {

				MapMessage mapMessage = (MapMessage) message;
				mapMessage.setJMSDeliveryMode(DeliveryMode.PERSISTENT);

				MessageVO msg = new MessageVO();
				msg.setMsgType(mapMessage.getString("msgType"));
				msg.setFromUser(mapMessage.getString("fromUser"));
				msg.setToUser(mapMessage.getString("toUser"));
				msg.setMessage(mapMessage.getString("message"));
				msg.setTime(mapMessage.getString("time"));
				msg.setEmail(mapMessage.getString("email"));
				msg.setTitle(mapMessage.getString("title"));

				processMsgInfo(msg);

			}
			message.acknowledge();
		} catch (JMSException e) {
			log.error("Jms error:::" + e.getMessage());
		} catch (Exception e) {
			log.error("MsgInfo error:::" + e.getMessage());
		}
	}

thanks

Alex

-- 
View this message in context: http://www.nabble.com/activemq5.0%2Cwhy-can-not-recieve-failure-message.-tp16186330s2354p16186330.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message