Sets the delegate {@link StreamMessage} which will actually publish the stream.

@throws IllegalStateException if the delegate has been set already or
if {@link #close()} or {@link #close(Throwable)} was called already.
556481
protected void delegate(StreamMessage<T> delegate) {
        requireNonNull(delegate, "delegate");

        if (!delegateUpdater.compareAndSet(this, null, delegate)) {
            throw new IllegalStateException("delegate set already");
        }

        if (abortPending != 0) {
            delegate.abort();
        }

        if (!completionFuture().isDone()) {
            delegate.completionFuture().handle((unused, cause) -> {
                if (cause == null) {
                    completionFuture().complete(null);
                } else {
                    completionFuture().completeExceptionally(cause);
                }
                return null;
            }).exceptionally(CompletionActions::log);
        }

        safeOnSubscribeToDelegate();
    }
767411
public void setOut(PrintStream out) {
    this.out = out;
    if (!(System.out instanceof ThreadLocalPrintStream)) {
      throw new IllegalStateException("System.out should be set by nailgun.");
    }
    ThreadLocalPrintStream tls = (ThreadLocalPrintStream) System.out;
    tls.init(out);
  }
951506
public boolean addMessage(SIMPMessage msgItem) throws SIResourceException
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "addMessage", new Object[] { msgItem });
  
    // Get the JsMessage as we need to update the Guaranteed fields
    JsMessage jsMsg = msgItem.getMessage();
  
    StreamSet streamSet = getStreamSet();
  
    // Stamp the message with the stream ID
    msgItem.setGuaranteedStreamUuid(streamSet.getStreamID());
  
    //  NOTE: no synchronization with flush necessary here since startFlush
    // is not supposed to be called until all competing producer threads have
    // exited.
    Reliability reliability = msgItem.getReliability();
  
    if(reliability == Reliability.BEST_EFFORT_NONPERSISTENT)
    {
      addBestEffortMessage(msgItem);
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        SibTr.exit(tc, "addMessage", false);
      return false;
    }
    else
    {
      SourceStream sourceStream = null;
      int priority = msgItem.getPriority();
      synchronized(streamSet)
      {        
        sourceStream = (SourceStream) streamSet.getStream(priority, reliability);
    
        if(sourceStream == null)
        {
          sourceStream = createStream(streamSet,
                                      priority,
                                      reliability,
                                      streamSet.getPersistentData(priority, reliability),
                                      false );
        }
      }
    
      synchronized(sourceStream)
      {    
        long tick = this.messageProcessor.nextTick();
    
        //Set a unique id in the message if explicitly told to or
        //if one has not already been set
        if(msgItem.getRequiresNewId()  ||  jsMsg.getSystemMessageId()==null)
        {
          jsMsg.setSystemMessageSourceUuid(this.messageProcessor.getMessagingEngineUuid());
          jsMsg.setSystemMessageValue(tick);
          msgItem.setRequiresNewId(false);
        }
    
        jsMsg.setGuaranteedValueEndTick(tick);
        jsMsg.setGuaranteedValueValueTick(tick);
        jsMsg.setGuaranteedValueRequestedOnly(false);
    
        jsMsg.setGuaranteedValueStartTick(sourceStream.getLastMsgAdded() + 1);
        jsMsg.setGuaranteedValueCompletedPrefix(sourceStream.getCompletedPrefix());
    
        sourceStream.writeUncommitted(msgItem);
      } // end sync
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        SibTr.exit(tc, "addMessage", true);
    
      return true;
    }    
  }
1361371
public void resetStream()
        throws IllegalStateException
    {
        if ((_deChunker!=null && _deChunker._chunkSize>0) ||
            _realIn.getByteLimit()>0)
            throw new IllegalStateException("Unread input");
        if(log.isTraceEnabled())log.trace("resetStream()");
        in=_realIn;
        if (_deChunker!=null)
            _deChunker.resetStream();
        _chunking=false;
        _realIn.setByteLimit(-1);
    }
