use of javax.jms.TextMessage in project hive by apache.
the class TestMsgBusConnection method testConnection.
public void testConnection() throws Exception {
try {
driver.run("create database testconndb");
Message msg = consumer.receive(TIMEOUT);
assertTrue("Expected TextMessage", msg instanceof TextMessage);
assertEquals(HCatConstants.HCAT_CREATE_DATABASE_EVENT, msg.getStringProperty(HCatConstants.HCAT_EVENT));
assertEquals("topic://planetlab.hcat", msg.getJMSDestination().toString());
HCatEventMessage messageObject = MessagingUtils.getMessage(msg);
assertEquals("testconndb", messageObject.getDB());
broker.stop();
driver.run("drop database testconndb cascade");
broker.start(true);
connectClient();
driver.run("create database testconndb");
msg = consumer.receive(TIMEOUT);
assertEquals(HCatConstants.HCAT_CREATE_DATABASE_EVENT, msg.getStringProperty(HCatConstants.HCAT_EVENT));
assertEquals("topic://planetlab.hcat", msg.getJMSDestination().toString());
assertEquals("testconndb", messageObject.getDB());
driver.run("drop database testconndb cascade");
msg = consumer.receive(TIMEOUT);
assertEquals(HCatConstants.HCAT_DROP_DATABASE_EVENT, msg.getStringProperty(HCatConstants.HCAT_EVENT));
assertEquals("topic://planetlab.hcat", msg.getJMSDestination().toString());
assertEquals("testconndb", messageObject.getDB());
} catch (NoSuchObjectException nsoe) {
nsoe.printStackTrace(System.err);
assert false;
} catch (AlreadyExistsException aee) {
aee.printStackTrace(System.err);
assert false;
}
}
use of javax.jms.TextMessage in project quickstarts by jboss-switchyard.
the class JmsBindingTest method testRollbackA.
/**
* Triggers the 'WorkService' by sending a HornetQ Message to the 'policyQSTransacted' queue.
*/
@Test
public void testRollbackA() throws Exception {
String command = "rollback.A";
Connection conn = _connectionFactory.createConnection(HORNETQ_USER, HORNETQ_PASSWORD);
conn.start();
try {
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(_queueIn);
TextMessage message = session.createTextMessage();
message.setText(command);
producer.send(message);
session.close();
session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(_queueOutA);
TextMessage msg = TextMessage.class.cast(consumer.receive(30000));
Assert.assertEquals(command, msg.getText());
Assert.assertNull(consumer.receive(1000));
consumer.close();
consumer = session.createConsumer(_queueOutB);
msg = TextMessage.class.cast(consumer.receive(1000));
Assert.assertEquals(command, msg.getText());
msg = TextMessage.class.cast(consumer.receive(1000));
Assert.assertEquals(command, msg.getText());
msg = TextMessage.class.cast(consumer.receive(1000));
Assert.assertEquals(command, msg.getText());
msg = TextMessage.class.cast(consumer.receive(1000));
Assert.assertEquals(command, msg.getText());
Assert.assertNull(consumer.receive(1000));
consumer.close();
consumer = session.createConsumer(_queueOutC);
msg = TextMessage.class.cast(consumer.receive(1000));
Assert.assertEquals(command, msg.getText());
msg = TextMessage.class.cast(consumer.receive(1000));
Assert.assertEquals(command, msg.getText());
msg = TextMessage.class.cast(consumer.receive(1000));
Assert.assertEquals(command, msg.getText());
msg = TextMessage.class.cast(consumer.receive(1000));
Assert.assertEquals(command, msg.getText());
Assert.assertNull(consumer.receive(1000));
session.close();
} finally {
conn.close();
}
}
use of javax.jms.TextMessage in project quickstarts by jboss-switchyard.
the class OrderIntakeClient method main.
/**
* Main routing for OrderIntakeClient
* @param args command-line args
* @throws Exception if something goes wrong.
*/
public static void main(final String[] args) throws Exception {
HornetQMixIn hqMixIn = new HornetQMixIn(false).setUser(USER).setPassword(PASSWD);
hqMixIn.initialize();
try {
Session session = hqMixIn.getJMSSession();
MessageProducer producer = session.createProducer(HornetQMixIn.getJMSQueue(ORDER_QUEUE_NAME));
String orderTxt = readFileContent(args[0]);
System.out.println("Submitting Order" + "\n" + "----------------------------\n" + orderTxt + "\n----------------------------");
producer.send(hqMixIn.createJMSMessage(orderTxt));
MessageConsumer consumer = session.createConsumer(HornetQMixIn.getJMSQueue(ORDERACK_QUEUE_NAME));
System.out.println("Order submitted ... waiting for reply.");
TextMessage reply = (TextMessage) consumer.receive(3000);
if (reply == null) {
System.out.println("No reply received.");
} else {
String str = reply.getText();
System.out.println("Received reply" + "\n" + "----------------------------\n" + str + "\n----------------------------");
}
} finally {
hqMixIn.uninitialize();
}
}
use of javax.jms.TextMessage 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();
}
}
use of javax.jms.TextMessage 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 {
HornetQMixIn hqMixIn = new HornetQMixIn(false).setUser(USER).setPassword(PASSWD);
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;
}
hqMixIn.initialize();
try {
final Session session = hqMixIn.createJMSSession();
final MessageProducer producer = session.createProducer(HornetQMixIn.getJMSQueue(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 + "]");
Thread.sleep(2000);
} finally {
hqMixIn.uninitialize();
}
}
Aggregations