In case you are interested, here is the client code:
QueueConnection connection = null;
try {
//send the file into JMS Queue
InitialContext jndiContext = new InitialContext();
//lookup connectinonFactory through JNDI
QueueConnectionFactory connectionFactory = (QueueConnectionFactory)
jndiContext.lookup("java:comp/env/jms/ConnectionFactory");
UserTransaction userTran =
(UserTransaction)jndiContext.lookup("java:comp/UserTransaction");
userTran.begin();
//lookup queue name
log.debug("looking up FileConnectQueue...");
Queue testQueue = (Queue)
jndiContext.lookup("java:comp/env/jms/TestQueue");
//create a connection
connection = connectionFactory.createQueueConnection();
connection.start();
//create a session
log.debug("creating session...");
QueueSession qSession = connection.createQueueSession(true, -1);
//create sender
log.debug("creating sender...");
QueueSender sender = qSession.createSender(testQueue);
//compose Metadata
Map metadata = new HashMap();
metadata.put(MetadataKey.TEST, "test");
TestFile testFile = new TestFile(new byte[]{});
testFile.loadMetadata(metadata);
//convert fcFile into MapMessage
Message message = this.toMessage(qSession, testFile);
sender.send(message);
userTran.commit();
} catch (RuntimeException e) {
log.error("RuntimeException", e);
} catch (Exception ex) {
log.error("Exception caught " + ex);
} finally{
if (connection != null) {
try {
log.debug("closing connection...");
connection.close();
} catch (JMSException e) {
log.error("Unable to close the queue connection.");
}
}
}
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4006979#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...