Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Developers

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-20-2011, 04:41 PM
Junior Member
 
Posts: 9
Default Java Soap Notification Example

Hi.

I try to connect our Spring App with Zimbra. I get ldap auth and calendar management working, but i don't find any infomations about the SOAP Notifications system.

I need notification events for new incoming mails on all accounts inside a domain.

To get all mailboxes i use this code

Code:
private List<ZMailbox>	mailboxList	= new ArrayList<ZMailbox>();
Code:
try {
	SoapProvisioning spAdmin = new SoapProvisioning();
	spAdmin.soapSetURI(adminURL);
	spAdmin.soapAdminAuthenticate(this.username, this.password);
	Domain domain = spAdmin.getDomainByName("mydomain.net");
	List<Account> accounts = domain.getAllAccounts();
	for (Account account : accounts) {
		logger.debug("ACCOUNT: "+account.getName());
		Options options = new Options(spAdmin.getAuthToken().getValue(), adminURL);
		options.setTargetAccount(account.getName());
		options.setTargetAccountBy(AccountBy.name);
		ZMailbox mbox = new ZMailbox(options);
		this.mailboxList.add(mbox);
	}
} catch (ServiceException e) {
}
TimerTask for send NoOp request to keep soap session alive
Code:
Iterator<ZMailbox> mailboxIter = mailboxList.iterator();
while (mailboxIter.hasNext()) {
	try {
		ZMailbox mbox = mailboxIter.next();
		mbox.noOp();
	} catch (ServiceException e) {
		e.printStackTrace();
	}
}
but how can i get the notifications about new mails in each postbox?

greets Rizzi
Reply With Quote
  #2 (permalink)  
Old 08-23-2011, 08:20 AM
Junior Member
 
Posts: 9
Default

Has no one an idea? i can't figure out to get the notifications.
Reply With Quote
  #3 (permalink)  
Old 08-23-2011, 10:17 AM
Project Contributor
 
Posts: 92
Default

As far as I remember, NoOp SOAP response includes the notifiation you want and you have to keep sending NoOp requests at some interval(polling)
or send NoOp request and keep the HTTP connection(long polling) to receive notification.
Reply With Quote
  #4 (permalink)  
Old 08-23-2011, 11:17 AM
Junior Member
 
Posts: 9
Default

Hi..
Thanks for the comment.

I sent NoOp Request inside a timer, but NoOp is void and has no return value
or miss understand somethink

greets Rizzi
Reply With Quote
  #5 (permalink)  
Old 08-27-2011, 03:46 AM
Project Contributor
 
Posts: 92
Default

NoOp function is implemented like this;
Code:
public void noOp() throws ServiceException {
        invoke(newRequestElement(MailConstants.NO_OP_REQUEST));
    }
So how about directly calling invoke method like this and keep the return to some variables in your source code so you can look into the response, can't you?
Could you try that?

By the way, if your source code works, you basically keep sending NoOp requests to all users in some interval.
Am i right?
If so, it could consume a lot of system resource.
How about implementing callback function which is called when every message is received?

You can see the short explanation about it here;
Yutaka-Notes about Extensible Classes In ZimbraStore - Zimbra :: Wiki
Reply With Quote
  #6 (permalink)  
Old 08-28-2011, 04:49 AM
Junior Member
 
Posts: 9
Default

Ok Thanks. I give it a try.

greets Rizzi
Reply With Quote
  #7 (permalink)  
Old 08-28-2011, 11:50 PM
Junior Member
 
Posts: 9
Default

Hi.

I think the LmtpCallback is the better way, but i can't find the method to get the LmtpBackend, for adding my custom callback function in the SoapProvisioning.

greets Rizzi
Reply With Quote
  #8 (permalink)  
Old 08-29-2011, 09:28 AM
Project Contributor
 
Posts: 92
Default

AFAIK, you can not do that with SoapProvisioning.

You have to create Zimbra Extension module which include your own class with your custom callback function like following;
» Zimbra :: Blog

You just implement extension's init function in which you register your own callback function to ZimbraLmtpBackend class with something like this;

Quote:
ZimbraLmtpBackend.addCallback(<yourownclass>.getIn stance());
ZimbraLmtpBackend.addCallback(QuotaWarning.getInst ance());
Reply With Quote
  #9 (permalink)  
Old 09-13-2011, 07:16 AM
Junior Member
 
Posts: 9
Default

Hi,

i try to build an server module, but i have to integrate the mail sync in our java spring application. the customer wants it this way

Quote:
Originally Posted by yutaka View Post
NoOp function is implemented like this;
Code:
public void noOp() throws ServiceException {
        invoke(newRequestElement(MailConstants.NO_OP_REQUEST));
    }
So how about directly calling invoke method like this and keep the return to some variables in your source code so you can look into the response, can't you?
Could you try that?
There ist no response

Code:
<NoOpResponse xmlns="urn:zimbraMail"/>
any other idea?

greets rizzi
Reply With Quote
  #10 (permalink)  
Old 09-13-2011, 11:39 PM
Junior Member
 
Posts: 9
Default

hi.

i see that the notify i need is in the header of the response, but i don't find a way to get the header

greets rizzi
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.