基本信息
源码名称:ActiveMQ数据访问减压
源码大小:52.15M
文件格式:.rar
开发语言:Java
更新时间:2016-06-02
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 19 元 
   源码介绍
:短信发送 时:当客户大批量的发送短信时,一次给上万人发送短信

public class NxtReceiveMqBaseOld {
               private static Connection connection;
               private static ConnectionFactory connectionFactory;
               private static Session session;
               private static String brokerURL="";
               private static Destination destination;
              
               public void init(){
                   try {
                  connectionFactory=new ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_USER, ActiveMQConnection.DEFAULT_PASSWORD, brokerURL);
  ((ActiveMQConnectionFactory)connectionFactory).setOptimizeAcknowledge(false);
                  connection=connectionFactory.createConnection();
                  ((ActiveMQConnection)connection).setOptimizeAcknowledge(false);
  connection.start();
  session=connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                   } catch (JMSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
               }
               public void unicode(){
              BrokerService broker=new BrokerService();
              try {
              
broker.addConnector(brokerURL);
broker.start();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
               }
               private static  MessageConsumer consumer;
               public boolean receveiMessage(String topic,String brokerURL, boolean send){
              try{
              this.brokerURL=brokerURL;
              init();
              destination=session.createTopic(topic);
              consumer=session.createConsumer(destination);
              consumer.setMessageListener(new MessageListener() {
@Override
public void onMessage(Message data) {
 try {
TextMessage textMessage=(TextMessage)data;
String wang=textMessage.getText();
System.out.println(wang);
ReceiveTopic topic=new ReceiveTopic();
topic.result(wang);
} catch (JMSException e) {

e.printStackTrace();

}
 
}
});
              }catch(Exception e){
              send=false;
              }
              return send;
               }
               public static void main(String[] args) throws JMSException {
              boolean send=true;
              NxtReceiveMqBaseOld nxt=new NxtReceiveMqBaseOld();
              send=nxt.receveiMessage("FirstTopic", "tcp://192.168.0.239:61616",send);
              while(!send){
              System.out.println("重新发送");
              send=nxt.receveiMessage("FirstTopic", "tcp://192.168.0.239:61616",send);
              }
}
}