在 /src/spring-jms-dev.xml 增加名稱為 Trully 的 consumer
...
<bean id="trullyConsumer" class="net.sweet.jms.consumer.Trully" />
<jms:listener-container connection-factory="consumerConnectionFactory" destination-type="queue"
message-converter="messageConverter"
concurrency="1">
<jms:listener destination="trully" ref="trullyConsumer" method="onMessage" />
</jms:listener-container>
...
新增 net.sweet.jms.consumer.Trully 的 java code
package net.sweet.jms.consumer; import net.sweet.encode.EncodeObject; import net.sweet.vlog.util.LoggerHelper; import org.apache.activemq.command.ActiveMQMapMessage; import org.apache.log4j.Logger; public class Trully { private static Logger log = Logger.getLogger(EncodeAudio.class); public void onMessage(Object message) { ActiveMQMapMessage msg = (ActiveMQMapMessage) message; LoggerHelper loggerHelper = null; EncodeObject obj = null; try { obj = new EncodeObject(msg, log); loggerHelper = new LoggerHelper(log, "/home/logs/jmsc/msg/" + obj.getMsgID() + ".log"); loggerHelper.log("Trully test Consuming msgID::::::"+obj.getMsgID()); loggerHelper.log("trully test consumer last line !!"); } catch (Throwable e) { loggerHelper.log(e); } loggerHelper = null; msg = null; obj = null; } }
沒有留言:
張貼留言