531063
public void set(T value) {
        if (logger.isTraceEnabled()) {
            logger.trace("Name: " + display(name) + ": Value: " + display(value), new Throwable("Stack trace"));
        }
        T thisValue = offerInternal(value);
        if (thisValue != null) {
            throw new IllegalStateException("Value was already set to another value: " + name + " == [" + display(thisValue) + "], not: [" + display(value) + "]");
        }
    }
98899
public SingleFieldBuilder<MType, BType, IType> setMessage(
      MType message) {
    if (message == null) {
      throw new NullPointerException();
    }
    this.message = message;
    if (builder != null) {
      builder.dispose();
      builder = null;
    }
    onChanged();
    return this;
  }
517574
public void sendAsync(BasicMessageWithExtraData<? extends BasicMessage> messageWithData) {
        if (!isConnected()) {
            throw new IllegalStateException("WebSocket connection was closed. Cannot send any messages");
        }

        BasicMessage message = messageWithData.getBasicMessage();
        configurationAuthentication(message);

        sendExecutor.execute(new Runnable() {
            @Override
            public void run() {
                try {
                    if (messageWithData.getBinaryData() == null) {
                        String messageString = ApiDeserializer.toHawkularFormat(message);
                        @SuppressWarnings("resource")
                        Buffer buffer = new Buffer().writeUtf8(messageString);
                        RequestBody requestBody = RequestBody.create(WebSocket.TEXT, buffer.readByteArray());
                        FeedCommProcessor.this.webSocket.sendMessage(requestBody);
                    } else {
                        BinaryData messageData = ApiDeserializer.toHawkularFormat(message,
                                messageWithData.getBinaryData());

                        RequestBody requestBody = new RequestBody() {
                            @Override
                            public MediaType contentType() {
                                return WebSocket.BINARY;
                            }

                            @Override
                            public void writeTo(BufferedSink bufferedSink) throws IOException {
                                emitToSink(messageData, bufferedSink);
                            }
                        };

                        FeedCommProcessor.this.webSocket.sendMessage(requestBody);
                    }
                } catch (Throwable t) {
                    log.errorFailedToSendOverFeedComm(message.getClass().getName(), t);
                }
            }
        });
    }
505490
@Override
    public void processTextMessage(WebSocketChannel channel, String message) {
        LOG.entering(CLASS_NAME, "send", message);

        WebSocketCompositeChannel parent = (WebSocketCompositeChannel)channel;
        if (parent.readyState != ReadyState.OPEN) {
            LOG.warning("Attempt to post message on unopened or closed web socket");
            throw new IllegalStateException("Attempt to post message on unopened or closed web socket");
        }
        
        WebSocketSelectedChannel selectedChannel = parent.selectedChannel;
        selectedChannel.handler.processTextMessage(selectedChannel, message);
    }
83757
public void setProcessInputStream(OutputStream os) {
    if (input != null) {
      inputThread = createPump(input, os, true, nonBlockingRead);
    } else {
      Closeables.close(os);
    }
  }
1185969
public void setPropertiesInMessage(JsMessage jsMsg,
                                       SIBUuid12 destinationUuid,
                                       SIBUuid12 producerConnectionUuid)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "setPropertiesInMessage",
                        new Object[] { jsMsg, destinationUuid, producerConnectionUuid });

        SIMPUtils.setGuaranteedDeliveryProperties(jsMsg,
                                                  _messageProcessor.getMessagingEngineUuid(),
                                                  null,
                                                  null,
                                                  null,
                                                  destinationUuid,
                                                  ProtocolType.PUBSUBINPUT,
                                                  GDConfig.PROTOCOL_VERSION);

        if (jsMsg.getConnectionUuid() == null)
        {
            //defect 278038:
            //The producerSession will have set this in the msgItem for pub sub 
            //destinations. However, the field may not have been set in the
            //jsMsg if the msg was not persisted before this point.
            //Since the message is going off the box, we have no choice but to set it now.
            jsMsg.setConnectionUuid(producerConnectionUuid);
        }
        //NOTE: the 'bus' field is not set in this method as it should
        //only be set once the message has been stored
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "setPropertiesInMessage");
    }
