5 Replies Latest reply on Apr 24, 2006 1:41 PM by Tom Elrod

    stream handler without a stream

    mazz Master

      Suppose I have a server that can, but not always, takes a client invocation with stream data.

      I use StreamInvocationHandler, as opposed to ServerInvocationHandler.

      I assume JBoss/Remoting internals will be smart enough to route my incoming message to invoke() when the request is not streaming data, and it will be smart enough to call handleStream() when the client IS sending streamed data.

      Is that true?

        • 1. Re: stream handler without a stream
          mazz Master

          One other question about the stream handler; the javadocs say this for the StreamInvocationHandler.handleStream method's param parameter:

          param - the payload associated with the invocation

          What is this payload? Its type is Object so I assume it isn't the normal InvocationRequest that you get in the invoke() method. Is it similar to the InvocationRequest.getParameter() object?

          If so, how do you get the invocation request metadata like the subsystem and the other things the InvocationRequest gives you (see InvocationRequest.getXXX methods)?

          • 2. Re: stream handler without a stream
            Tom Elrod Master

            If sending a stream from the client the the server, the user will need to call Client.invoke(InputStream inputStream, Object param) as opposed to Client.invoke(Object param) or Client.invoke(Object param, Map metadata). This will cause remoting to internally handle the stream proxying and deliver the proxy to the handleStream(InputStream stream, Object param) method of StreamInvocationHandler.

            As for the second parameter to the handleStream() method, is for any extra contextual information the client would like to send. For example, org.jboss.remoting.samples.stream.StreamingServer uses the param object to represent the file name for the stream being passed. Guess this second parameter could be of type Map, but figured would just let be of type Object so could be anything. Don't know if is maybe a little too unstructured?

            • 3. Re: stream handler without a stream
              mazz Master

              Ok, so this doesn't seem right. If I don't handle streams, I can get the invocation metadata, but I CAN'T get this metadata if I'm handling streams.

              Why do I get the InvocationHandler in the invoke()...

              public Object invoke( InvocationRequest invocation )

              ...but yet I can't get that same data if the request happens to be passing streamed data:

              public Object handleStream( InputStream in, Object payload )

              It seems the APIs here should be similar - since they are both the integration points for receiving requests (one just happens to have a stream). I'm thinking the APIs should have been more identical:

              public Object invoke(InvocationRequest invocation)
              public Object handleStream(InputStream in, InvocationRequest invocation)

              See what I mean?

              The problem now is, if I'm getting a stream, I can't find out what subsystem my handler is in. I can't get anything related to the invocation request because the API has stripped that data from me.

              Am I missing something? How can I get InvocationRequest metadata if I'm handling a stream request?

              • 4. Re: stream handler without a stream
                Tom Elrod Master

                Have changed the StreamInvocationHandler interface to have:

                public Object handleStream(InputStream stream, InvocationRequest param)

                as its method now. See http://jira.jboss.com/jira/browse/JBREM-409 for details.