Class JmsSinkBuilder<T>

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Sink<T> build()
      Creates and returns the JMS Sink with the supplied components.
      JmsSinkBuilder<T> connectionFn​(FunctionEx<jakarta.jms.ConnectionFactory,​jakarta.jms.Connection> connectionFn)
      Sets the function which creates a connection given a connection factory.
      JmsSinkBuilder<T> connectionParams​(java.lang.String username, java.lang.String password)
      Sets the connection parameters.
      JmsSinkBuilder<T> destinationName​(java.lang.String destinationName)
      Sets the name of the destination.
      JmsSinkBuilder<T> exactlyOnce​(boolean enable)
      Enables or disables the exactly-once behavior of the sink using two-phase commit of state snapshots.
      JmsSinkBuilder<T> messageFn​(BiFunctionEx<jakarta.jms.Session,​T,​jakarta.jms.Message> messageFn)
      Sets the function which creates the message from the item.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • connectionParams

        @Nonnull
        public JmsSinkBuilder<T> connectionParams​(@Nullable
                                                  java.lang.String username,
                                                  @Nullable
                                                  java.lang.String password)
        Sets the connection parameters. If connectionFn is provided, these parameters are ignored.
        Parameters:
        username - the username, Default value is null
        password - the password, Default value is null
      • connectionFn

        @Nonnull
        public JmsSinkBuilder<T> connectionFn​(@Nullable
                                              FunctionEx<jakarta.jms.ConnectionFactory,​jakarta.jms.Connection> connectionFn)
        Sets the function which creates a connection given a connection factory.

        If not provided, the following will be used:

        
             if (factory instanceof XAConnectionFactory) {
                 XAConnectionFactory xaFactory = (XAConnectionFactory) factory;
                 return usernameLocal != null || passwordLocal != null
                         ? xaFactory.createXAConnection(usernameLocal, passwordLocal)
                         : xaFactory.createXAConnection();
             } else {
                 return usernameLocal != null || passwordLocal != null
                         ? factory.createConnection(usernameLocal, passwordLocal)
                         : factory.createConnection();
             }
         
        The given function must be stateless.
      • destinationName

        @Nonnull
        public JmsSinkBuilder<T> destinationName​(@Nonnull
                                                 java.lang.String destinationName)
        Sets the name of the destination.
      • messageFn

        @Nonnull
        public JmsSinkBuilder<T> messageFn​(@Nullable
                                           BiFunctionEx<jakarta.jms.Session,​T,​jakarta.jms.Message> messageFn)
        Sets the function which creates the message from the item.

        If not provided, the builder creates a function which wraps item.toString() into a TextMessage, unless the item is already an instance of javax.jms.Message.

        The given function must be stateless.

      • exactlyOnce

        @Nonnull
        public JmsSinkBuilder<T> exactlyOnce​(boolean enable)
        Enables or disables the exactly-once behavior of the sink using two-phase commit of state snapshots. If enabled, the processing guarantee of the job must be set to exactly-once, otherwise the sink's guarantee will match that of the job. In other words, sink's guarantee cannot be higher than job's, but can be lower to avoid the additional overhead.

        The default value is true.

        Parameters:
        enable - If true, sink's guarantee will match the job guarantee. If false, sink's guarantee will be at-least-once even if job's is exactly-once
        Returns:
        this instance for fluent API
      • build

        @Nonnull
        public Sink<T> build()
        Creates and returns the JMS Sink with the supplied components.