Class JmsIO.Write<EventT>

    • Field Summary

      • Fields inherited from class org.apache.beam.sdk.transforms.PTransform

        annotations, displayData, name, resourceHints
    • Constructor Summary

      Constructors 
      Constructor Description
      Write()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      WriteJmsResult<EventT> expand​(org.apache.beam.sdk.values.PCollection<EventT> input)  
      JmsIO.Write<EventT> withConnectionFactory​(javax.jms.ConnectionFactory connectionFactory)
      Specify the JMS connection factory to connect to the JMS broker.
      JmsIO.Write<EventT> withConnectionFactoryProviderFn​(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Void,​? extends javax.jms.ConnectionFactory> connectionFactoryProviderFn)
      Specify a JMS connection factory provider function to connect to the JMS broker.
      JmsIO.Write<EventT> withPassword​(java.lang.String password)
      Define the password to connect to the JMS broker (authenticated).
      JmsIO.Write<EventT> withQueue​(java.lang.String queue)
      Specify the JMS queue destination name where to send messages to.
      JmsIO.Write<EventT> withRetryConfiguration​(RetryConfiguration retryConfiguration)
      Specify the JMS retry configuration.
      JmsIO.Write<EventT> withTopic​(java.lang.String topic)
      Specify the JMS topic destination name where to send messages to.
      JmsIO.Write<EventT> withTopicNameMapper​(org.apache.beam.sdk.transforms.SerializableFunction<EventT,​java.lang.String> topicNameMapper)
      Specify the JMS topic destination name where to send messages to dynamically.
      JmsIO.Write<EventT> withUsername​(java.lang.String username)
      Define the username to connect to the JMS broker (authenticated).
      JmsIO.Write<EventT> withValueMapper​(org.apache.beam.sdk.transforms.SerializableBiFunction<EventT,​javax.jms.Session,​javax.jms.Message> valueMapper)
      Map the EventT object to a Message.
      • Methods inherited from class org.apache.beam.sdk.transforms.PTransform

        addAnnotation, compose, compose, getAdditionalInputs, getAnnotations, getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, getResourceHints, populateDisplayData, setDisplayData, setResourceHints, toString, validate, validate
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Write

        public Write()
    • Method Detail

      • withConnectionFactoryProviderFn

        public JmsIO.Write<EventT> withConnectionFactoryProviderFn​(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Void,​? extends javax.jms.ConnectionFactory> connectionFactoryProviderFn)
        Specify a JMS connection factory provider function to connect to the JMS broker. Use this method in case your ConnectionFactory objects are themselves not serializable, but you can recreate them as needed with a SerializableFunction provider

        For instance:

         pipeline.apply(JmsIO.write().withConnectionFactoryProviderFn(() -> new MyJmsConnectionFactory());
         
        Specified by:
        withConnectionFactoryProviderFn in interface JmsIO.ConnectionFactoryContainer<EventT>
        Parameters:
        connectionFactoryProviderFn - a SerializableFunction that creates a ConnectionFactory
        Returns:
        The corresponding JmsIO.Write
      • withQueue

        public JmsIO.Write<EventT> withQueue​(java.lang.String queue)
        Specify the JMS queue destination name where to send messages to. The JmsIO.Write acts as a producer on the queue.

        This method is exclusive with withTopic(String). The user has to specify a destination: queue, topic, or topicNameMapper.

        For instance:

        
         .apply(JmsIO.write().withQueue("my-queue")
        
         
        Parameters:
        queue - The JMS queue name where to send messages to.
        Returns:
        The corresponding JmsIO.Read.
      • withTopic

        public JmsIO.Write<EventT> withTopic​(java.lang.String topic)
        Specify the JMS topic destination name where to send messages to. The JmsIO.Read acts as a publisher on the topic.

        This method is exclusive with withQueue(String). The user has to specify a destination: queue, topic, or topicNameMapper.

        For instance:

        
         .apply(JmsIO.write().withTopic("my-topic")
        
         
        Parameters:
        topic - The JMS topic name.
        Returns:
        The corresponding JmsIO.Read.
      • withUsername

        public JmsIO.Write<EventT> withUsername​(java.lang.String username)
        Define the username to connect to the JMS broker (authenticated).
      • withPassword

        public JmsIO.Write<EventT> withPassword​(java.lang.String password)
        Define the password to connect to the JMS broker (authenticated).
      • withTopicNameMapper

        public JmsIO.Write<EventT> withTopicNameMapper​(org.apache.beam.sdk.transforms.SerializableFunction<EventT,​java.lang.String> topicNameMapper)
        Specify the JMS topic destination name where to send messages to dynamically. The JmsIO.Write acts as a publisher on the topic.

        This method is exclusive with withQueue(String) and withTopic(String). The user has to specify a SerializableFunction that takes EventT object as a parameter, and returns the topic name depending of the content of the event object.

        For example:

        
         SerializableFunction<CompanyEvent, String> topicNameMapper =
           (event ->
            String.format(
            "company/%s/employee/%s",
            event.getCompanyName(),
            event.getEmployeeId()));
         
        
         .apply(JmsIO.write().withTopicNameMapper(topicNameNapper)
         
        Parameters:
        topicNameMapper - The function returning the dynamic topic name.
        Returns:
        The corresponding JmsIO.Write.
      • withValueMapper

        public JmsIO.Write<EventT> withValueMapper​(org.apache.beam.sdk.transforms.SerializableBiFunction<EventT,​javax.jms.Session,​javax.jms.Message> valueMapper)
        Map the EventT object to a Message.

        For instance:

        
         SerializableBiFunction<SomeEventObject, Session, Message> valueMapper = (e, s) -> {
        
               try {
                 TextMessage msg = s.createTextMessage();
                 msg.setText(Mapper.MAPPER.toJson(e));
                 return msg;
               } catch (JMSException ex) {
                 throw new JmsIOException("Error!!", ex);
               }
             };
        
         
        
         .apply(JmsIO.write().withValueMapper(valueNapper)
         
        Parameters:
        valueMapper - The function returning the Message
        Returns:
        The corresponding JmsIO.Write.
      • withRetryConfiguration

        public JmsIO.Write<EventT> withRetryConfiguration​(RetryConfiguration retryConfiguration)
        Specify the JMS retry configuration. The JmsIO.Write acts as a publisher on the topic.

        Allows a retry for failed published messages, the user should specify the maximum number of retries, a duration for retrying and a maximum cumulative retries. By default, the duration for retrying used is 15s and the maximum cumulative is 1000 days RetryConfiguration

        For example:

        
         RetryConfiguration retryConfiguration = RetryConfiguration.create(5);
         
        or
        
         RetryConfiguration retryConfiguration =
           RetryConfiguration.create(5, Duration.standardSeconds(30), null);
         
        or
        
         RetryConfiguration retryConfiguration =
           RetryConfiguration.create(5, Duration.standardSeconds(30), Duration.standardDays(15));
         
        
         .apply(JmsIO.write().withPublicationRetryPolicy(publicationRetryPolicy)
         
        Parameters:
        retryConfiguration - The retry configuration that should be used in case of failed publications.
        Returns:
        The corresponding JmsIO.Write.