Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-9364

Add ability to receive onOpen/onClose/onError websocket events through camel rout.

    XMLWordPrintableJSON

Details

    • Novice

    Description

      There is a case when I need to maintain my own map (websocket session key, user object). Consequently I need to receive events from onOpen/onClose/onError methods of websocket protocol and add/remove item from my map.

      To achieve this :

      1) I will add special servlet parameter, let's call it "events" with value "true". Which will enable this feature. By default it will be "false" (no parameter needed) and current functionality will not be influenced any how.

      <servlet>
      <servlet-name>CamelWsServlet</servlet-name>
      <servlet-class>org.apache.camel.component.atmosphere.websocket.CamelWebSocketServlet</servlet-class>
      <init-param>
      <param-name>events</param-name>
      <param-value>true</param-value>
      </init-param>
      <load-on-startup>2</load-on-startup>
      </servlet>

      2) I will change WebsocketHandler sending exchange message with header key such as "websocket.eventType" and possible values :
      ONOPEN_EVENT_TYPE = 1;
      ONCLOSE_EVENT_TYPE = 0;
      ONERROR_EVENT_TYPE = -1;

      to camel rout each time when we trigger onOpen/onClose/onError methods. In addition to this header parameter session key will be send as well.

      3) Rout on client side will filter messages by header to distinguish events and their purposes.

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            pkletsko Pavlo Kletsko
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 4h
                4h
                Remaining:
                Remaining Estimate - 4h
                4h
                Logged:
                Time Spent - Not Specified
                Not Specified