Last few days i was playing with GranideDS tutorials (using Spring server and AIR client)
https://github.com/graniteds-tutorials/graniteds-tutorial-data
"This tutorial shows how to build a simple data application that manages a database of user accounts. All connected clients are notified and synchronized with data updates using a GraniteDS long polling channel."
Unfortunately i cannot find any GraniteDS javascript client library or example.
I created an HttpServlet to manage (add Entity for example) persistense context using http (ajax) requests.
my TestServlet.java
@WebServlet("/TestServlet")
public class TestServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext());
AccountService srvObject = (AccountService) wac.getBean("testService");
//testService mean spring service annotation parameter
Account emp = new Account();
emp.setName(request.getParameter("name"));
emp.setEmail(request.getParameter("email"));
srvObject.save(emp);
response.getWriter().println("OK");
}
}
This method adds an entity correctly but connected client's data are NOT syncronized. How can i notify all clients about new changes?
UPDATE: I was trying to change DataEnabled's publish to PublishMode.ON_COMMIT
@DataEnabled(topic="dataTopic", publish=DataEnabled.PublishMode.ON_COMMIT, useInterceptor=true)
add to application-context.xml
<graniteds:tide-data-publishing-advice/>
In this case both air application and servlet causing server error:
SEVERE: Could not register synchronization for ON_COMMIT publish mode, check that the Spring PlatformTransactionManager supports it and that the order of the TransactionInterceptor is lower than the order of TideDataPublishingInterceptor
And <graniteds:tide-data-publishing-advice order="-1"/>
does not helps.
You can try the mode ON_SUCCESS with useInterceptor=true "useInterceptor=true" is necessary because it's what will make GraniteDS aware of your service which is called completely outside its control