Class BrokerConnection

java.lang.Object
com.sap.cds.services.messaging.jms.BrokerConnection

public class BrokerConnection extends Object
Represents the broker connection for outbount (emitter) and inbound (queues) messages. The connection can be shared by several services of the same technical service instance.
  • Constructor Details

    • BrokerConnection

      public BrokerConnection(String name, jakarta.jms.ConnectionFactory connectionFactory)
      Parameters:
      name - name of the connection
      connectionFactory - JMS connection factory
  • Method Details

    • connect

      public void connect() throws IOException
      Connects to the destination broker and creates the emitter session on the broker connection.
      Throws:
      IOException - when any errors occurs
    • close

      public void close() throws jakarta.jms.JMSException
      Closes the connection to the broker.
      Throws:
      jakarta.jms.JMSException - if the JMS provider fails to close the connection due to some internal error.
    • registerQueueListener

      public void registerQueueListener(String queue, MessagingBrokerQueueListener listener, TopicAccessor topicAccessor) throws IOException
      Registers the queue listener for the specified queue.
      Parameters:
      queue - the queue name
      listener - the queue listeners
      topicAccessor - the topic accessor in order to extract the destination topic from the delivered message.
      Throws:
      IOException - when any errors occurs
    • emitTopicMessage

      public void emitTopicMessage(String topic, TopicMessageEventContext messageEventContext)
      Emits the given message to the specified topic
      Parameters:
      topic - topic
      messageEventContext - the message context
    • getName

      public String getName()
      Returns the connection name.
      Returns:
      connection name
    • isConnected

      public boolean isConnected()
      Determines whether the connection is opened.
      Returns:
      true if opened and false otherwise.