javax.mail.event.MessageCountEvent Java Examples

The following examples show how to use javax.mail.event.MessageCountEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MailNotificationService.java    From camunda-bpm-mail with Apache License 2.0 6 votes vote down vote up
public void start(String folderName) throws Exception {
	executorService = Executors.newSingleThreadExecutor();

	Folder folder = mailService.ensureOpenFolder(folderName);

	folder.addMessageCountListener(new MessageCountAdapter() {
		@Override
		public void messagesAdded(MessageCountEvent event) {
			List<Message> messages = Arrays.asList(event.getMessages());

			handlers.forEach(handler -> handler.accept(messages));
		}
	});

	if (supportsIdle(folder)) {
		notificationWorker = new IdleNotificationWorker(mailService, (IMAPFolder) folder);
	} else {
		notificationWorker = new PollNotificationWorker(mailService, folder,
				configuration.getNotificationLookupTime());
	}

	LOGGER.debug("start notification service: {}", notificationWorker);

	executorService.submit(notificationWorker);
}
 
Example #2
Source File: ArdulinkMailMessageCountAdapter.java    From Ardulink-1 with Apache License 2.0 6 votes vote down vote up
public void messagesAdded(MessageCountEvent ev) {
    Message[] msgs = ev.getMessages();
    System.out.println("Got " + msgs.length + " new messages");

    for (int i = 0; i < msgs.length; i++) {
		try {
			manageMessage(msgs[i]);
		} catch (IOException ioex) { 
		    ioex.printStackTrace();	
		} catch (MessagingException mex) {
		    mex.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}
    }
}
 
Example #3
Source File: IMAPAdapter.java    From hana-native-adapters with Apache License 2.0 6 votes vote down vote up
public void messagesAdded(MessageCountEvent ev) {
	Message[] msgs = ev.getMessages();
	try {
		for (int i = 0; i < msgs.length; i++) {
			addCDCRow(INBOX, msgs[i], RowType.INSERT);
			msgs[i].writeTo(System.out);
		}
		commit();
	} catch (IOException | MessagingException | AdapterException e) {
		e.printStackTrace();
		try {
			Subscriptions s = getSubscriptions();
			SubscriptionInformationPerTablename sub = s.get("RSSFEED");
			if (sub != null) {
				for (SubscriptionRuntimeInformation rs : sub.getSubscriptionList().values()) {
					stop(rs.getSubscriptionSpecification());
				}
			}
		} catch (AdapterException e1) {
		}
	}
}
 
Example #4
Source File: ArdulinkMailMessageCountListener.java    From Ardulink-1 with Apache License 2.0 5 votes vote down vote up
public void messagesAdded(MessageCountEvent ev) {
    Message[] msgs = ev.getMessages();
	logger.info("Got {} new messages", msgs.length);

    for (int i = 0; i < msgs.length; i++) {
		try {
			manageMessage(msgs[i]);
		} catch (IOException ioex) { 
		    ioex.printStackTrace();	
		} catch (MessagingException mex) {
		    mex.printStackTrace();
		}
    }
}
 
Example #5
Source File: Main.java    From javamail-mock2 with Apache License 2.0 4 votes vote down vote up
@Override
public void messagesAdded(final MessageCountEvent e) {
    addedCount++;

}
 
Example #6
Source File: Main.java    From javamail-mock2 with Apache License 2.0 4 votes vote down vote up
@Override
public void messagesRemoved(final MessageCountEvent e) {
    removedCount++;

}
 
Example #7
Source File: IMAPTestCase.java    From javamail-mock2 with Apache License 2.0 4 votes vote down vote up
@Override
public void messagesAdded(final MessageCountEvent e) {
    addedCount++;

}
 
Example #8
Source File: IMAPTestCase.java    From javamail-mock2 with Apache License 2.0 4 votes vote down vote up
@Override
public void messagesRemoved(final MessageCountEvent e) {
    removedCount++;

}
 
Example #9
Source File: EmailMessageCountListener.java    From mumu with Apache License 2.0 2 votes vote down vote up
public void messagesAdded(MessageCountEvent e) {
	
}
 
Example #10
Source File: EmailMessageCountListener.java    From mumu with Apache License 2.0 2 votes vote down vote up
public void messagesRemoved(MessageCountEvent e) {
	
}