Class BrokerConnection
java.lang.Object
com.sap.cds.services.messaging.jms.BrokerConnection
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 Summary
ConstructorsConstructorDescriptionBrokerConnection(String name, jakarta.jms.ConnectionFactory connectionFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the connection to the broker.voidconnect()Connects to the destination broker and creates the emitter session on the broker connection.voidemitTopicMessage(String topic, TopicMessageEventContext messageEventContext) Emits the given message to the specified topicgetName()Returns the connection name.booleanDetermines whether the connection is opened.voidregisterQueueListener(String queue, MessagingBrokerQueueListener listener, TopicAccessor topicAccessor) Registers the queue listener for the specified queue.
-
Constructor Details
-
BrokerConnection
- Parameters:
name- name of the connectionconnectionFactory- JMS connection factory
-
-
Method Details
-
connect
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.JMSExceptionCloses 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 namelistener- the queue listenerstopicAccessor- the topic accessor in order to extract the destination topic from the delivered message.- Throws:
IOException- when any errors occurs
-
emitTopicMessage
Emits the given message to the specified topic- Parameters:
topic- topicmessageEventContext- the message context
-
getName
Returns the connection name.- Returns:
- connection name
-
isConnected
public boolean isConnected()Determines whether the connection is opened.- Returns:
trueif opened andfalseotherwise.
-