use of org.switchyard.component.test.mixins.activemq.ActiveMQMixIn in project quickstarts by jboss-switchyard.
the class ActiveMQClient 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;
}
ActiveMQMixIn mixIn = new ActiveMQMixIn();
try {
Session session = mixIn.getSession();
MessageProducer producer = session.createProducer(session.createQueue(ORDER_QUEUE));
for (String order : orders) {
final TextMessage message = session.createTextMessage();
message.setText(order);
producer.send(message);
}
session.close();
session = mixIn.getSession();
System.out.println("* * * SHIPPING ORDERS * * *");
MessageConsumer consumer = session.createConsumer(session.createQueue(SHIPPING_QUEUE));
Message msg = null;
while ((msg = consumer.receive(1000)) != null) {
if (msg instanceof TextMessage) {
System.out.println(" - " + ((TextMessage) msg).getText());
}
}
System.out.println();
System.out.println("* * * PENDING ORDERS (FILLING STOCK) * * *");
consumer = session.createConsumer(session.createQueue(FILLING_STOCK_QUEUE));
while ((msg = consumer.receive(1000)) != null) {
if (msg instanceof TextMessage) {
System.out.println(" - " + ((TextMessage) msg).getText());
}
}
session.close();
Thread.sleep(2000);
} finally {
mixIn.uninitialize();
}
}
use of org.switchyard.component.test.mixins.activemq.ActiveMQMixIn in project quickstarts by jboss-switchyard.
the class ActiveMQClient 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 {
ActiveMQMixIn mixIn = new ActiveMQMixIn();
if (args.length == 0) {
System.err.println("ERROR: Use -Dexec.args to pass a name and language value, e.g. -Dexec.args=\"Skippy english\"");
return;
}
try {
final Session session = mixIn.getSession();
final MessageProducer producer = session.createProducer(session.createQueue(QUEUE));
final TextMessage message = session.createTextMessage();
String payload = TEMPLATE.replace("@name@", args[0]);
if (args.length == 2) {
payload = payload.replace("@lang@", args[1]);
} else {
payload = payload.replace("@lang@", "english");
}
System.out.println(payload);
message.setText(payload);
producer.send(message);
System.out.println("Sent message [" + message + "]");
session.close();
} finally {
mixIn.uninitialize();
}
}
Aggregations