i am trying to make a method async using @Async annotation provided by Spring 3.0
i have done following
inclued following in my module-context.xml
<task:executor id="initiateContactCreation" pool-size="2-10" queue-capacity="5"/>
<task:annotation-driven executor="initiateContactCreation" />
annotated method with @Async
@Async
private void initiateContactCreation(String fromUserId, List<String> toUsers){
logger.info("Inside Async method for contact creation");
ContactDetails contactDetails = new ContactDetails();
contactDetails.setUserId(fromUserId);
contactDetails.setContactEmailIds(toUsers.toArray(new String[toUsers.size()]));
this.contactsAndDirSvc.addContact(contactDetails);
logger.info("Returning from Async method for contact creation");
}
but i see that the method does not return control immediately.
my logger shows
logs from initiateContactCreation
then logs from addContact
(PS. it is taking time executing this method and i do not want it to be executed synchronously) and then logs from the method from where i am calling initiateContactCreation
what am i doing wrong?