Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. ...
  2. QueueServerConnection queueServerConnection = new QueueServerConnection();
  3. queueServerConnection.createConnection();
  4. queueServerConnection.sendMessage("Expired for user = " + userDAO.getUserId())
  5. queueServerConnection.closeConenction();
  6. ...
  7.  
  8.  
  9. ...
  10. ConnectionFactory factory = new ConnectionFactory();
  11. factory.setHost("localhost");
  12. Connection connection = factory.newConnection();
  13. Channel channel = connection.createChannel();
  14.  
  15. channel.queueDeclare(QUEUE_NAME, false, false, false, null);
  16. System.out.println(" [*] Waiting for messages...");
  17.  
  18. Consumer consumer = new DefaultConsumer(channel) {
  19.     @Override
  20.     public void handleDelivery(... byte[] body) throwsIOException {
  21.    
  22.     String message = new String(body, "UTF-8");
  23.     if( message.equals("EXpired") ){
  24.  
  25.             MailService mailService = new MailService("senderEmail","password");
  26.             mailService.sendMail("to", "Your time expired !)";
  27.         }
  28.  
  29.                 }
  30.     };
  31. ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement