Filed under: Musings on Tech stuff, Java, Linux and Open Source
I was reading this article from IBM about how to communicate with Geronimo’s JMS server(ActiveMQ). The sample for the non-J2EE client does not work!
What I did is to take the code from the article and edit the typo and voila! I got some prototype code! I am using IBM Websphere Community Edition(IBM WAS CE), which is synonymous to Geronimo(at least for the first version). By the way, I added the sender code.
Here are the simple steps:
1. Run Geronimo or IBM WAS CE
2. Compile these two classes. Take note that you need the ff. jar files to compile and run these successfully. Here’s the list:
- geronimo-j2ee_1.4_spec.jar
- commons-logging-1.0.4.jar
- concurrent-1.3.4.jar
3. Run the clients.
You’ll find it somewhere under the Geronimo or WAS CE installation directory.
The receiver class
——start————
import java.util.logging.Logger;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.jms.TextMessage;
import org.activemq.ActiveMQConnectionFactory;
public class JMSReceiver {
protected Queue queue;
protected String queueName = “SendReceiveQueue”;
protected String url = “tcp://localhost:61616″;
Logger logger = Logger.getAnonymousLogger();
protected int ackMode = Session.AUTO_ACKNOWLEDGE;
public static void main(String[] args) {
JMSReceiver msgReceiver = new JMSReceiver();
msgReceiver.run();
}
public void run() {
try {
ActiveMQConnectionFactory connectionFactory =
new ActiveMQConnectionFactory(url);
QueueConnection connection =
(QueueConnection)
connectionFactory.createConnection();
connection.start();
MessageConsumer consumer = null;
QueueSession session = connection.createQueueSession(
false,
Session.AUTO_ACKNOWLEDGE);
queue = session.createQueue(queueName);
consumer = session.createReceiver(queue);
logger.info(”Waiting for message (max 5)”);
for (int i = 0; i < 5; i++) {
Message message = consumer.receive();
processMessage(message);
}
logger.info(”Closing connection”);
consumer.close();
session.close();
connection.close();
} catch (Exception e) {
logger.info(”Caught: ” + e);
e.printStackTrace();
}
}
public void processMessage(Message message) {
try {
TextMessage txtMsg = (TextMessage) message;
logger.info(”Received a message: ” + txtMsg.getText());
} catch (Exception e) {
logger.info(”Caught: ” + e);
e.printStackTrace();
}
}
}——–end———
The sender class
——————-
import java.util.logging.Logger;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.jms.TextMessage;
import org.activemq.ActiveMQConnectionFactory;
public class JMSSender {
private Queue receiveQueue = null;
protected String queueName = “SendReceiveQueue”;
protected String url = “tcp://localhost:61616″;
Logger logger = Logger.getAnonymousLogger();
public static void main(String[] args) {
JMSSender msgSender = new JMSSender();
msgSender.run();
}
public void run() {
QueueConnection queueConn = null;
QueueSession queueSess = null;
TextMessage myMessage = null;
QueueSender queueSender = null;
try {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(
url);
queueConn = factory.createQueueConnection();
queueSess = queueConn.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
receiveQueue = queueSess.createQueue(queueName);
queueSender = queueSess.createSender(receiveQueue);
myMessage = queueSess.createTextMessage();
myMessage.setText(”test from JMS client 2″);
queueSender.send(myMessage);
queueSender.close();
queueSess.close();
queueConn.close();
} catch (Exception e) {
logger.info(”Caught: ” + e);
e.printStackTrace();
}
}
}
—————–
Anyway, I hope this code might be useful for those interested in JMS. Enjoy and happy coding! If you have queries or if anything is not working, just drop me a note.
Filed under: Uncategorized
After a great career, Michael Schumacher decides to call it quits. He announced his retirement after winning the Monza Grand Prix.
“The Scuderia also announced Kimi Raikkonen would team up with Felipe Massa in 2007″.
Full news here…
Kimi and Ferrari will definitely make history!
We had nothing to do last Saturday night. Here’s another experiment using Nikon CLS…The Canon 350D is not really for sale. I just made the comment up for fun. I used my friend’s camera as one of my subjects. This site seems to have a weird crop. To see the correct crops, visit my flickr site at http://www.flickr.com/photos/melvindave/.





Filed under: Uncategorized
Here’s a sample shot I took using my on-board flash, one sb800 for the background and the Sunpak slave.

I used my SB800 to provide the background by bouncing it off the wall. The lighting for the shadows came from the Sunpak slave. I used manual mode in my cam and set SU4 in my SB800 flash.

The yellow color was made possible by the plastic bag covering my SB800.

That’s all folks!
Filed under: Lost in Singapore
It was the day I was waiting for a long time. I was really very anxious to go back home. Last time I went home for a holiday was last Feb. I went to Orchard to have my lunch and do some last minute stuf. I finished at about 3PM.
My flight was at 510PM so I had to go back home and proceed to the airport. I left home at about 4PM and arrived at Changi airport terminal 2 by 420PM. I checked in my baggage and I was out of the immigration at about 435PM. Hmmm…that was very efficient. No wonder that Changi is one of the best airports all over the world. The efficiency bought me time to have some SG dollars exchanged to the Phil. peso. I boarded the plane at about 505PM. After a few minutes the plane took off. Singapore Airlines(SQ) was really punctual.
For while I was wondering why SQ was the most expensive flight going home. It was my first time to fly SQ and I was excited when I saw that every seat has its own tv screen. Cool! Hmmm… Another thing, the flight attendants were realy cute! I was really impressed! hahahaha
Food was not so great though. I didn’t like the main course. Well, it was good anyway since I was also hungry. The ice cream was really good. Plus, the red wine! Red wine’s really nice with choco ice cream. hahaha!
I had the chance to play around with Kris World. This is what they call their in-flight entertainment system. There are a lot of stuff to watch in Kris World. I watched Firewall starring Harrison Ford. The movie wasn’t that nice so I didn’t finish it so I watched The Simpsons and Discovery’s Super homes alternately. The selections were also cool. They had some famous TV series like CSI NY and House. For I moment I wished that the flight was longer. At about 830PM, the pilot announced that we were landing Ninoy Aquino Int’l Airport(NAIA) in a while. Flight was generally smooth. There’s just some turbulence but it was just normal. SQ’s service was really great. There was really no dull moment.
At about 9PM I was out of the Phil. immigration. It was really good that there were a good number of immigation officers to serve us. Service was also efficient! NAIA is better compared to PAL’s centennial airport. I just wish Terminal 3 would be opened soon since the facility’s size really rocks. It looks like a truly world-class airport. I hope when I get back for the Christmas holidays I would arrive in that airport
We went straight to Gerry’s at Jupiter to have dinner. I haven’t tasted real Mango shake for a while now. After dinner, we went to Coffee Bean in Greenbelt 3 to cap the night off.
It’s really nice to be back home!!! There’s really no place like home!
Filed under: Musings on Tech stuff, Java, Linux and Open Source
I was curious on how fast is it to do a web application with Ruby on Rails. They say it is really fast compared to creating a Java web application.
After some searching over the net, I found Locomotive. Locomotive is a pre-packaged application which bundles all the requirements of a Rails web application. It aims to get you started with Ruby on Rails minus the headache. It is self-contained. It can even run with the other ruby installations. Too bad it only runs on a Mac. I didn’t wait any longer and installed it in my machine. Installation is a breeze. Just click and drag it to the applications directory. The interface to control running instances of rails apps is straightforward.
After that I looked for some tutorials, I found this article the easiest to understand.
http://alliance.seas.upenn.edu/~matuszek/wiki700/index.php?n=Main.Locomotive
It took me maybe less than an hour to create my first Rails application. Hmmm…I don’t even have background with Rails! I was amazed how fast it can be done. Actually, I was stuck because my crappy text editor couldn’t save the proper filename. Dang! It could just have been a few minutes. Haha! The sample is not just the simple Hello World thingy but it has some database stuff wherein the users are able to do the usual CRUD routine from the web browser.
Rails is very interesting. I think I’ll use this thing for my pet projects. hehehe
Filed under: Uncategorized
Fresh from Taiwan, my colleague has brought us some good news. Our product got APECrecognition! http://www.lemongreen.biz.
Filed under: Uncategorized
I shot some 400 photos during our photo clinic this afternoon…When I went home my CF was corrupted!!! I lost all of my photos…
Filed under: Uncategorized
The Smart Pinoy SIM rocks! I was texting my friend as if I was in Manila. Piso lang(Php1.00) kasi ang gastos nya to text me back here in Singapore. This service is great for OFWs who need to keep in touch with their relatives back home.
The catch? Your friend or loved one should be using a Smart or Talk and Text SIM. Well, it’s not really an issue
Filed under: Lost in Singapore
At last, high-resolution photos of the Philippines in Google Earth! Here's a snapshot of UP Diliman using the latest version of the cool app.