600414
@Override
	public final void setMessageListener(MessageListener messageListener) throws JMSException
    {
        super.setMessageListener(messageListener);
        
        // If the connection was already started, wake up the new listener in case there were messages
        // waiting in the destination
        if (messageListener != null && session.getConnection().isStarted())
        	wakeUpMessageListener();
    }
470242
@Override
    public void setRequest(HttpRequestMessage msg) throws IllegalRequestObjectException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "setRequest: " + msg);
        }

        // null message isn't allowed
        if (null == msg) {
            throw new IllegalRequestObjectException("Illegal null message");
        }

        HttpRequestMessageImpl temp = null;
        try {
            temp = (HttpRequestMessageImpl) msg;
        } catch (ClassCastException cce) {
            // no FFDC required
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Non msg impl passed to setRequest");
            }
            throw new IllegalRequestObjectException("Invalid message provided");
        }
        // possibly clean up any existing request object
        if (null != getMyRequest() && isRequestOwner()) {
            if (!getMyRequest().equals(temp)) {
                getMyRequest().destroy();
            } else {
                if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                    Tr.event(tc, "Caller overlaying same message");
                }
            }
        }
        // set the new object in place
        setMyRequest(temp);
        // 335554 : the message init() will overwrite the version based on config
        // and needs to be reset back to whatever we started with here.
        VersionValues version = temp.getVersionValue();
        getMyRequest().init(this);
        getMyRequest().setVersion(version);
        updatePersistence(getMyRequest());
        getResponseImpl().setHeaderChangeLimit(getMyRequest().getHeaderChangeLimit());

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "setRequest");
        }
    }
458964
@Override
    public void setException(Exception e) {
        if (!isTerminated()) {
            subject.onError(e);
        } else {
            throw new IllegalStateException("Response has already terminated so exception can not be set", e);
        }
    }
1137150
@Override
    public void setMessageListener(MessageListener listener) throws JMSRuntimeException {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "setMessageListener", new Object[] { listener });

        try {
            messageConsumer.setMessageListener(listener);
        } catch (JMSException jmse) {
            throw (JMSRuntimeException) JmsErrorUtils.getJMS2Exception(jmse, JMSRuntimeException.class);
        } finally {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(this, tc, "setMessageListener");
        }

    }
744823
void setLastMessage(AVIMMessage lastMessage) {
    if (null != lastMessage) {
      if (null == this.lastMessage) {
        this.lastMessage = lastMessage;
      } else {
        if(this.lastMessage.getTimestamp() <= lastMessage.getTimestamp()) {
          this.lastMessage = lastMessage;
        }
      }
    }
  }
118671
public ApiFuture<String> publish(String message) {
    ByteString data = ByteString.copyFromUtf8(message);
    PubsubMessage pubsubMessage = PubsubMessage.newBuilder().setData(data).build();
    ApiFuture<String> messageIdFuture = publisher.publish(pubsubMessage);
    ApiFutures.addCallback(
        messageIdFuture,
        new ApiFutureCallback<String>() {
          public void onSuccess(String messageId) {
            System.out.println("published with message id: " + messageId);
          }

          public void onFailure(Throwable t) {
            System.out.println("failed to publish: " + t);
          }
        },
        Executors.newSingleThreadExecutor());
    return messageIdFuture;
  }
623364
public void setChunking()
        throws IllegalStateException
    {
        if (_realIn.getByteLimit()>=0)
            throw new IllegalStateException("Has Content-Length");
        if (_deChunker==null)
            _deChunker=new ChunkingInputStream(_realIn);
        in=_deChunker;
        
        _chunking=true;
        _deChunker._trailer=null;
    }