Class JmsReader


public class JmsReader extends IntegrationReader
Read Records from a Java Message Service (JMS) provider.
  • Constructor Details

    • JmsReader

      public JmsReader(JmsSettings settings)
      Connects to a Java Message Service server.
      Apache ActiveMQ Example:
      Properties props = new Properties();
      props.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.apache.activemq.jndi.ActiveMQInitialContextFactory");
      props.setProperty(Context.PROVIDER_URL,"tcp://localhost:61616");
      DataReader reader = new JmsReader(props, JmsDestinationType.QUEUE, "queueName");

      Read your JMS provider manual for more details

      Parameters:
      properties - the properties required by the JMS server
      type - the type of messaging used
      destinationName - the name of the Topic or Queue
      See Also:
  • Method Details

    • getSettings

      public JmsSettings getSettings()
    • getConnection

      public JmsConnection getConnection()
      Returns the JMS connection or null if the reader has not been opened.
    • getReceiveTimeout

      public Long getReceiveTimeout()
      Returns the timeout interval for receiving messages or null if reads should not timeout (default to null).
      Returns:
      the timeout interval
    • setReceiveTimeout

      public JmsReader setReceiveTimeout(Long timeout)
      Sets the timeout interval for receiving messages or null if reads should not timeout (default to null).
      Parameters:
      timeout - timeout interval for receiving messages
      Returns:
      the JmsReader instance
    • open

      public void open() throws DataException
      Description copied from class: DataEndpoint
      Makes this endpoint ready for reading or writing.
      Overrides:
      open in class IntegrationReader
      Throws:
      DataException
    • close

      public void close() throws DataException
      Description copied from class: DataEndpoint
      Indicates that this endpoint has finished reading or writing.
      Overrides:
      close in class DataEndpoint
      Throws:
      DataException
    • readImpl

      protected Record readImpl() throws Throwable
      Description copied from class: DataReader
      Overridden by subclasses to read the next record from this DataReader. The default implementation of DataReader.read() now insures that this method will not be called again after it returns a null.

      If no record is available, null will be returned.

      Contract for subclasses (see also docs/authoring/DataReader.md):

      Specified by:
      readImpl in class DataReader
      Throws:
      Throwable
    • onMessage

      protected Record onMessage(Message message) throws Throwable
      Converts a received message to a record by message type, adds the JMS header fields and acknowledges it in CLIENT mode; returns null if the message is null.
      Throws:
      Throwable
    • addMessageHeader

      protected void addMessageHeader(Message message, Record record) throws Throwable
      Adds the message's JMS headers as jms_* fields and each message property as a jms_property_ prefixed field.
      Throws:
      Throwable
    • onMapMessage

      protected Record onMapMessage(MapMessage message) throws JMSException
      Converts a map message to a record with one field per map entry.
      Throws:
      JMSException
    • onBytesMessage

      protected Record onBytesMessage(BytesMessage message) throws JMSException
      Converts a bytes message to a record whose message field holds the body bytes.
      Throws:
      JMSException
    • onObjectMessage

      protected Record onObjectMessage(ObjectMessage message) throws JMSException
      Converts an object message to a record whose message field holds the object.
      Throws:
      JMSException
    • onStreamMessage

      protected Record onStreamMessage(StreamMessage message) throws JMSException
      Converts a stream message to a record whose message field holds only the first value read from the stream.
      Throws:
      JMSException
    • onTextMessage

      protected Record onTextMessage(TextMessage message) throws JMSException
      Converts a text message to a record whose message field holds the text.
      Throws:
      JMSException
    • addExceptionProperties

      public DataException addExceptionProperties(DataException exception)
      Description copied from class: Endpoint
      Adds this endpoint's current state to a DataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.
      Overrides:
      addExceptionProperties in class DataReader