use of org.switchyard.component.test.mixins.hornetq.HornetQMixIn in project quickstarts by jboss-switchyard.
the class HornetQClient method main.
/**
* Only execution point for this application.
* @param ignored not used.
* @throws Exception if something goes wrong.
*/
public static void main(final String[] args) throws Exception {
String[] orders = { "BREAD", "PIZZA", "JAM", "POTATO", "MILK", "JAM" };
if (args.length != 0) {
orders = args;
}
HornetQMixIn hqMixIn = new HornetQMixIn(false).setUser(USER).setPassword(PASSWD);
hqMixIn.initialize();
try {
Session session = hqMixIn.createJMSSession();
MessageProducer producer = session.createProducer(HornetQMixIn.getJMSQueue(ORDER_QUEUE));
for (String order : orders) {
final TextMessage message = session.createTextMessage();
message.setText(order);
producer.send(message);
}
session.close();
session = hqMixIn.createJMSSession();
System.out.println("* * * SHIPPING ORDERS * * *");
MessageConsumer consumer = session.createConsumer(HornetQMixIn.getJMSQueue(SHIPPING_QUEUE));
Message msg = null;
while ((msg = consumer.receive(1000)) != null) {
System.out.println(" - " + hqMixIn.readStringFromJMSMessage(msg));
}
System.out.println();
System.out.println("* * * PENDING ORDERS (FILLING STOCK) * * *");
consumer = session.createConsumer(HornetQMixIn.getJMSQueue(FILLING_STOCK_QUEUE));
while ((msg = consumer.receive(1000)) != null) {
System.out.println(" - " + hqMixIn.readStringFromJMSMessage(msg));
}
session.close();
Thread.sleep(2000);
} finally {
hqMixIn.uninitialize();
}
}
use of org.switchyard.component.test.mixins.hornetq.HornetQMixIn in project quickstarts by jboss-switchyard.
the class JMSClient method sendToHornetQ.
private static void sendToHornetQ() throws Exception {
HornetQMixIn hqMixIn = new HornetQMixIn(false).setUser(HQ_USER).setPassword(HQ_PASSWD);
hqMixIn.initialize();
Session session = null;
try {
session = hqMixIn.createJMSSession();
final MessageProducer producer = session.createProducer(HornetQMixIn.getJMSQueue(QUEUE_NAME));
Message message = hqMixIn.createJMSMessageFromResource(MESSAGE_PAYLOAD);
producer.send(message);
System.out.println("Message sent. Please see server console output");
} finally {
hqMixIn.uninitialize();
}
}
Aggregations