MessageProducer publisher = null;
Connection connection = createConnectionFactory(brokerUrl, isEmbeddedBroker);
if (isPersistent) {
IdGenerator idGenerator = new IdGenerator();
connection.setClientID(idGenerator.generateId());
}
Session session = createSession(connection, TRANSACTED_FALSE);
Destination destination = createDestination(session, subject, isTopic);
publisher = session.createProducer(destination);