Uploaded image for project: 'Errai'
  1. Errai
  2. ERRAI-842

Conversational event in rpc context

    Details

    • Type: Feature Request
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 3.1.2.Final
    • Fix Version/s: 4.0.0.CR1
    • Component/s: ErraiBus
    • Labels:
      None

      Description

      We use a the Caller-interface (or MessageBuilder.createCall) on client to do rpc service calls.
      On server-side we would like to fire conversational events which are caught by client-side observers which know nothing about the initial call.
      This of course can be achieved by using the MessageBuilder-API but this would mean that we cannot use all the convenience stuff like injectable callers and automatic Service-method invocation on server-side without ever having to deal with the actual Message.

      After a little digging we found that the problem is, that EventConversationScope is only activated in case of an incoming CDI event.
      We cannot think of any negative sideeffects of activating this context whenever a call is made, be it rpc or event.

      We wrote an interceptor to deal with this problem until it hopefully finds its way into the framework:

      @ConversationalService
      @Interceptor
      public class ConversationalServiceInterceptor {
      	@AroundInvoke
      	public Object invoke(InvocationContext ctx) throws Exception {
      		Context conversationalContext = EventConversationContext.get();
      		if (conversationalContext == null || conversationalContext.getSessionId() == null) {
      			EventConversationContext.activate(RpcContext.getMessage());
      			try {
      				return ctx.proceed();
      			} finally {
      				EventConversationContext.deactivate();
      			}
      		} else {
      			return ctx.proceed();
      		}
      	}
      }
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                csa Christian Sadilek
                Reporter:
                dsc_ Dominik Schlosser
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: