Tuesday, 29 September 2009
Welcome to a new committer
We have a new committer on board! :)
Diego Naya joins us from Plug Tree Labs where he is the CEO.
Diego is based in Argentina. Welcome to Diego!
Friday, 25 September 2009
Friday, 11 September 2009
Back from JBossWorld and on with HornetQ
Finally I seem to be recovering from an extended period of jet lag after returning from JBossWorld/Red Hat summit in Chicago.
The conference was a great success - it was the first time JBossWorld joined forces with the Red Hat guys to create a joint conference.
The HornetQ presentation was received very well. We had a good attendance and lots of questions at the end. It's just a shame the presentations weren't video'd - otherwise we could have put it in youtube. Next year I think I will bring along my own video camera and tripod and do it myself!
So, what's next? Next stop is HornetQ 2.0 GA. I'm guessing we have around 6 to 8 weeks work to get this out. But of course this depends on how many distractions we are getting. And right now there are a lot ;)
Onwards to GA...
Tuesday, 1 September 2009
A HornetQ Simple Example using Maven
Since HornetQ can be run embedded and can be run with no little or no thirdparty dependencies, its easy to create a simple project that runs an embedded server or simple client. The example code can be downloaded from here and can be built and run as follows:
To build both the embedded server and client run mvn package from the root directory.
To run the server run mvn exec:java from the embedded-server directory.
To run the client run mvn exec:java from the client directory.
Now lets look more closely at both examples in more detail.
embedded server
Lets start by looking at the dependencies in the pom.xml found under the embedded-server directory.
The dependencies needed are configured as follows:
<dependencies> <dependency> <groupId>org.hornetq</groupId> <artifactId>hornetq-core</artifactId> <version>2.0.0.GA</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.hornetq</groupId> <artifactId>hornetq-jms</artifactId> <version>2.0.0.GA</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.hornetq</groupId> <artifactId>hornetq-logging</artifactId> <version>2.0.0.GA</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.hornetq</groupId> <artifactId>hornetq-transports</artifactId> <version>2.0.0.GA</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.jboss.netty</groupId> <artifactId>netty</artifactId> <version>3.1.0.GA</version> </dependency> <dependency> <groupId>org.jboss.javaee</groupId> <artifactId>jboss-jms-api</artifactId> <version>1.1.0.GA</version> <scope>compile</scope> </dependency>These dependencies are what you would need to run a HornetQ JMS server now lets look at the code needed to run an embedded server:
public class EmbeddedServer { public static void main(String[] args) throws Exception { try { FileConfiguration configuration = new FileConfiguration(); configuration.setConfigurationUrl("hornetq-configuration.xml"); configuration.start(); HornetQServer server = HornetQServers.newHornetQServer(configuration); JMSServerManager jmsServerManager = new JMSServerManagerImpl(server, "hornetq-jms.xml"); //if you want to use JNDI, simple inject a context here or don't call this method and make sure the JNDI parameters are set. jmsServerManager.setContext(null); jmsServerManager.start(); System.out.println("STARTED::"); } catch (Throwable e) { System.out.println("FAILED::"); e.printStackTrace(); } } }You can configure the server via the hornetq-configuration.xml file and configure any JMS objects via the hornetq-jms.xml file. Of course you can do much more than this with your server but this is a good starting point. Consult the HornetQ documentation for more information of what other features are available. client The client example shows how you can easily create a HornetQ JMS client using minimal jars. The dependencies this time are much smaller than the server and contain client jars that HornetQ provides for lightweight client apps.
<dependency> <groupId>org.hornetq</groupId> <artifactId>hornetq-core-client</artifactId> <version>2.0.0.GA</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.hornetq</groupId> <artifactId>hornetq-jms-client</artifactId> <version>2.0.0.GA</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.hornetq</groupId> <artifactId>hornetq-transports</artifactId> <version>2.0.0.GA</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.jboss.netty</groupId> <artifactId>netty</artifactId> <version>3.1.0.GA</version> </dependency> <dependency> <groupId>org.jboss.javaee</groupId> <artifactId>jboss-jms-api</artifactId> <version>1.1.0.GA</version> <scope>compile</scope> </dependency>The client code in this case is copied from one of the HornetQ examples, running this client will send a message to the server that was started earlier.
public static void main(String[] args) throws Exception { Connection connection = null; try { // Step 1. Directly instantiate the JMS Queue object. Queue queue = HornetQJMSClient.createQueue("exampleQueue"); // Step 2. Instantiate the TransportConfiguration object which contains the knowledge of what transport to use, // The server port etc. MapYou can use this template as a starting point for any projects you may want to create that would use HornetQ as a client or as an embedded server.connectionParams = new HashMap (); connectionParams.put(PORT_PROP_NAME, 5445); TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getName(), connectionParams); // Step 3 Directly instantiate the JMS ConnectionFactory object using that TransportConfiguration ConnectionFactory cf = HornetQJMSClient.createConnectionFactory(transportConfiguration); // Step 4.Create a JMS Connection connection = cf.createConnection(); // Step 5. Create a JMS Session Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); // Step 6. Create a JMS Message Producer MessageProducer producer = session.createProducer(queue); // Step 7. Create a Text Message TextMessage message = session.createTextMessage("This is a text message"); System.out.println("Sent message: " + message.getText()); // Step 8. Send the Message producer.send(message); // Step 9. Create a JMS Message Consumer MessageConsumer messageConsumer = session.createConsumer(queue); // Step 10. Start the Connection connection.start(); // Step 11. Receive the message TextMessage messageReceived = (TextMessage)messageConsumer.receive(5000); System.out.println("Received message: " + messageReceived.getText()); } finally { if (connection != null) { connection.close(); } } }
Subscribe to:
Posts (Atom)