public void run(String... strings) throws Exception {
final String msg = "Hello World";
final JCSMPSession session = solaceFactory.createSession();
XMLMessageConsumer cons = session.getMessageConsumer(msgConsumer);
session.addSubscription(topic);
logger.info("Connected. Awaiting message...");
cons.start();
// Consumer session is now hooked up and running!
/** Anonymous inner-class for handling publishing events */
XMLMessageProducer prod = session.getMessageProducer(pubEventHandler);
// Publish-only session is now hooked up and running!
TextMessage jcsmpMsg = JCSMPFactory.onlyInstance().createMessage(TextMessage.class);
jcsmpMsg.setText(msg);
jcsmpMsg.setDeliveryMode(DeliveryMode.PERSISTENT);
logger.info("============= Sending " + msg);
prod.send(jcsmpMsg, topic);
try {
// block here until message received, and latch will flip
msgConsumer.getLatch().await(10, TimeUnit.SECONDS);
} catch (InterruptedException e) {
logger.error("I was awoken while waiting");
}
// Close consumer
cons.close();
logger.info("Exiting.");
session.closeSession();
}