Answer the question
In order to leave comments, you need to log in
How and when are connections created by an object of the CachingConnectionFactory class?
Hello. I use activiti 6, and service tasks in the diagram. Almost every service task has the same class that sends some message. Judging by the activity documentation, an instance of this class is created one for each service task. That is, how many service tasks, so many instances of this class will be (but no more). In the class constructor, I create an instance of the org.springframework.amqp.rabbit.connection.CachingConnectionFactory class:
JdbcTemplateNsiDao jdbcTemplateNsiDao = new JdbcTemplateNsiDao();
jdbcTemplateRlDao = new JdbcTemplateRlDao();
String hostName = jdbcTemplateNsiDao.getHostName();
Long port = jdbcTemplateNsiDao.getPort();
logger.info(String.format("Create the ConnectionFactory for the RabbitMQ with host name = %s and port = %d", hostName, port));
CachingConnectionFactory connectionFactory =
new CachingConnectionFactory(hostName, port.intValue());
sendService = new SendServiceImpl(new RabbitTemplate(connectionFactory));
((SendToETPServiceImpl) sendToETPService).setQueueNameForStatusMovement(jdbcTemplateNsiDao.getQueueNameForStatusMovement());
} catch (NamingException | IOException e) {
logger.error("Error while creating JdbcTemplate Dao for Activiti ", e);
}
}
rabbitTemplate.convertAndSend(queueNameForStatusMovement, message);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question