I have a usecase around SAP Enterprise messaging(Consume BusinessEvents from S4HC) to make it multitenant. For this, the approach is by making One queue per tenant and a particular queue would be subscribed to multiple business events of that tenant. Currently, I have achieved the functionality to make it work/listen only for 1 queue with the following code. Note that all the events are asynchronous or non blocking calls with a listener class implemented.
@Bean
public Connection getSession(MessagingServiceJmsConnectionFactory connectionFactory) throws JMSException, InterruptedException {
Connection connection = connectionFactory.createConnection();
//connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue(QUEUE_PREFIX + QUEUE);
final MessageConsumer messageConsumer = session.createConsumer(queue);
messageConsumer.setMessageListener(new DefaultMessageListener());
connection.start();
Thread.sleep(5000);
return connection;
}
Approach is to create queues on subscription callbacks through service manager and to make the application listen to the new queue(add it to existing queues) without stopping/restarting the app. How to get the connection factory session and add the new queues with the listener to make it dynamic using SpringBoot? Can you help in this regard.
This code doesn't look like the SAP Cloud SDK. We checked twice and the mentioned classes are not found in our code. We had PoC support for Enterprise Messaging but deprecated it in favor of the planned release of the library for it by Cloud Application Programming model (CAP)
Check CAP's section on the Event Handlers in Java for more details. As far as I can see from the feature overview table CAP doesn't yet have support for multitenancy with the Java library. Implementation for Node.js is complete in that sense.
In SDK we plan to provide some convenience on top of the CAPs implementation when it's finalized. Their implementation
I think you can approach CAP via their support channels.