Class Stream

java.lang.Object
com.swiftmq.impl.streams.Stream

public class Stream extends Object
Stream is the entry point for SwiftMQ Streams.

It is passed as a global variable "stream" to Stream Scripts and is used to create and access Stream resources such as Memories, Timers, Inputs etc.

Author:
IIT Software GmbH, Muenster/Germany, (c) 2016, All Rights Reserved
  • Field Details

    • closed

      public boolean closed
  • Constructor Details

  • Method Details

    • getStreamCtx

      public StreamContext getStreamCtx()
      Internal use
      Returns:
      stream context
    • routerName

      public String routerName()
      Returns the name of the local Router.
      Returns:
      routerName
    • domainName

      public String domainName()
      Returns the Domain Name of this Stream.
      Returns:
      domain name
    • packageName

      public String packageName()
      Returns the Package Name of this Stream
      Returns:
      package name
    • name

      public String name()
      Returns the name of this stream
      Returns:
      name
    • fullyQualifiedName

      public String fullyQualifiedName()
      Returns the fully qualified Stream name: domain.package.name
      Returns:
      fully qualified name
    • restartCount

      public int restartCount()
      Returns the restart count of this stream
      Returns:
      restart count
    • log

      public Log log()
      Returns the stream's Log
      Returns:
      Log
    • cli

      public CLI cli()
      Returns the stream's CLI
      Returns:
      CLI
    • getWorkingDirectory

      public String getWorkingDirectory()
      Returns the working directory of the router
      Returns:
    • stateMemory

      public Memory stateMemory()
      Returns the Stream's State Memory that is used by MemoryGroups to store their associated Memories.
      Returns:
      stateMemory
    • addMemory

      public Memory addMemory(String name, Memory memory)
      Internal use only
    • addMemoryGroup

      public MemoryGroup addMemoryGroup(String name, MemoryGroup memoryGroup)
      Internal use only
    • removeMemory

      public void removeMemory(Memory memory)
      Internal use only
    • removeMemoryGroup

      public void removeMemoryGroup(MemoryGroup memoryGroup)
      Internal use only
    • addTimer

      public Timer addTimer(String name, Timer timer)
      Internal use only
    • removeTimer

      public Stream removeTimer(Timer timer)
      Internal use only
    • addInput

      public Input addInput(String name, Input input) throws Exception
      Internal use only
      Throws:
      Exception
    • removeInput

      public Stream removeInput(Input input)
      Internal use only
    • addOutput

      public Output addOutput(String name, Output output)
      Internal use only
    • removeOutput

      public Stream removeOutput(String name)
      Internal use only
    • addMailServer

      public MailServer addMailServer(String name, MailServer mailServer)
      Internal use only
    • removeMailServer

      public Stream removeMailServer(String name)
      Internal use only
    • addJDBCLookup

      public JDBCLookup addJDBCLookup(String name, JDBCLookup jdbcLookup)
      Internal use only
    • removeJDBCLookup

      public Stream removeJDBCLookup(String name)
      Internal use only
    • addTempQueue

      public TempQueue addTempQueue(String name, TempQueue tempQueue)
      Internal use only
    • removeTempQueue

      public Stream removeTempQueue(TempQueue tempQueue)
      Internal use only
    • getTimers

      public Timer[] getTimers()
      Internal use only
    • getInputs

      public Input[] getInputs()
      Internal use only
    • getOutputs

      public Output[] getOutputs()
      Internal use only
    • getMemories

      public Memory[] getMemories()
      Internal use only
    • deferredClose

      public void deferredClose()
      Internal use only
    • getMemoryGroups

      public MemoryGroup[] getMemoryGroups()
      Internal use only
    • getMailservers

      public MailServer[] getMailservers()
      Internal use only
    • getJDBCLookups

      public JDBCLookup[] getJDBCLookups()
      Internal use only
    • getTempQueues

      public TempQueue[] getTempQueues()
      Internal use only
    • create

      public StreamBuilder create()
      Returns a stream builder to create stream resources
      Returns:
      stream builder
    • input

      public Input input(String name)
      Returns the Input with the given name.
      Parameters:
      name - Name of the Input
      Returns:
      Input
    • input

      public Input input(TempQueue tempQueue)
      Returns the Input for this TempQueue.
      Parameters:
      tempQueue - temp queue
      Returns:
      Input
    • output

      public Output output(String name)
      Returns the Output with the given name.
      Parameters:
      name - Name of the Output
      Returns:
      Output
    • jdbcLookup

      public JDBCLookup jdbcLookup(String name)
      Returns the JDBCLookup with the given name.
      Parameters:
      name - Name of the JDBCLookup
      Returns:
      JDBCLookup
    • mailserver

      public MailServer mailserver(String name)
      Returns the MailServer with the given name.
      Parameters:
      name - Name of the MailServer
      Returns:
      MailServer
    • timer

      public Timer timer(String name)
      Returns the Timer with the given name.
      Parameters:
      name - Name of the Timer
      Returns:
      Timer
    • memory

      public Memory memory(String name)
      Returns the Memory with the given name.
      Parameters:
      name - Name of the Memory
      Returns:
      Memory
    • memoryGroup

      public MemoryGroup memoryGroup(String name)
      Returns the MemoryGroup with the given name.
      Parameters:
      name - Name of the MemoryGroup
      Returns:
      MemoryGroup
    • tempQueue

      public TempQueue tempQueue(String name)
      Returns the TempQueue with the given name.
      Parameters:
      name - Name of the TempQueue
      Returns:
      TempQueue
    • queue

      public QueueImpl queue(String name)
      Factory method to return a new QueueImpl (address)
      Parameters:
      name - queue name
      Returns:
      QueueImpl
    • topic

      public TopicImpl topic(String name)
      Factory method to return a new TopicImpl (address)
      Parameters:
      name - topic name
      Returns:
      TopicImpl
    • lookupJNDI

      public Destination lookupJNDI(String name) throws Exception
      Returns a Destination registered in JNDI under this name.
      Parameters:
      name - Name at which the Destination is registered
      Returns:
      Destination
      Throws:
      Exception
    • purgeOutputs

      public Stream purgeOutputs()
      Closes all Outputs that were not used between the last and this call to this method.
      Returns:
      this
    • current

      public Stream current(Message current)
      Sets/overwrites the currently processed Message.
      Parameters:
      current - current Message
      Returns:
      Stream
    • current

      public Message current()
      Returns the currently processed Message. This is automatically set from the stream processor before calling onMessage and set to null thereafter.
      Returns:
      current Message
    • onMessage

      public Stream onMessage(Runnable runnable)
      Sets the onMessage callback.
      Parameters:
      runnable - callback
      Returns:
      Stream
    • onException

      public Stream onException(ExceptionCallback runnable)
      Sets the onException callback.
      Parameters:
      runnable - callback
      Returns:
    • onStart

      public Stream onStart(Runnable runnable)
      Sets the onStart callback.
      Parameters:
      runnable - callback
      Returns:
    • onStop

      public Stream onStop(Runnable runnable)
      Sets the onStop callback.
      Parameters:
      runnable - callback
      Returns:
    • executeCallback

      public Stream executeCallback(FunctionCallback functionCallback, Object context)
      Executes a function callback in the Stream's event queue. This is one method to execute asynchronous calls from libraries. This does not work in GraalVM. Please use stream.async(...)
      Parameters:
      functionCallback - callback
      context - optional context
      Returns:
      this
    • async

      public Object async(String interfaceClassName, Object callback) throws Exception
      Wraps an async callback with a proxy that implements the interface given by the "interfaceClassName" and runs the callback on the Stream's event queue. This works on GraalVM and Nashorn.
      Parameters:
      interfaceClassName - Fully qualified class name of the interface to implement
      callback - Callback
      Returns:
      proxy object
      Throws:
      Exception
    • lastException

      public String lastException()
      Returns the last exception occurred on the stream
      Returns:
      last exception
    • lastStackTrace

      public String lastStackTrace()
      Returns the formatted stack trace of the last exception occurred on the stream
      Returns:
      stack trace
    • executeOnExceptionCallback

      public void executeOnExceptionCallback()
      Internal use only
    • executeOnMessageCallback

      public void executeOnMessageCallback() throws Exception
      Internal use only
      Throws:
      Exception
    • executeOnStartCallback

      public void executeOnStartCallback()
      Internal use only
    • executeOnStopCallback

      public void executeOnStopCallback()
      Internal use only
    • collect

      public void collect(long interval)
      Internal use only
    • start

      public void start() throws Exception
      Internal use only
      Throws:
      Exception
    • close

      public void close()
      Internal use only
    • toString

      public String toString()
      Overrides:
      toString in class Object