Problem receive globalevent


I find solution my problem in topic

but I don’t understand first item
“Changing data object type in GlobalUiEvent into String”

GlobalUiEvent is the interface. How have I an understanding of this tip ?
Can I look to any example ?

Hi @andrzej.paluch72
Yess sorry for late response,

  1. Create Class that extends GlobalApplicationEvent and implements GlobalUiEvent
    on that class construction set one paramater as String type

     public class MasterDataPropagateEvents extends GlobalApplicationEvent implements 
    GlobalUiEvent {`
    private String MasterDataStr="";
     public MasterDataPropagateEvents(Objec source,String data) {
     public getSource(){
     return super.getSource();
     public String getMasterDataStr() {
      return this.MasterDataStr;
  2. After that create bean Class that has @Inject Events from import package on it, so we can publish data to GUI screen

     public String sendUiNotificationEvent(FosterMasterDataRevb message) {
      MasterDataPropagateEvents propagateEvents =new MasterDataPropagateEvents(this, 
       return "done";
  3. Call #2 class in Entity listener class and execute sendUiNotificationEvent

  4. Create method to receive event in your GUI Screen just like below

       public void onUiNotificationEvent(MasterDataPropagateEvents event) {


Thanks for reply.

I have got still problem when app.war and app-core.war are sperate.

  1. First of all I change manually websocket-sping.xml like below in cubaglevt-core-0.3.0.jar
    cubaglevt-core-0.3.0.jar (12.7 KB)
<beans xmlns=""

        <websocket:mapping path="/handler" handler="cubaglevt_WebSocketServer"/>
	<bean class="org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean">
        <property name="maxTextMessageBufferSize" value="281920"/>
        <property name="maxBinaryMessageBufferSize" value="281920"/>
  1. I create class UiNotificationEvent in global project

    import com.haulmont.addon.globalevents.GlobalApplicationEvent;

import com.haulmont.addon.globalevents.GlobalUiEvent;

public class UiNotificationEvent extends GlobalApplicationEvent implements GlobalUiEvent {

	private static final long serialVersionUID = 7852612799484215742L;
	private String message;
	private UserSession userSession;
	private NotyficationEvent type;

	public UiNotificationEvent(Object source, String message, UserSession userSession, NotyficationEvent type) {
		this.message = message;
		this.userSession = userSession;
		this.type = type;

	public String getMessage() {
		return message;

	public String getMessageForSession(UserSession session) {
		if (session.getId().equals(userSession.getId()))
			return getMessage();
			return null;

	public UserSession getUserSession() {
		return userSession;

	public NotyficationEvent getNotyficationType() {
		return type;

3 Next I create bean and invoke UiNotificationEvent e.g

UserSession userSession = userSessionSource.getUserSession();
			events.publish(new UiNotificationEvent(userSession.getUser(), getChangeStatusAllowedMessage(), userSession,
  1. In main window I catch event like below

    protected void showNotification(UiNotificationEvent event) {
    UserSession userSession = userSessionSource.getUserSession();
    if (userSession.getId().equals(event.getUserSession().getId())) {
    NotyficationEvent type = event.getNotyficationType();
    if (type.equals(NotyficationEvent.TRAY))
    showNotification(event.getMessage(), NotificationType.TRAY);
    else if (type.equals(NotyficationEvent.ERROR))
    showNotification(event.getMessage(), NotificationType.ERROR);
    else if (type.equals(NotyficationEvent.WARM))
    showNotification(event.getMessage(), NotificationType.WARNING);
    showNotification(event.getMessage(), NotificationType.HUMANIZED);

I see I have’t method getSource in UiNotificationEvent . Is it necessary ?

> public getSource(){
>  return super.getSource();
> ```


  1. Since your deployment method by separating war , have you set cuba.useLocalServiceInvocation to false?
  2. May I see your log in catalina.log, related to WebSockect
    ( if you using linux it can be show by cat catalina.log | grep “WebSocket”


Log when cuba.useLocalServiceInvocation=true below

2019-07-09 18:24:18.259 DEBUG [http-nio-8080-exec-7/app-core/admin] com.haulmont.addon.globalevents.core.WebSocketServer - Sending[ [detached]] to {WebSocketServerSockJsSession[id=188ec88a20254b1faa50b72713636bd0]=true}
2019-07-09 18:24:18.259 DEBUG [http-nio-8080-exec-7/app-core/admin] com.haulmont.addon.globalevents.core.WebSocketServer - Sending message TextMessage payload=[rO0ABXNyAD..], byteCount=19624, last=true] to WebSocketServerSockJsSession[id=188ec88a20254b1faa50b72713636bd0]
2019-07-09 18:24:18.274 INFO  [http-nio-8080-exec-1] com.haulmont.addon.globalevents.core.WebSocketServer - Closed session WebSocketServerSockJsSession[id=188ec88a20254b1faa50b72713636bd0] with status CloseStatus[code=1009, reason=The decoded text message was too big for the output buffer and the endpoint does not support partial messages]
2019-07-09 18:24:18.321 INFO  [WebSocketClient-AsyncIO-1] com.haulmont.addon.globalevents.transport.AbstractWebSocketClient - Closed WebSocketClientSockJsSession[id='188ec88a20254b1faa50b72713636bd0, url=http://localhost:8080/app-core/cubaglevt-ws/handler]
2019-07-09 18:24:18.337 DEBUG [http-nio-8080-exec-2/app-core/admin] - loadList: metaClass=erp$Documents,, query=select e from erp$Documents e where (e.docdate &gt;= :component_dateFrom and e.docdate &lt;= :component_dateTo and = :component_ledger and = :component_department) order by e.entrydate, max=50

Log when cuba.useLocalServiceInvocation=false below [new], [new], [new]], removeInstances=[]
2019-07-09 19:03:45.519 DEBUG [http-nio-8080-exec-2/app-core/admin] - load: metaClass=erp$Customers, id=null,
2019-07-09 19:03:45.550 DEBUG [http-nio-8080-exec-5/app-core/admin] - load: metaClass=erp$PaymentsForm, id=null,
2019-07-09 19:03:45.644 DEBUG [http-nio-8080-exec-3/app-core/admin] - load: metaClass=erp$Documents, id=38302,
2019-07-09 19:03:45.722 DEBUG [http-nio-8080-exec-10/app-core/admin] com.haulmont.addon.globalevents.core.WebSocketServer - Sending[ [detached]] to {}
2019-07-09 19:03:45.753 DEBUG [http-nio-8080-exec-9/app-core/admin] - loadList: metaClass=erp$Documents,, query=select e from erp$Documents e where (e.docdate &gt;= :component_dateFrom and e.docdate &lt;= :component_dateTo and = :component_ledger and = :component_department) order by e.entrydate, max=50

strange log files, it supposes to be resulting in opposite logs, cuba.userLocalService Invocation=false should have WebSocket on it.

Anyway, do you sure only send String message? From your code above I saw you try to send data UserSession Object

Yes I publish more information and sesion too. I need this parametr because in other way notification is send for all session.

UserSession userSession = userSessionSource.getUserSession();
			events.publish(new UiNotificationEvent(userSession.getUser(), getChangeStatusAllowedMessage(), userSession,


  1. I think you can only send sessionId instead of all object UserSession for that purpose?
  2. If you must send all UserSession object, Can you try to convert UserSession to JSON object before sending it to notification?


Ok I try it. Can I use for this variable source?

well in my case I’m not changing variable resource at all, Simply overide it as it is ,from parent Class

so how is your websocket going ?


I haven’t time for see about this problem this week. I figure then I have to add log in service and web leayer. Maybe this help me resolve problem.