fluid-ws-java-client/src/main/java/com/fluidbpm/ws/client/v1/flowitem/WebSocketSendToFlowClient.java
public FluidItem sendToFlowSynchronized(
            Form formToSendToFlowParam,
            String destinationFlowParam) {

        if(formToSendToFlowParam == null)
        {
            return null;
        }

        if(destinationFlowParam == null ||
                destinationFlowParam.trim().isEmpty())
        {
            throw new FluidClientException(
                    "No destination Flow provided.",
                    FluidClientException.ErrorCode.FIELD_VALIDATE);
        }

        FluidItem itemToSend = new FluidItem();
        itemToSend.setFlow(destinationFlowParam);
        itemToSend.setForm(formToSendToFlowParam);

        //Send all the messages...
        itemToSend.setEcho(UUID.randomUUID().toString());

        //Start a new request...
        String uniqueReqId = this.initNewRequest();
        
        //Send the actual message...
        this.sendMessage(itemToSend, uniqueReqId);
        
        try {
            List<FluidItem> returnValue = this.getHandler(uniqueReqId).getCF().get(
                    this.getTimeoutInMillis(),TimeUnit.MILLISECONDS);

            //Connection was closed.. this is a problem....
            if(this.getHandler(uniqueReqId).isConnectionClosed()) {
                throw new FluidClientException(
                        "WebSocket-SendToFlow: " +
                                "The connection was closed by the server prior to the response received.",
                        FluidClientException.ErrorCode.IO_ERROR);
            }

            if(returnValue == null || returnValue.isEmpty())
            {
                return null;
            }

            return returnValue.get(0);
        }
        //Interrupted...
        catch (InterruptedException exceptParam) {

            throw new FluidClientException(
                    "WebSocket-Interrupted-SendToFlow: " +
                            exceptParam.getMessage(),
                    exceptParam,
                    FluidClientException.ErrorCode.STATEMENT_EXECUTION_ERROR);
        }
        //Error on the web-socket...
        catch (ExecutionException executeProblem) {

            Throwable cause = executeProblem.getCause();

            //Fluid client exception...
            if(cause instanceof FluidClientException)
            {
                throw (FluidClientException)cause;
            }
            else
            {
                throw new FluidClientException(
                        "WebSocket-SendToFlow: " +
                                cause.getMessage(), cause,
                        FluidClientException.ErrorCode.STATEMENT_EXECUTION_ERROR);
            }
        }
        //Timeout...
        catch (TimeoutException eParam) {

            throw new FluidClientException(
                    "WebSocket-SendToFlow: Timeout while waiting for all return data. There were '"
                            +this.getHandler(uniqueReqId).getReturnValue().size()
                            +"' items after a Timeout of "+(
                            TimeUnit.MILLISECONDS.toSeconds(this.getTimeoutInMillis()))+" seconds."
                    ,FluidClientException.ErrorCode.IO_ERROR);
        }
        finally {
            this.removeHandler(uniqueReqId);
        }
    }
public FluidItem sendToFlowSynchronized(
            Form formToSendToFlowParam,
            String destinationFlowParam) {

        if(formToSendToFlowParam == null)
        {
            return null;
        }

        if(destinationFlowParam == null ||
                destinationFlowParam.trim().isEmpty())
        {
            throw new FluidClientException(
                    "No destination Flow provided.",
                    FluidClientException.ErrorCode.FIELD_VALIDATE);
        }

        FluidItem itemToSend = new FluidItem();
        itemToSend.setFlow(destinationFlowParam);
        itemToSend.setForm(formToSendToFlowParam);

        //Send all the messages...
        itemToSend.setEcho(UUID.randomUUID().toString());

        //Start a new request...
        String uniqueReqId = this.initNewRequest();
        
        //Send the actual message...
        this.sendMessage(itemToSend, uniqueReqId);
        
        try {
            List<FluidItem> returnValue = this.getHandler(uniqueReqId).getCF().get(
                    this.getTimeoutInMillis(),TimeUnit.MILLISECONDS);

            //Connection was closed.. this is a problem....
            if(this.getHandler(uniqueReqId).isConnectionClosed()) {
                throw new FluidClientException(
                        "WebSocket-SendToFlow: " +
                                "The connection was closed by the server prior to the response received.",
                        FluidClientException.ErrorCode.IO_ERROR);
            }

            if(returnValue == null || returnValue.isEmpty())
            {
                return null;
            }

            return returnValue.get(0);
        }
        //Interrupted...
        catch (InterruptedException exceptParam) {

            throw new FluidClientException(
                    "WebSocket-Interrupted-SendToFlow: " +
                            exceptParam.getMessage(),
                    exceptParam,
                    FluidClientException.ErrorCode.STATEMENT_EXECUTION_ERROR);
        }
        //Error on the web-socket...
        catch (ExecutionException executeProblem) {

            Throwable cause = executeProblem.getCause();

            //Fluid client exception...
            if(cause instanceof FluidClientException)
            {
                throw (FluidClientException)cause;
            }
            else
            {
                throw new FluidClientException(
                        "WebSocket-SendToFlow: " +
                                cause.getMessage(), cause,
                        FluidClientException.ErrorCode.STATEMENT_EXECUTION_ERROR);
            }
        }
        //Timeout...
        catch (TimeoutException eParam) {

            throw new FluidClientException(
                    "WebSocket-SendToFlow: Timeout while waiting for all return data. There were '"
                            +this.getHandler(uniqueReqId).getReturnValue().size()
                            +"' items after a Timeout of "+(
                            TimeUnit.MILLISECONDS.toSeconds(this.getTimeoutInMillis()))+" seconds."
                    ,FluidClientException.ErrorCode.IO_ERROR);
        }
        finally {
            this.removeHandler(uniqueReqId);
        }
    }
Sends the {@code formToSendToFlowParam} to a {@code Flow} in Fluid.
The return value is the {@code FluidItem} created as a result.

The Web socket has the ability to wait for the workflow to finish
and then only respond with the final result of the item.

@param formToSendToFlowParam The Fluid Form to send to flow.
@param destinationFlowParam The destination flow.

@return The {@code formToSendToFlowParam} created as {@code FluidItem}.