
[{"content":"","date":"July 29, 2026","externalUrl":null,"permalink":"/categories/ai/","section":"Categories","summary":"","title":"AI","type":"categories"},{"content":"","date":"July 29, 2026","externalUrl":null,"permalink":"/categories/","section":"Categories","summary":"","title":"Categories","type":"categories"},{"content":"","date":"July 29, 2026","externalUrl":null,"permalink":"/","section":"Dejan Bosanac","summary":"","title":"Dejan Bosanac","type":"page"},{"content":"We put a lot of effort into building context for our coding agents, but we rarely treat that context with the same engineering rigor as the rest of the project. I wanted to explore what it looks like when we do. Starting with the basics: what AGENTS.md and Agent Skills are and why they matter.\nhttps://developers.redhat.com/articles/2026/07/27/standardize-project-context-agentsmd-and-agent-skills\nNext up, I\u0026rsquo;ll dive into topics like authoring, testing, evals, CI integration, etc.\n","date":"July 29, 2026","externalUrl":null,"permalink":"/posts/2026-07-29-master-your-skills/","section":"Posts","summary":"We put a lot of effort into building context for our coding agents, but we rarely treat that context with the same engineering rigor as the rest of the project. I wanted to explore what it looks like when we do. Starting with the basics: what AGENTS.md and Agent Skills are and why they matter.\nhttps://developers.redhat.com/articles/2026/07/27/standardize-project-context-agentsmd-and-agent-skills\nNext up, I’ll dive into topics like authoring, testing, evals, CI integration, etc.\n","title":"Master your skills","type":"posts"},{"content":"","date":"July 29, 2026","externalUrl":null,"permalink":"/posts/","section":"Posts","summary":"","title":"Posts","type":"posts"},{"content":"","date":"August 17, 2015","externalUrl":null,"permalink":"/categories/iot/","section":"Categories","summary":"","title":"IoT","type":"categories"},{"content":"","date":"August 17, 2015","externalUrl":null,"permalink":"/categories/messaging/","section":"Categories","summary":"","title":"Messaging","type":"categories"},{"content":"Deploying message broker for an IoT use case introduces some new challenges to the broker scalability. We\u0026rsquo;re talking now about thousands of connections, consumers and destinations, which make us think of how we provision, configure and monitor our messaging infrastructure much more carefully. In this post I\u0026rsquo;ll try to sum up some of techniques that can be used with the current Apache ActiveMQ in terms to scale it better for IoT deployment. I\u0026rsquo;ll also describe some of the new features we developed for the 5.12.0 release to make it a better fit in this new world. And finally I\u0026rsquo;ll try to explain where we can go from here and what can we work on in the future.\nActiveMQ Vertical Scaling # The two most common messaging protocols used for IoT are MQTT and AMQP and we spent a significant effort to make them rock-solid in the latest releases. But protocols aren\u0026rsquo;t everything and every time someone starts play with the broker, the same question arise: How can I get the maximum scalability from the single broker instance? So, here are some tips:\nAlways start with the general broker scaling techniques. That basically means to try using as minimal threads as possible no matter how much connections and destinations your broker handles. So use NIO transport and turn of thread-per-destination setup.\nThe first implementation of MQTT protocol for ActiveMQ assumed that QoS1 and QoS2 subscribers are mapped internally to JMS durable subscribers. JMS durable subscribers have a heavy state and don\u0026rsquo;t scale very well. In later versions, you can opt for another implementation that uses virtual topics instead and should scale much better.\n\u0026lt;transportConnectors\u0026gt; \u0026lt;transportConnector name=\u0026#34;mqtt+nio\u0026#34; uri=\u0026#34;mqtt+nio://0.0.0.0:1883\u0026amp;transport.subscriptionStrategy=mqtt-virtual-topic-subscriptions\u0026#34;/\u0026gt; \u0026lt;/transportConnector\u0026gt; One more reason to try the new 5.12.0 release is the new improvements of KahaDB message store that can now preallocate journal files. You can find more information about this in this post, but these tweaks on some file systems can gain significant performance improvements\nAll these little configuration tweaks are summed in the new example configuration file, which you can find in the\nexamples/conf/activemq-mqtt.xml file in the new 5.12.0 distribution.\nVertically scaling the broker is only one part of the equation. There a couple more important questions that needs to be met for the successful IoT deployment.\nSSL # Many IoT devices depend on SSL certificates for authentication purposes. This is not something new and we saw that in traditional messaging setups as well (and supported it), but the difference is, again, in the scale. It\u0026rsquo;s easy to manually maintain a keystore with a handful of certificates in it. It\u0026rsquo;s entirely different story when the number of certificates start to raise.\nIn 5.12.0 we added some new features to help people deal with this. There are a couple of tools that are standardised for solving these problems and supported in JDK. So now, you can use Certificate Revocation List, which provides an easy way to revoke invalid certificates during the runtime.\nYou can also use OCSP (Online Certificate Status Protocol) which provides even more automated way to communicate with your certificate authority. You can find more information about these features here.\nI think that SSL certificate provisioning is much bigger story for IoT deployments (and clouds in general) and there are already some interesting projects emerging solve it, like pki.io. We\u0026rsquo;ll try to support whatever people use in this space and right now with the support of CRL and OCSP you can have a little more flexibility when dealing with your certificates.\nMonitoring under stress # One topic I often encounter when talking about IoT deployments is how to monitor the broker that is on its limits of the vertical scaling (whatever they are). We usually monitor the broker behaviour using JMX or advisory messages. While these are perfect tools when the broker is under its limits, things get less optimal when you\u0026rsquo;re on the edge.\nWith large number of destinations and connections coming and going, registering MBeans and firing advisory messages can become very expensive, especially when done in high volume. It can get in the way of the actual work the broker needs to do.\nFolks that want to get maximum from their broker instance usually just turn everything off, like\n\u0026lt;broker useJmx=\u0026#34;false\u0026#34; advisorySupport=\u0026#34;false\u0026#34; ...\u0026gt; but that leave us with no insight in the state of the broker, beyond peaking into the logs.\nOne solution we came up with is making an mbean registration more selective\nStarting with 5.12.0, you can define mbean names you want to suppress from registering, by defining them on the management context, like\n\u0026lt;managementContext\u0026gt; \u0026lt;managementContext suppressMBean=\u0026#34;endpoint=dynamicProducer,endpoint=Consumer, connectionName=*,destinationName=ActiveMQ.Advisory.*\u0026#34;/\u0026gt; \u0026lt;/managementContext\u0026gt; Using this feature, you can customize what view of the broker you need and by suppressing registration/unregistration of high frequency ephemeral mbeans, you can help your broker deal with the load. So even in the high scale/load scenario, you can get the basic metrics of the broker. There is much more we can do in this space, by defining custom views and such, so stay tuned.\nLegacy MQTT # Apache ActiveMQ implements MQTT 3.1.1 specification, but MQTT is not a new protocol and there is already a vast amount of devices deployed that use older (3.1) clients. We made an effort to enable known use cases where older clients expect different behaviour than what\u0026rsquo;s in the 3.1.1 specification. So for example, you can enable publishing to the \u0026ldquo;dollar topics\u0026rdquo; and see a difference in behaviour on unsuccessful subscription attempts. We\u0026rsquo;ll try to cover all these corner cases and provide the support for legacy clients where it is sensible thing to do so.\nActiveMQ Artemis # In case you weren\u0026rsquo;t paying attention, there have been a bit of a consolidation in the Java message brokers land. The HornetQ broker has been donated to the Apache and is now part of the ActiveMQ project. Its asynchronous core gives us a good base for the next generation ActiveMQ that should scale better and have better performances than the current broker. It already have an initial support for AMQP and MQTT protocols. With these protocols hardened and features above fully implemented, it should be a very good message broker for the backbone of your IoT infrastructure.\nHelp from the friends # Having a good message a broker is sure an important piece of the puzzle. But for truly large IoT deployments we\u0026rsquo;ll need more than that. We need to have a more complex infrastructure that will allow us to partition our traffic (in terms of connections, destination, etc.), provide fault tolerance and high availability capabilities. There are a couple of interesting projects that can help build an elastic messaging infrastructure for IoT needs.\nQpid Dispatch Router provides a broker-less routing of messages between clients, brokers and other endpoints based on AMQP. It helps build optimal topologies and routing messages from clients to their final destination. For example, dispatch router can serve as gateway between clients and broker, helping the large number of connections or destinations be concentrated and partitioned over multiple brokers without client awareness. That\u0026rsquo;s only one of the examples where adding a router to your messaging network can help. It\u0026rsquo;s an interesting topic and you\u0026rsquo;ll hear much more interesting things in this space in the future.\nFabric8 and OpenShift, on the other hand provide us with an easy way to provision and manage this messaging infrastructure. You can use them to easily deploy new brokers, routers, gateways and discover existing components. Fabric8 also provide a gateway that can be used to partition the traffic among the endpoints.\nThere are a many ways to slice this problem and the final solution is certainly dependent on the actual use case. But having all these components rock solid and working nicely together is crucial in architecting the final solution.\nConclusion # With this post I tried to give some perspective on where we are and where we\u0026rsquo;re heading with the supporting IoT cases. I hoped you enjoyed it and found it useful. I\u0026rsquo;ll cover this topic in much more details at Voxxed Days Belgrade and ApacheCon in October. For the end, take a look at the awesome Red Hat Summit IoT demo, which shows some of the this stuff in practice.\n","date":"August 17, 2015","externalUrl":null,"permalink":"/posts/2015-08-17-messaging-for-iot/","section":"Posts","summary":"Deploying message broker for an IoT use case introduces some new challenges to the broker scalability. We’re talking now about thousands of connections, consumers and destinations, which make us think of how we provision, configure and monitor our messaging infrastructure much more carefully. In this post I’ll try to sum up some of techniques that can be used with the current Apache ActiveMQ in terms to scale it better for IoT deployment. I’ll also describe some of the new features we developed for the 5.12.0 release to make it a better fit in this new world. And finally I’ll try to explain where we can go from here and what can we work on in the future.\n","title":"Messaging for IoT","type":"posts"},{"content":"We introduced HawtIO console as a tech preview in 5.9.0 ActiveMQ release, with an idea to replace the old and rusty web console in the distribution. Unfortunately, that idea didn\u0026rsquo;t go well with the rest of Apache community so it\u0026rsquo;s voted out and 5.9.1 is released without it. You can read more on the topic of distributing non-Apache developed web consoles in Apache projects in this (lengthy) thread if you\u0026rsquo;re interested.\nAnyhow, there\u0026rsquo;s a lot of people out there who liked HawtIO and are asking questions on how to use it with the future (and some old) releases. So here, I\u0026rsquo;ll try to sum up different ways of how ActiveMQ and HawtIO can be used together.\nHawtIO is pure JavaScript application that doesn\u0026rsquo;t have any server-side component. It uses Jolokia REST API to access managed servers. As a pure JavaScript application it\u0026rsquo;s possible to package it as a Chrome application, so you can run HawtIO locally in your browser. Take a look at the HawtIO Get Started guide on how to do this.\nOnce, you have your console running you can use it to connect to any remote broker, running management REST API (5.8.0 and newer). Take a look at this connect form\nYou can notice that management API uses /api/jolokia/ path and that by default ActiveMQ web server is listening on port 8161. Just click Connect to remote server and you\u0026rsquo;ll have the access to the broker.\nThe nice thing is that you can save different broker settings in the application, so it\u0026rsquo;s easy to connect to any of the brokers you have in your environment with the single click.\nSo, if you\u0026rsquo;re a Chrome user or willing to use Chrome apps in this way, there\u0026rsquo;s really nothing stopping you from accessing remote brokers from your local HawtIO instance.\nIf this solution is not ideal for you, you can always embed the console back in your ActiveMQ installation. Luckily, it\u0026rsquo;s very easy thing to do.\nFirst, you need to download Hawtio default war, presumably in the webapps/ directory of your installation\ncd webapps wget http://central.maven.org/maven2/io/hawt/hawtio-default/1.3.1/hawtio-default-1.3.1.war Now, add appropriate web application context to the web server, by adding something lile\n\u0026lt;bean class=\u0026#34;org.eclipse.jetty.webapp.WebAppContext\u0026#34;\u0026gt; \u0026lt;property name=\u0026#34;contextPath\u0026#34; value=\u0026#34;/hawtio\u0026#34; /\u0026gt; \u0026lt;property name=\u0026#34;war\u0026#34; value=\u0026#34;${activemq.home}/webapps/hawtio-default-1.3.1.war\u0026#34; /\u0026gt; \u0026lt;property name=\u0026#34;logUrlOnStart\u0026#34; value=\u0026#34;true\u0026#34; /\u0026gt; \u0026lt;/bean\u0026gt; to the etc/jetty.xml\nThe final step is to configure HawtIO authentication and adjust it to the broker\u0026rsquo;s one. This is done by providing the following system properties\n-Dhawtio.realm=activemq -Dhawtio.role=admins -Dhawtio.rolePrincipalClasses=org.apache.activemq.jaas.GroupPrincipal The easiest way to do it, is to add them to the ACTIVEMQ_OPTS variable in the bin/activemq startup script.\nNow, run your broker and enjoy the hawtness.\nFinally, if you\u0026rsquo;re interested in a great platform for running ActiveMQ and other integration technologies (HawtIO included), you should definitely give fabric8 a try. It provides an easy way to provision, configure and manage vast array of integration endpoints (broker included).\nOr if you prefer standalone broker installation, you can try RedHat distributions that still come with the HawtIO included by default.\nSo, even if HawtIO is not distributed with ActiveMQ, you can easily use it in number of different setups depending solely on your preference.\n","date":"April 29, 2014","externalUrl":null,"permalink":"/posts/2014-04-29-activemq-and-hawtio/","section":"Posts","summary":"We introduced HawtIO console as a tech preview in 5.9.0 ActiveMQ release, with an idea to replace the old and rusty web console in the distribution. Unfortunately, that idea didn’t go well with the rest of Apache community so it’s voted out and 5.9.1 is released without it. You can read more on the topic of distributing non-Apache developed web consoles in Apache projects in this (lengthy) thread if you’re interested.\nAnyhow, there’s a lot of people out there who liked HawtIO and are asking questions on how to use it with the future (and some old) releases. So here, I’ll try to sum up different ways of how ActiveMQ and HawtIO can be used together.\n","title":"ActiveMQ and HawtIO","type":"posts"},{"content":"So, we have more and more users want to connect to ActiveMQ directly from the browser using WebSockets. For quite a while now we support Stomp clients which are really easy to use from JavaScript. Now, as more mobile users trying the same approach, we added support for very efficient binary MQTT protocol to the mix for upcoming 5.9.0 version.\nThe good thing is that you really don\u0026rsquo;t have to change anything on the broker side to support it. Both Stomp and MQTT can work over the same connector, as clients identify the protocol they want to use when they initialize the connection. We also provided a nice little demo using Eclipse Paho JavaScript client. You can play with the demo if you start the broker with activemq-demo.xml config like\nbin/activemq console xbean:conf/activemq-demo.xml And go to the\nhttp://localhost:8161/demo/mqtt/\nYou can also peek at the source code\nIf you\u0026rsquo;re interested in messaging for web and mobile, I\u0026rsquo;ll be talking more about Stomp, MQTT, WebSocket and stuff at OSCON later this July, so pop by if you can. Happy messaging!\n","date":"July 5, 2013","externalUrl":null,"permalink":"/posts/2013-07-05-mqtt-over-websocket-transport-in-activemq/","section":"Posts","summary":"So, we have more and more users want to connect to ActiveMQ directly from the browser using WebSockets. For quite a while now we support Stomp clients which are really easy to use from JavaScript. Now, as more mobile users trying the same approach, we added support for very efficient binary MQTT protocol to the mix for upcoming 5.9.0 version.\nThe good thing is that you really don’t have to change anything on the broker side to support it. Both Stomp and MQTT can work over the same connector, as clients identify the protocol they want to use when they initialize the connection. We also provided a nice little demo using Eclipse Paho JavaScript client. You can play with the demo if you start the broker with activemq-demo.xml config like\n","title":"MQTT over WebSocket transport in ActiveMQ","type":"posts"},{"content":"Messaging once was a thing of \u0026ldquo;enterprises\u0026rdquo; but times are changing fast and devs now want to use it from virtually any environment. I thought it\u0026rsquo;s important to talk about messaging technologies available for web and mobile, so I\u0026rsquo;ll give a talk about it at CamelOne and OSCON. If you\u0026rsquo;re attending one of those give me a ping, so we can have a chat over some beers.\n","date":"May 14, 2013","externalUrl":null,"permalink":"/posts/2013-05-14-lightweight-messaging-for-web-and-mobile-with-apache-activemq/","section":"Posts","summary":"Messaging once was a thing of “enterprises” but times are changing fast and devs now want to use it from virtually any environment. I thought it’s important to talk about messaging technologies available for web and mobile, so I’ll give a talk about it at CamelOne and OSCON. If you’re attending one of those give me a ping, so we can have a chat over some beers.\n","title":"Lightweight Messaging For Web And Mobile With Apache ActiveMQ","type":"posts"},{"content":"","date":"May 14, 2013","externalUrl":null,"permalink":"/categories/talks/","section":"Categories","summary":"","title":"Talks","type":"categories"},{"content":"We managed to keep our goal of making more frequent releases and today we\u0026rsquo;re happy to announce Apache ActiveMQ 5.7.0. The main goal of this release was Java 7 compatibility. The project is built using JDK 6, but it\u0026rsquo;s tested to work properly with Java 7. This was needed as we now use Camel 2.10, which also added support for Java 7.\nBesides this, there\u0026rsquo;s a couple of new features and close to two hundred bug fixes in this release. Some of the prominent new features are:\nSecure WebSocket (wss) transport - which means that you can now securely connect to the broker directly from your browser. You can find more information about it here Broker Redelivery - which allows you to define redelivery policy such that broker will resend a message to a different consumer in case that processing fails. Here you can find more information on when you\u0026rsquo;d want to use this feature and how. We also improved our storage locking mechanism, so now it\u0026rsquo;s completely pluggable. This means that locking is not tied to the store itself, but it\u0026rsquo;s separately configured. And also you can tune it or implement new locking strategies to suit your environment. We also provided a new database locker, called Lease Database Locker, which should do much better job for JDBC master slave scenarios.\nSo, that\u0026rsquo;s about it. Give 5.7.0 a try and let us know what do you want to see in 5.8.0.\nAnd while I have your attention, there\u0026rsquo;re two upcoming sessions where you can learn more about ActiveMQ:\nI\u0026rsquo;ll be talking about ActiveMQ in the cloud at Red Hat Integration and BPM Week on October 15th and about Apollo and the future of ActiveMQ at ApacheCon EU on November 8th ","date":"October 8, 2012","externalUrl":null,"permalink":"/posts/2012-10-08-apache-activemq-5-7-0-released/","section":"Posts","summary":"We managed to keep our goal of making more frequent releases and today we’re happy to announce Apache ActiveMQ 5.7.0. The main goal of this release was Java 7 compatibility. The project is built using JDK 6, but it’s tested to work properly with Java 7. This was needed as we now use Camel 2.10, which also added support for Java 7.\nBesides this, there’s a couple of new features and close to two hundred bug fixes in this release. Some of the prominent new features are:\n","title":"Apache ActiveMQ 5.7.0 released","type":"posts"},{"content":"Shared storage master slave broker topologies depend on successful storage locking. Meaning that only a single broker (the master) is active and use the message database. So far locking was tied to a specific message store, so KahaDB was using shared file locking while JDBC store was using a specialized database table to keep slaves from starting. This work fine for the most use cases, but sometimes folks need to use a custom locker (like when the standard file locking doesn\u0026rsquo;t work on their NFS) or tune existing solutions.\nFor the upcoming 5.7.0 release we introduced pluggable storage lockers, which means that message storage locking is totally separated from the store itself. That means that you can now use any locking strategy with any store. An example configuration is shown below:\n\u0026lt;persistenceAdapter\u0026gt; \u0026lt;kahaDB directory = \u0026#34;target/activemq-data\u0026#34;\u0026gt; \u0026lt;locker\u0026gt; \u0026lt;shared-file-locker lockAcquireSleepInterval=\u0026#34;5000\u0026#34;/\u0026gt; \u0026lt;/locker\u0026gt; \u0026lt;/kahaDB\u0026gt; \u0026lt;/persistenceAdapter\u0026gt; You can find more details on this new feature here. It will also allow us to implement new locking strategies, based on ZooKeeper for example, which will make high-availability setups even easier. So stay tuned.\n","date":"September 13, 2012","externalUrl":null,"permalink":"/posts/2012-09-13-pluggable-activemq-storage-lockers/","section":"Posts","summary":"Shared storage master slave broker topologies depend on successful storage locking. Meaning that only a single broker (the master) is active and use the message database. So far locking was tied to a specific message store, so KahaDB was using shared file locking while JDBC store was using a specialized database table to keep slaves from starting. This work fine for the most use cases, but sometimes folks need to use a custom locker (like when the standard file locking doesn’t work on their NFS) or tune existing solutions.\n","title":"Pluggable ActiveMQ Storage Lockers","type":"posts"},{"content":"OK, after basic anti-patterns discussed in part 1 and 2 of this series, it\u0026rsquo;s time to discuss a bit more sophisticated messaging anti-patterns and how to write better messaging-oriented applications.\nUsing appropriate message type # So let\u0026rsquo;s start with the first principles of messaging. Why we want to use a message broker in our architecture? The most probable answer is to exchange data in asynchronous and lously-coupled way between our systems. In that terms we should see how our data are best represented in terms of messages. JMS specification defines a few types of message types to be used which I\u0026rsquo;d classify in two groups. In the first group I\u0026rsquo;ll put TextMessages and ByteMessages which provides a kind of a plain-sheet in terms of what kind of data is carried in the message body. I think that you should strongly consider using only these message types as they provide a framework for loosely-coupled data exchange without introducing unnecessary complexity. Let\u0026rsquo;s cover briefly other message types and discuss what they bring to the picture:\nObjectMessages # If you haven\u0026rsquo;t already, be sure to read a post Jeff Mesnil wrote on this subject. It sums up pretty well what\u0026rsquo;s wrong ObjectMessage type. In the nutshell:\nYou can get into a classloading mess as your systems need to share a classpath information as they need to be able to (de)serialize same objects. This increases coupling between the systems which we wanted to avoid in the first place.\nIt adds unnecessary performance penalties for serializing and transferring the whole objects, instead of only valuable data\nStreamMessages # In a similar fashion, StreamMessage adds some semantics over the basic ByteMessages. Instead of treating all bytes equally, you can now write and read strings, integers, objects, etc. This was very valuable in times when JMS API was designed, but today in the age of all these advanced serialization frameworks, both binary (Protobuf and co) and text-based ones (Jackson and co.), I think you\u0026rsquo;ll better forget about it. Encode your data with the some of the tools you\u0026rsquo;re probably already using in your applications and transfer them using ByteMessages or TextMessages.\nMapMessages # MapMessages are just one more example of a too specialized interface. It\u0026rsquo;s true that map (properties) collection format is commonly used, but it\u0026rsquo;s just one of many, so why depend and couple your application to it.\nAdditionally usage of ObjectMessages, StreamMessages and MapMessage ties your solution to the JMS land and prevents you to exchange messages with Stomp-based clients for example.\nAvoid fat-messages (Blobs) # While it\u0026rsquo;s certainly possible to move large messages through message brokers, you should think twice if you want to do that. And when I say large messages, I mean gigabytes and gigabytes of data in a single message. If you find yourself with the requirement like that, ask yourself do you really need a messaging service to move this data. Broker internals are optimized to move large amount of messages and adding big blobs in the combination can cause various side effects (connection controls kicking in, blocking other clients, exhausting resources, etc).\nThe usual pattern suggested for this use case is that you should use some traditional transport, like FTP, for moving large data; and use messaging service to notify clients when data is ready for download (and where to find it). ActiveMQ even provides and [API which will do this for you under the cover of JMS API] (http://activemq.apache.org/blob-messages.html)\nThat\u0026rsquo;s it for today, choose your message type and size wisely so you don\u0026rsquo;t end up with tightly coupled systems and brokers/clients struggling with oversized messages.\n","date":"September 5, 2012","externalUrl":null,"permalink":"/posts/2012-09-05-messaging-anti-patterns-part-3/","section":"Posts","summary":"OK, after basic anti-patterns discussed in part 1 and 2 of this series, it’s time to discuss a bit more sophisticated messaging anti-patterns and how to write better messaging-oriented applications.\nUsing appropriate message type # So let’s start with the first principles of messaging. Why we want to use a message broker in our architecture? The most probable answer is to exchange data in asynchronous and lously-coupled way between our systems. In that terms we should see how our data are best represented in terms of messages. JMS specification defines a few types of message types to be used which I’d classify in two groups. In the first group I’ll put TextMessages and ByteMessages which provides a kind of a plain-sheet in terms of what kind of data is carried in the message body. I think that you should strongly consider using only these message types as they provide a framework for loosely-coupled data exchange without introducing unnecessary complexity. Let’s cover briefly other message types and discuss what they bring to the picture:\n","title":"Messaging Anti-Patterns: Part 3","type":"posts"},{"content":"OK, now that you promised that you won\u0026rsquo;t store your messages in the broker (see part one of this post series), let\u0026rsquo;s consider one more thing that you should avoid when dealing with messaging systems.\nShort-lived connections # One thing that reoccur regularly is folks (knowingly or unknowingly) creating and tearing connections to the broker for every message they produce and consume.\nThis anti-pattern is especially common in two environments: Stomp and Spring. Stomp is very lightweight text-oriented messaging protocol. Which makes it really easy to write clients in almost any programming language available. This is one of the main strengths of Stomp and if you\u0026rsquo;re not JVM-exclusive shop I strongly recommend you to take a detailed look at it. But this impose a problem of course; large number of clients are poorly written and/or used inappropriately. For example, you can have a script which when ran will send or consume some messages from the broker. So if you don\u0026rsquo;t care much, you\u0026rsquo;ll open a new connection every time, send and consume messages and (hopefully) disconnect from the broker. Then you\u0026rsquo;ll put your script under load which will then transfer that load to the broker.\nSpring, on the other hand, uses nice abstractions for dealing with JMS brokers, but the problem is that it was designed to be ran in a container of some kind and it is expected that container will manage resources for it. So when you write your standalone Java application and don\u0026rsquo;t care about this you end up with messaging clients behaving badly. A new connection, session, producer, consumer objects will be created for every message exchange and that far from optimal.\nWhy is all this such a problem? Well, first of all opening and closing connections requires from broker to do some work and having large number of clients opening and closing connections to exchange a single message produces a huge overhead and steals resources broker could use to do some other useful work. This is not specific to messaging and broker. You don\u0026rsquo;t open and close a database connection for every query (hopefully) for the same reasons. And also a spike in load in this case can spike in number of sockets used (as they need some time shutdown on the system) and eventual system resources exhaustion.\nBesides this, messaging services are all about long lasting connections and clients. ActiveMQ implements various concepts, like producer flow control and consumer message prefetch, which are aimed to improve messaging experience and performance of the whole system. Not only that these messaging mechanisms are meaningless in a short-lived connections scenario, but can also introduce additional overhead in the system.\nFinally if you have network brokers, information on large number of message consumers coming and going will be propagated through the network. This can significantly increase a broker to broker traffic and even impact the stability of remote brokers.\nSo what\u0026rsquo;s to be done? In Spring it\u0026rsquo;s easy, just use some kind of a cached connection factory and you\u0026rsquo;ll be sorted. There\u0026rsquo;ll be no more a new connection, session, producer, consumer for every message exchanged. More resources on ActiveMQ Spring support can be found here so please give it read if you\u0026rsquo;re using JMS Spring clients in your applications.\nFor Stomp, there\u0026rsquo;s no silver bullet. But for starters be aware of what you\u0026rsquo;re doing and try to reuse your resources smartly. If you do it, messages will flow smoothly and you\u0026rsquo;ll have a stable system.\n","date":"August 17, 2012","externalUrl":null,"permalink":"/posts/2012-08-17-messaging-anti-patterns-part-2/","section":"Posts","summary":"OK, now that you promised that you won’t store your messages in the broker (see part one of this post series), let’s consider one more thing that you should avoid when dealing with messaging systems.\nShort-lived connections # One thing that reoccur regularly is folks (knowingly or unknowingly) creating and tearing connections to the broker for every message they produce and consume.\n","title":"Messaging Anti-Patterns: Part 2","type":"posts"},{"content":"If you have a hammer everything looks like a nail, right? So we all witnessed that people sometimes try to solve the problem with wrong technology. Heck we probably all did it at one point or another. Common reasons are familiarity with an exiting technology stack we have at hand or perception that some of the features will justify it all. But using any technology in a way it\u0026rsquo;s not designed for, will lead to all kind of problems and you\u0026rsquo;ll eventually be forced to do it properly (probably cursing at the project in question because it hasn\u0026rsquo;t met you wrong expectations).\nIn this and couple of follow-up posts I\u0026rsquo;ll try sum up some things we saw in mailing lists, Jiras, etc related to improper usage of messaging systems (ActiveMQ in particular). Hopefully, it will help people that consider using messaging in their architecture, see if it is the right tool for solving their particular problem.\nSo let\u0026rsquo;s kick off with one common mistake people make\nUsing message queue as a database # Messaging systems are built to asynchronously connect multiple systems, by passing messages between them. So everything is designed with that in mind; how to most efficiently pass messages from producers to consumers. This means that messages are expected to be reasonably short-lived, and not stored in a queue.\nFrom time to time we see people trying keep application state in the broker. Put some messages in a queue, than browse them, cherry-pick just some of them, delete others and similar stuff. While most of the messaging systems have some kind of support to do this it\u0026rsquo;s not what they\u0026rsquo;re designed to support primarily. Client APIs, internal storage system, client-server contracts, etc. are optimized for entirely different set of tasks.\nAn example could be a system that wants to keep a single most-recent data as a queue message (timestamped or versioned somehow). So that application can find that message (usually by browsing) and do the house keeping by deleting stale data. People are sometimes inclined to do this as brokers provide high-availability, reconnection logic, can be geographically distributed which is all fine and well. But brokers are a poor choice for maintaining application state.\nA workaround is not to keep any state in the broker, of course. Either use a centralized high-availability database or a local copy of data and use messaging system to propagate changes.\nSo if you find yourself wanting to store some messages in a queue and then later browse them, query them or maintain them, please don\u0026rsquo;t. Get yourself a database of some kind (relational or not) and manipulate data there. Queues (and topics) are for data that should be consumed as they come and moved from one system to another as fast as possible. They should live in the broker only as long as it takes to consume them or if something has gone wrong and they cannot be consumed. Which should be an exceptional situation rather than what we design for.\nIf there\u0026rsquo;s any messaging anti-patterns you observed (or designed yourself - c\u0026rsquo;mon don\u0026rsquo;t be ashamed), send them to me. I\u0026rsquo;ll gladly put them on my list and document them in coming days.\n","date":"July 31, 2012","externalUrl":null,"permalink":"/posts/2012-07-31-messaging-anti-patterns-part-1/","section":"Posts","summary":"If you have a hammer everything looks like a nail, right? So we all witnessed that people sometimes try to solve the problem with wrong technology. Heck we probably all did it at one point or another. Common reasons are familiarity with an exiting technology stack we have at hand or perception that some of the features will justify it all. But using any technology in a way it’s not designed for, will lead to all kind of problems and you’ll eventually be forced to do it properly (probably cursing at the project in question because it hasn’t met you wrong expectations).\n","title":"Messaging Anti-Patterns: Part 1","type":"posts"},{"content":"I had a blast of a week at CamelOne and JEEConf. Both organized perfectly and awesome crowd all around.\nCamelOne was packed with FuseSource customers and users with a great feedback on the things we do. There were a lot of interest in Fuse Fabric which should help folks provision their integration infrastructure with ease. I covered how Fabric can help with complex ActiveMQ deployments and you can find the slides embedded below.\nDeploying FuseMQ with Fuse Fabric\nView more PowerPoint from dejanb\nIf you have to deploy and manage more than one broker I strongly recommend you taking a look at Fabric and FuseESB Enterprise 7.0 which incorporates it.\nJEEConf was a more general Java conference; a quite larger than last year. Although most of the sessions were in Russian so I couldn\u0026rsquo;t actually follow, at least I had time to write this blog post :) I gave a talk on ActiveMQ Apollo subproject, which is packed with cool new stuff that should bring open source messaging to the next level. Take a look at the slides here\nIntroduction to ActiveMQ Apollo\nView more presentations from dejanb\nIt was well received and I\u0026rsquo;m looking forward to more feedback as people start playing with it more. All in all, it was a great week and it\u0026rsquo;s always a pleasure to present and get a feedback on the our projects. Can\u0026rsquo;t wait for Monday when the new cycle of development begins.\n","date":"May 19, 2012","externalUrl":null,"permalink":"/posts/2012-05-19-conference-week-wrap-up/","section":"Posts","summary":"I had a blast of a week at CamelOne and JEEConf. Both organized perfectly and awesome crowd all around.\nCamelOne was packed with FuseSource customers and users with a great feedback on the things we do. There were a lot of interest in Fuse Fabric which should help folks provision their integration infrastructure with ease. I covered how Fabric can help with complex ActiveMQ deployments and you can find the slides embedded below.\n","title":"Conference week wrap-up","type":"posts"},{"content":"We just released Apache ActiveMQ 5.6.0. It was a long-awaited maintenance release, but however there are a few very significant new features that was worth waiting for. Those include a new LevelDB store, MQTT and Stomp 1.1 protocols support and self-balancing cluster clients, to name a few. I already written about clustering here and there sure will be a lot of things to write about these other features as well in coming days.\nAlso, next week I\u0026rsquo;ll be at CamelOne in Boston and JEEConf In Kiev (a bit too much traveling for my taste, but there you go). I\u0026rsquo;ll talk about Enterprise deployment of ActiveMQ using Fuse Fabric (a topic already covered here in a nutshell) and Apache Apollo, the next generation of the broker. All these projects that are coming in the pipeline are pushing the possibilities of our integration infrastructure one step further. It will allow people to do complex deployments easier and connect to the infrastructure from virtually everywhere. It was a very exciting first half of the year, and it looks like things are going to be even more interesting going forward.\n","date":"May 8, 2012","externalUrl":null,"permalink":"/posts/2012-05-08-activemq-560-and-other-news/","section":"Posts","summary":"We just released Apache ActiveMQ 5.6.0. It was a long-awaited maintenance release, but however there are a few very significant new features that was worth waiting for. Those include a new LevelDB store, MQTT and Stomp 1.1 protocols support and self-balancing cluster clients, to name a few. I already written about clustering here and there sure will be a lot of things to write about these other features as well in coming days.\n","title":"ActiveMQ 5.6.0 and other news","type":"posts"},{"content":"FuseSource just announced a public beta of new Enterprise products (Read more about it in Rob\u0026rsquo;s post). So it\u0026rsquo;s time to give you a bit more details on what we were working on for the past few months. One thing I want to emphasize in this post is how this project improves the experience of deploying and managing ActiveMQ brokers. Fuse Fabric (the central engine behind Fuse Enterprise) can help you provision and manage your brokers better and additionally help with cloud deployments.\nProvisioning # While classic server software (ActiveMQ included) deployment scenarios, which include unpacking a distro, setting a config and starting/stopping software, works OK for small deployments, there are a lot of challenges people encounter when trying to set and manage a large number of instances. Here are some of them:\nEnormous amount of work needed to set everything - imagine a large cluster you need to set, ssh-ing, unpacking, copying and tweaking config files is very tedious and error-prone process Changing configuration during runtime - you need again to manually tweak every file and restart the server, which is all but fun Upgrading - can also be a challenge and time consuming Some of the things folks usually do to make their life easier is to:\nKeep XML config part of the spec as a template and in version control system and tweak as much things as possible with properties - this makes it easier to keep things under control and minimize the potential of an error when managing a configuration on large number of instances. Keep configuration separate from distribution to make it all easier to upgrade Use tools like Puppet or Chef to even further make things easier in these scenarios One of the things where Fabric excels is centralized configuration management. In Fabric it\u0026rsquo;s really easy to spin new container instances on your servers (using ssh) or to the public cloud. Additionally it\u0026rsquo;s really easy to deploy ActiveMQ broker to those containers, by simply applying appropriate profile to them. So generally, you can predefine a template for your broker, like XML configuration template and all necessary properties in a profile and then with a simple Karaf command (or even mouse click in our tools, like FuseIDE and Fuse Management Console) deploy as many instances as you like of that broker (no matter if it\u0026rsquo;s a physical box in your data center or a VM at the public could provider).\nDiscovery # Fabric uses Apache ZooKeeper as it\u0026rsquo;s central registry of container instances running. This same registry is used to keep track of all brokers running inside a Fabric instance. This means that we can use this registry to discover all brokers inside a certain group. Therefore we created a new discovery protocol (called fabric of course) that can do that. So clients can connect to the broker group (think of it as a cluster) without any need to know exact location of the brokers. So now you can see how Fabric helps deploying your brokers to the cloud. First, you can use its ability to start containers (and deploy brokers on them) on any server or cloud provider available. And than clients can use Fabric to discover brokers and connect to them, all location agnostic.\nTopologies # ZooKeeper as a central registry allows us to do some more nice things in domain of broker topologies. For example, currently the master-slave topology of ActiveMQ brokers depends on shared storage (either shared file system or enterprise JDBC database). In this scenario the master election and slave locking depends on the locking ability of the shared storage, limiting it to certain type of hardware. With ZooKeeper as a distributed registry, battle-proven for this kind of use cases, it\u0026rsquo;s easy to create a master-slave topologies with master election done on ZooKeeper locks. If you want to have a persistent master-slave, you still gonna need to store your messages in a some kind of a shared storage, but locking is not store\u0026rsquo;s job any more. And on the other hand it\u0026rsquo;s really easy to create non-persistent cluster of brokers with shared-nothing philosophy. Creating a master-slave is as simple as creating a multiple brokers with the same name in the group. The first one started will become a master, while others will be slaves waiting for the master to fail.\nAnother example of enhanced topology possibilities with ActiveMQ and Fabric is new ways you can set networks of brokers. Just as clients can use ZooKeeper registry to discover brokers, network connectors can use the same discovery protocol to connect the broker with all other brokers in the certain group. Again, brokers are mutually totally location agnostic, which is something desired in deployment scenarios with modern infrastructure. Could it be done any easier? Finally, you might want to mix these two topologies and create connected networks of master/slave broker, which with Fabric, is just easy to do as those basic topologies.\nUpgrades and Patching # And now you say you need to upgrade all of the dozen brokers you have? No problem, with Fabric you can centrally update any bundle you\u0026rsquo;re using in your profile and that change will be propagated to all brokers. Now it\u0026rsquo;s time to talk about risk management of upgrades and this is where profile versions come into play. Instead of messing with profiles that are used in production at the moment, you can create a new version of it with updated versions of all bundles you plan to use. Once you have that profile ready, you can test it out on one or a few instances. And only after you\u0026rsquo;re certain that everything is OK, you can apply a new profile to all brokers. Of course, it\u0026rsquo;s easy to rollback to the previous version if anything goes wrong.\nFabric also provides you with the mechanism to provide a simple incremental patch jar with only certain classes modified (a single bug-fix). These classes will be then used instead of old ones and will allow us to provide a fix for a critical bug without need to upgrade the project version. This can be useful for dealing with critical production bugs, where waiting for the next release is not an option.\nMore resources # This post was just meant to give you a glance view of what\u0026rsquo;s coming from FuseSource regarding easier deployment, provisioning and managing of your messaging (and generally integration) infrastructure. You can check some more docs on the projects. Especially, there\u0026rsquo;s some more info that explains ActiveMQ concepts explained here in more details and shows how to run examples. You will definitely hear more from us on this topic in coming days, so stay tuned.\n","date":"April 10, 2012","externalUrl":null,"permalink":"/posts/2012-04-10-activemq-in-cloud/","section":"Posts","summary":"FuseSource just announced a public beta of new Enterprise products (Read more about it in Rob’s post). So it’s time to give you a bit more details on what we were working on for the past few months. One thing I want to emphasize in this post is how this project improves the experience of deploying and managing ActiveMQ brokers. Fuse Fabric (the central engine behind Fuse Enterprise) can help you provision and manage your brokers better and additionally help with cloud deployments.\n","title":"ActiveMQ in the cloud","type":"posts"},{"content":"For the last two weeks I\u0026rsquo;ve been working on some interesting use cases for the good ol\u0026rsquo; failover transport. I finally have some time at my hands, so here\u0026rsquo;s a brief recap of what\u0026rsquo;s coming in 5.6 release in this area.\nFirst there\u0026rsquo;s a new feature, called Priority Backup. It\u0026rsquo;s described in details here, but in a nutshell it provides you with the mechanism of prioritizing your failover urls and keep your clients connected to them as soon as they are available. The most obvious use case for this is to keep your clients connected to the broker in local data center whenever you can. By doing this, you can both have better performances and stability of your clients, but also save on your bandwidth bills.\nAnother improvement is coming for automatic broker cluster feature. Although this feature is not new, I spent some time hardening it and thought to share some more insight in how (and when) to use it in your projects.\nIn search of high availability, people often default to master-slave architecture. This makes sense in most use cases, but if your flow is purely non-persistent you can probably come up with more optimal architecture. Instead of having one broker at the time handling all your load, and other one just waiting for it to fail, you\u0026rsquo;ll get more efficient system with some kind of active-active configuration where (possibly multiple) brokers share the load all the time. Ideally clients would be evenly distributed and would rebalance if anything changes. Brokers don\u0026rsquo;t need to share any messages as clients are distributed and messages are non-persistent so they will be lost if broker fails. So can you achieve this kind of architecture with ActiveMQ?\nSure you do. That\u0026rsquo;s where automatic rebalance and clustering shines. First of all, brokers should be networked but only so they can exchange information on their availability. They shouldn\u0026rsquo;t exchange the messages (but of course can if your use case needs it). In 5.6 you do that with pure static networks, using configuration like\n\u0026lt;networkConnector uri=\u0026#34;static:(tcp://host)\u0026#34; staticBridge=\u0026#34;true\u0026#34;/\u0026gt; So now imagine three brokers A,B and C forming a full mesh. In addition every broker uses rebalance options on their transport connectors\n\u0026lt;transportConnector name=\u0026#34;openwire\u0026#34; uri=\u0026#34;tcp://localhost:61616\u0026#34; updateClusterClients=\u0026#34;true\u0026#34; updateClusterClientsOnRemove=\u0026#34;true\u0026#34; rebalanceClusterClients=\u0026#34;true\u0026#34; /\u0026gt; All that is left for the client to do is connect to one of the brokers it knows like\nfailover:(brokerA) and the broker will fill it with all information on other brokers in the cluster and whether it should reconnect to one of them or not. So having a large number of clients connecting like this, very soon they\u0026rsquo;ll rebalance over available brokers. You can stop one of the brokers in the cluster for updates and clients will rebalance over remaining ones. You can even add a new broker to the cluster and everything will get rebalanced without any need for you to touch your clients.\nSo, basically in this way you have both load balancing and high availability for your non-persistent messages. Additionally, your clients are automatically updated with all information they need, and no manual intervention is needed.\nAlthough the basic support for clustering was there since 5.4, I did some more hardening and better rebalancing, so it\u0026rsquo;s coming in the Apache ActiveMQ 5.6 (and the next Fuse 5.5.1) release. Also, there are some more great stuff regarding broker clustering coming soon, so stay tuned and happy messaging.\n","date":"February 14, 2012","externalUrl":null,"permalink":"/posts/2012-02-14-new-activemq-failover-and-clustering-goodies/","section":"Posts","summary":"For the last two weeks I’ve been working on some interesting use cases for the good ol’ failover transport. I finally have some time at my hands, so here’s a brief recap of what’s coming in 5.6 release in this area.\nFirst there’s a new feature, called Priority Backup. It’s described in details here, but in a nutshell it provides you with the mechanism of prioritizing your failover urls and keep your clients connected to them as soon as they are available. The most obvious use case for this is to keep your clients connected to the broker in local data center whenever you can. By doing this, you can both have better performances and stability of your clients, but also save on your bandwidth bills.\n","title":"New ActiveMQ failover and clustering goodies","type":"posts"},{"content":"Recently Jakub wrote an excellent blog post explaining more on how ActiveMQ networks work. The one thing that somehow always got unexplained and confused users over time is the connection between network of brokers and advisory messages. I finally took some time to document it and introduce some enhancements we have in this area for the upcoming 5.6 broker release. Read more here on how network connectors use advisory messages and how you can tune all that in complex and high load environments.\n","date":"December 21, 2011","externalUrl":null,"permalink":"/posts/2011-12-21-activemq-networks-and-advisory-messages-explained/","section":"Posts","summary":"Recently Jakub wrote an excellent blog post explaining more on how ActiveMQ networks work. The one thing that somehow always got unexplained and confused users over time is the connection between network of brokers and advisory messages. I finally took some time to document it and introduce some enhancements we have in this area for the upcoming 5.6 broker release. Read more here on how network connectors use advisory messages and how you can tune all that in complex and high load environments.\n","title":"ActiveMQ networks and advisory messages explained","type":"posts"},{"content":"Slides are available at slideshare now:\nAdvanced messaging with Apache ActiveMQ\nView more presentations from dejanb\n","date":"May 23, 2011","externalUrl":null,"permalink":"/posts/2011-05-23-advanced-messaging-with-apache-activemq-slides/","section":"Posts","summary":"Slides are available at slideshare now:\nAdvanced messaging with Apache ActiveMQ\nView more presentations from dejanb\n","title":"Advanced messaging with Apache ActiveMQ slides","type":"posts"},{"content":"I\u0026rsquo;ll be speaking on \u0026ldquo;Advanced Messaging with ActiveMQ\u0026rdquo; at JEEConf in Kiev, Ukraine on Saturday May 21st.\n","date":"May 11, 2011","externalUrl":null,"permalink":"/posts/2011-05-11-jeeconf-session/","section":"Posts","summary":"I’ll be speaking on “Advanced Messaging with ActiveMQ” at JEEConf in Kiev, Ukraine on Saturday May 21st.\n","title":"JEEConf Session","type":"posts"},{"content":" ","date":"March 28, 2011","externalUrl":null,"permalink":"/posts/2011-03-28-just-arrived/","section":"Posts","summary":" ","title":"Just arrived!","type":"posts"},{"content":" Book projects always (at least for me) takes quite longer to finish than you anticipate at the beginning. But unlike everything we do in software development, when it is finally finished, you get the real physical thing you can hold in your hands. And that\u0026rsquo;s always a great feeling.\nI\u0026rsquo;m happy to announce that ActiveMQ in Action is released. You can already get final eBook, while the print version will hit the shelfs on March 24th.\nThanks everyone for support and enjoy reading. I can\u0026rsquo;t wait to get my hands on the printed version.\n","date":"March 21, 2011","externalUrl":null,"permalink":"/posts/2011-03-21-activemq-in-action-released/","section":"Posts","summary":" Book projects always (at least for me) takes quite longer to finish than you anticipate at the beginning. But unlike everything we do in software development, when it is finally finished, you get the real physical thing you can hold in your hands. And that’s always a great feeling.\nI’m happy to announce that ActiveMQ in Action is released. You can already get final eBook, while the print version will hit the shelfs on March 24th.\n","title":"ActiveMQ in Action released","type":"posts"},{"content":"The PCI DSS (Payment Card Industry (PCI) Data Security Standard) v2.0, specifies that all user actions must be audited, so they can be inspected later if needed. To be deployable in such environments, we added audit logging to ActiveMQ. In this article you can find the basics on how to configure and use it. Here, I\u0026rsquo;d like to expand the topic a bit and talk about add-ons you can find in Fuse Message Broker.\nFor starters, let\u0026rsquo;s quickly recap how it works. When enabled, by setting\n-Dorg.apache.activemq.audit=true system variable, all user (or to say management) actions will be logged. This basically means, that we will log all JMX commands and operations invoked using web console.\nThe implementation of audit logging in ActiveMQ is pluggable. A default one will just use the standard application log mechanism to store these logs (in ${ACTIVEMQ_BASE}/data/audit.log file by default). You can easily provide your own by log by implementing [AuditLog](http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/util/AuditLog.java?view=markup) interface and let the Java Service Loader to find it.\nFor the FuseSource flavor of ActiveMQ, we prepared some more goodness in this area. So if you deploy your broker in OSGi environment, like Apache Karaf, it will use OSGi platform infrastructure for audit logging. For starters, we will use OSGi service mechanism to lookup for the available audit loggers. Also, we provide a default implementation that uses OSGi event admin mechanism to sends audit logs as events to the org/fusesource/audit topic. A default topic handler is also provided, which simply logs the events in the log file. But with this solution, you can easily provide your topic handler that can process and store audit logs in any way that suits your environment.\nIn the future you can expect similar solution for the whole range of the FuseSource projects and unified way to handle the logs for the whole platform.\n","date":"January 20, 2011","externalUrl":null,"permalink":"/posts/2011-01-20-activemq-55-audit-logging/","section":"Posts","summary":"The PCI DSS (Payment Card Industry (PCI) Data Security Standard) v2.0, specifies that all user actions must be audited, so they can be inspected later if needed. To be deployable in such environments, we added audit logging to ActiveMQ. In this article you can find the basics on how to configure and use it. Here, I’d like to expand the topic a bit and talk about add-ons you can find in Fuse Message Broker.\n","title":"ActiveMQ 5.5: Audit Logging","type":"posts"},{"content":"Update: Slides are available at http://www.slideshare.net/fusesource/introduction-to-apache-camel\nI\u0026rsquo;ll be introducing Apache Camel at next Software Scalability | Belgrade – meetup on January 29th. The full announcement can be found here\n","date":"January 14, 2011","externalUrl":null,"permalink":"/posts/2011-01-14-software-scalability-belgrade-meetup-04/","section":"Posts","summary":"Update: Slides are available at http://www.slideshare.net/fusesource/introduction-to-apache-camel\nI’ll be introducing Apache Camel at next Software Scalability | Belgrade – meetup on January 29th. The full announcement can be found here\n","title":"Software scalability \u0026#124; Belgrade meetup 04","type":"posts"},{"content":"If you\u0026rsquo;re running ActiveMQ in a distributed setup using network of brokers, you\u0026rsquo;re probably interested in techniques available to monitor your network. This usually implies viewing the status of the network bridges and generating events when the status changes. There were some improvements in this area for the next 5.5 release and here I\u0026rsquo;ll try to explain this topic a bit more.\nTo demonstrate these techniques we need a simple network, so take a look at the one shown in the following diagram.\nWe see that broker 1 have two network bridges:\nOne created by duplex connection, originating from broker 2 and one direct to the broker 3 Now let\u0026rsquo;s see for starters what JConsole will show us.\nAs you can see, both bridges are shown in JConsole under the Network Bridge tab. You can spot bridges created by remote duplex connectors, by having a connector name pattern like duplex#x and also CreatedByDuplex attribute set to true.\nThe similar information you can get now in Web Console. There\u0026rsquo;s a new tab, called Network, which will give you the following view.\nYou can notice that again, you can easily separate bridges created by connectors on this broker and those created by remote duplex connector.\nTools are nice for most usages, but what if you want to monitor your network bridges programatically? Well the first thing you can do is to use JMX API to query bridges. The following application, connects to the broker and lists all of its network bridges.\npublic class Bridges { public static void main(String[] args) throws Exception { JMXServiceURL url = new JMXServiceURL( \u0026#34;service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi\u0026#34;); JMXConnector connector = JMXConnectorFactory.connect(url, null); connector.connect(); MBeanServerConnection connection = connector.getMBeanServerConnection(); ObjectName name = new ObjectName( \u0026#34;org.apache.activemq:BrokerName=static-broker1,Type=NetworkBridge,*\u0026#34;); Set bridges = connection.queryNames(name, null); for (ObjectName bridgeName : bridges) { NetworkBridgeViewMBean view = (NetworkBridgeViewMBean) MBeanServerInvocationHandler.newProxyInstance( connection, bridgeName, NetworkBridgeViewMBean.class, true); System.out.println(\u0026#34;Bridge to \u0026#34; + view.getRemoteBrokerName() + \u0026#34; (\u0026#34; + view.getRemoteAddress() + \u0026#34;) \u0026#34; + ((view.isCreatedByDuplex() ? \u0026#34;- created by duplex\u0026#34; : \u0026#34;\u0026#34;))); } } } So if you run it against broker 1, you\u0026rsquo;ll get something like\nBridge to static-broker3 (localhost/127.0.0.1:61617) Bridge to static-broker2 (/127.0.0.1:52776) - created by duplex You can see both bridges, and an indication that bridge to broker 2 is created by remote duplex.\nJMX API will give you just the static snapshot of the available bridges. If you\u0026rsquo;re interested in notifications when bridges are being stopped or started, you can use advisory messages. The following example shows how to subscribe to the appropriate advisory topic and get events of the interest.\npublic class BridgeAdvisories implements MessageListener { public static void main(String[] args) throws Exception { ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(\u0026#34;tcp://localhost:61616\u0026#34;); Connection conn = factory.createConnection(); Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer consumer = sess.createConsumer(AdvisorySupport.getNetworkBridgeAdvisoryTopic()); consumer.setMessageListener(new BridgeAdvisories()); conn.start(); } @Override public void onMessage(Message message) { try { BrokerInfo brokerInfo = (BrokerInfo) ((ActiveMQMessage) message).getDataStructure(); boolean started = message.getBooleanProperty(\u0026#34;started\u0026#34;); if (started) { boolean createdByDuplex = message.getBooleanProperty(\u0026#34;createdByDuplex\u0026#34;); System.out.println(\u0026#34;Network bridge to \u0026#34; + brokerInfo.getBrokerName() + \u0026#34; (\u0026#34; + brokerInfo.getBrokerURL() + \u0026#34;) has been started \u0026#34; + (createdByDuplex ? \u0026#34;by duplex\u0026#34; : \u0026#34;\u0026#34;)); } else { System.out.println(\u0026#34;Network bridge to \u0026#34; + brokerInfo.getBrokerName() + \u0026#34; (\u0026#34; + brokerInfo.getBrokerURL() + \u0026#34;) has been stopped\u0026#34;); } } catch (JMSException e) { e.printStackTrace(); } } } If you run this against our broker 1 and start and stop brokers 2 and 3, you can expect the output similar to the following.\nNetwork bridge to static-broker3 (tcp://dejan-bosanacs-macbook-pro.local:61617) has been stopped Network bridge to static-broker3 (tcp://dejan-bosanacs-macbook-pro.local:61617) has been started Network bridge to static-broker2 (tcp://dejan-bosanacs-macbook-pro.local:61618) has been stopped Network bridge to static-broker2 (tcp://dejan-bosanacs-macbook-pro.local:61618) has been started by duplex So with this we covered techniques that you can use to monitor networks of ActiveMQ broker, which I hope you\u0026rsquo;ll find useful. If you\u0026rsquo;re interested in learning more about ActiveMQ (and related technologies), you can attend one of the online trainings organized by FuseSource\n","date":"January 5, 2011","externalUrl":null,"permalink":"/posts/2011-01-05-how-to-monitor-activemq-networks/","section":"Posts","summary":"If you’re running ActiveMQ in a distributed setup using network of brokers, you’re probably interested in techniques available to monitor your network. This usually implies viewing the status of the network bridges and generating events when the status changes. There were some improvements in this area for the next 5.5 release and here I’ll try to explain this topic a bit more.\nTo demonstrate these techniques we need a simple network, so take a look at the one shown in the following diagram.\n","title":"How to monitor ActiveMQ networks","type":"posts"},{"content":" It\u0026rsquo;s always a good feeling when the book project goes into the production, and that\u0026rsquo;s what happened to ActiveMQ in Action this week.\nIf you already bought MEAP access plus printed version of the book, you can expect your printed version in the next few months. If not, it\u0026rsquo;s still not too late as we\u0026rsquo;re offering 40% discount to celebrate going into the production. Just use activemq40 coupon code at the time of checkout.\nEnjoy reading!\n","date":"October 28, 2010","externalUrl":null,"permalink":"/posts/2010-10-28-activemq-in-action-in-production/","section":"Posts","summary":" It’s always a good feeling when the book project goes into the production, and that’s what happened to ActiveMQ in Action this week.\nIf you already bought MEAP access plus printed version of the book, you can expect your printed version in the next few months. If not, it’s still not too late as we’re offering 40% discount to celebrate going into the production. Just use activemq40 coupon code at the time of checkout.\n","title":"ActiveMQ in Action in Production","type":"posts"},{"content":"While configuring ActiveMQ for a production use, you usually need to store passwords in your configuration files. Passwords are usually needed for:\nSimple authentication plugin JDBC/LDAP passwords Accessing secured brokers by Web Console, Camel, etc Naturally, people don\u0026rsquo;t want to keep plain passwords in the configuration files. ActiveMQ 5.4.1 comes with a solution for that. Thanks to the integration with Jasypt library, your passwords can be now stored encrypted.\nFor a full description of this new feature see http://activemq.apache.org/encrypted-passwords.html.\nHere, I\u0026rsquo;ll briefly describe how to use it and what implications does it have for your deployment. First of all, for your convenience we provided new commands that you can use to encrypt/decrypt passwords from the command line.\nEncrypted passwords should replace plain ones in the properties files and with just a little XML config (replacing standard property configurer with one provided by Jasypt) you should be ready to go.\nBut there\u0026rsquo;s one tricky part to all this. You need to provide secret to the encryptor somehow. The most secure way to do this is by using the environment variable. You should set the it before you start the broker and unset it just after.\nOf course, there are other methods you can use to achieve this. But the only one currently provided by Jasypt assumes that you need to put that password in your xml configuration file. It\u0026rsquo;s needless to say that compromising the security of this password affects all other encrypted passwords. There\u0026rsquo;s always a room for improvement, so probably we can make it easier for you to enter this password while starting the broker in the future.\nIf you want (need) extra security, there\u0026rsquo;s usually a price to be payed in complexity of your deployment procedures. Setting/unsetting environment variables every time you start the broker (for now) is a small one if you want your passwords to be safe.\nBy the way don\u0026rsquo;t forget to attend Apache Camel webinars organized by FuseSource in September.\n","date":"September 3, 2010","externalUrl":null,"permalink":"/posts/2010-09-03-activemq-541-encrypted-passwords/","section":"Posts","summary":"While configuring ActiveMQ for a production use, you usually need to store passwords in your configuration files. Passwords are usually needed for:\nSimple authentication plugin JDBC/LDAP passwords Accessing secured brokers by Web Console, Camel, etc Naturally, people don’t want to keep plain passwords in the configuration files. ActiveMQ 5.4.1 comes with a solution for that. Thanks to the integration with Jasypt library, your passwords can be now stored encrypted.\nFor a full description of this new feature see http://activemq.apache.org/encrypted-passwords.html.\n","title":"ActiveMQ 5.4.1: Encrypted passwords","type":"posts"},{"content":"Apache ActiveMQ 5.4.0 is out. Beside our usual dedication to making it bullet-proof by adding a lot of test cases and resolving issues reported by our vibrant community, this release contains a lot of new features (some of which has already been covered here). In this post I\u0026rsquo;ll try to sum up the new features that we included in this release. As the development pace was very rapid, some of them haven\u0026rsquo;t been documented yet, but that\u0026rsquo;ll change soon too. So let\u0026rsquo;s start:\nMessage Priority - Queues and Durable Topic subscribers can dispatch messages based on the message priority. For durable messages you can use priorities with KahaDB and JDBC persistence. Scheduled Delivery of Messages (http://activemq.apache.org/delay-and-schedule-message-delivery.html) - Now you can delay or schedule delivery of messages from your destinations and thus create distributed scheduler. HTML 5 Web Sockets (http://activemq.apache.org/websockets.html) - Want to send/receive messages from your browser using web sockets? No problem, just setup the websocket transport, take client library and use Stomp directly from JavaScript. Better OSGi support (http://activemq.apache.org/osgi-integration.html) - configure and use ActiveMQ broker and web console easily in OSGi environment, such as Apache Karaf. Better Unix support (http://activemq.apache.org/unix-shell-script.html) - new shell scripts that will enable you to easier control your brokers from the command line Easy way to configure Web Console (http://activemq.apache.org/web-console.html#WebConsole-SecuringWebConsole) - now you can easily secure web console, by changing only one line in the configuration file Selectors for Ajax and REST consumers (http://activemq.apache.org/rest.html#REST-Consumingwithselectors) - want to use selectors to consume from destinations using REST. This is now achievable with ActiveMQ 5.4.0. New security options: JaasDualAuthentcationPlugin - that helps you use certificate authentication for SSL connections and username/password ones for plain TCP ones. Anonymous users (http://activemq.apache.org/security.html#Security-Anonymousaccess) - allow access to anonymous users to the secured broker Ajax Adapters - use Ajax API with popular client libraries, such as JQuery, Dojo or Prototype These are definitely interesting times for open source messaging and be sure to expect a lot more from ActiveMQ team (such as new Apollo architecture). Also, don\u0026rsquo;t miss Rob Davies talking on Deploying ActiveMQ in the Enterprise on August 19th.\n","date":"August 17, 2010","externalUrl":null,"permalink":"/posts/2010-08-17-whats-new-in-apache-activemq-540/","section":"Posts","summary":"Apache ActiveMQ 5.4.0 is out. Beside our usual dedication to making it bullet-proof by adding a lot of test cases and resolving issues reported by our vibrant community, this release contains a lot of new features (some of which has already been covered here). In this post I’ll try to sum up the new features that we included in this release. As the development pace was very rapid, some of them haven’t been documented yet, but that’ll change soon too. So let’s start:\n","title":"What's new in Apache ActiveMQ 5.4.0","type":"posts"},{"content":"When you\u0026rsquo;re sending messages to a cluster of ActiveMQ brokers using failover protocol and the current broker dies, the transport will try to connect and send messages to the next one. If that one is unavailable it will try next and so on and so on. So what happens when all brokers in the cluster are down? You\u0026rsquo;ll get the feeling that send call is hanging. At least until one of the brokers gets up again.\nFor some applications this is a desired behavior, but others don\u0026rsquo;t want (or can\u0026rsquo;t afford) to hang on sending messages under any circumstances. The easy solution for this is to use the timeout option on a failover transport. Take a look at the following queue producer.\npublic class QueueProducer { public static void main(String[] args) throws Exception { ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(\u0026#34;failover:(tcp://localhost:61616)?timeout=1000\u0026#34;); Connection connection = factory.createConnection(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); connection.start(); Queue queue = session.createQueue(\u0026#34;TEST\u0026#34;); MessageProducer producer = session.createProducer(queue); // send messages for (int i = 0; i \u0026lt; 1000; i++) { producer.send(session.createTextMessage(i + \u0026#34; message\u0026#34;)); System.out.println(\u0026#34;Sent message \u0026#34; + i); Thread.sleep(1000); } producer.close(); session.close(); connection.close(); } } What we have here is a producer that tries to send 1000 messages to the broker listening at port 61616. If that broker is down, it will wait one second (timeout=1000) before it fails. So when the broker is down, you can expect something like this:\n2010-08-16 15:52:12,336 [main ] INFO FailoverTransport - Failover timed out after 1008ms Exception in thread \u0026#34;main\u0026#34; javax.jms.JMSException: Failover timeout of 1000 ms reached. at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:62) at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1298) at org.apache.activemq.ActiveMQConnection.ensureConnectionInfoSent(ActiveMQConnection.java:1382) at org.apache.activemq.ActiveMQConnection.createSession(ActiveMQConnection.java:309) at icap.QueueProducer.main(QueueProducer.java:15) Caused by: java.io.IOException: Failover timeout of 1000 ms reached. at org.apache.activemq.transport.failover.FailoverTransport.oneway(FailoverTransport.java:529) at org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:40) at org.apache.activemq.transport.ResponseCorrelator.asyncRequest(ResponseCorrelator.java:81) at org.apache.activemq.transport.ResponseCorrelator.request(ResponseCorrelator.java:86) at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1276) ... 3 more So how does it work under the hood? The failover transport will try to reconnect to the broker (with interval of 100 ms between retries) and if don\u0026rsquo;t succeed in a specify amount of time it will throw an exception. What implication does this introduce? The obvious one is that you cannot specify \u0026ldquo;small\u0026rdquo; timeout periods (less than 100 ms) as you\u0026rsquo;ll lose your failover functionality. Again, for most applications this is more than enough, but even for those that require \u0026ldquo;fast producer failure\u0026rdquo; there is a solution. Actually two of them.\nSolution number one is to use TransportListener to be notified on your connection status. So when you know you have a valid connection, you send your messages in a regular manner. And execute your backup logic in case all brokers are down. Consider the following:\npublic class FastFailProducer implements TransportListener { boolean volatile connected = false; public void run() throws Exception { ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(\u0026#34;failover:(tcp://localhost:61616)?timeout=1000\u0026#34;); factory.setTransportListener(this); Connection connection = factory.createConnection(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); connection.start(); Queue queue = session.createQueue(\u0026#34;TEST\u0026#34;); MessageProducer producer = session.createProducer(queue); // send messages for (int i = 0; i \u0026lt; 1000; i++) { if (connected) { // send a message producer.send(session.createTextMessage(i + \u0026#34; message\u0026#34;)); System.out.println(\u0026#34;Sent message \u0026#34; + i); } else { // execute your backup logic System.out.println(\u0026#34;Message \u0026#34; + i + \u0026#34; not sent\u0026#34;); } Thread.sleep(1000); } producer.close(); session.close(); connection.close(); } public static void main(String[] args) throws Exception { FastFailProducer producer = new FastFailProducer(); producer.run(); } public void transportResumed() { connected = true; } public void transportInterupted() { connected = false; } public void onException(IOException error) { connected = false; } public void onCommand(Object command) {} } Here we modified a previous example, so that now we implement the transport listener. When the link goes up, transportResumed() gets called. When the link goes down, transportInterupted() gets called. When there\u0026rsquo;s an unrecoverable transport exception (like timeout, or maximum number of retries are reached) onException() gets called.\nSo now we can have a state of our connection and decide whether we want to send a message or just fail back even before we try. Executing the example against the broker that goes up and down, you can expect the following result\n2010-08-16 17:09:23,799 [ActiveMQ Task ] INFO FailoverTransport - Successfully connected to tcp://localhost:61616 Sent message 0 Sent message 1 Sent message 2 Sent message 3 2010-08-16 17:09:27,843 [127.0.0.1:61616] WARN FailoverTransport - Transport (localhost/127.0.0.1:61616) failed to tcp://localhost:61616 , attempting to automatically reconnect due to: java.io.EOFException Message 4 not sent Message 5 not sent Message 6 not sent Message 7 not sent Message 8 not sent Message 9 not sent 2010-08-16 17:09:33,164 [ActiveMQ Task ] INFO FailoverTransport - Successfully reconnected to tcp://localhost:61616 Sent message 10 Sent message 11 Sent message 12 Sent message 13 Now this is all fine and well, but in most cases when your connection is down you simply want to queue messages somewhere else until remote broker comes up. Why don\u0026rsquo;t you just use embedded broker for that? So with this second approach, you actually always send messages to the broker embedded in your producer application. That broker is then connected to the remote broker using the failover protocol. In this way your producers can work without caring about the state of the connection. So let\u0026rsquo;s change the original example to make it work with the embedded broker:\npublic class EmbeddedProducer { public static void main(String[] args) throws Exception { ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(\u0026#34;vm:(broker:(network:static:tcp://localhost:61616)?persistent=false\u0026amp;useJmx=false)\u0026#34;); Connection connection = factory.createConnection(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); connection.start(); Queue queue = session.createQueue(\u0026#34;TEST\u0026#34;); MessageProducer producer = session.createProducer(queue); // send messages for (int i = 0; i \u0026lt; 1000; i++) { producer.send(session.createTextMessage(i + \u0026#34; message\u0026#34;)); System.out.println(\u0026#34;Sent message \u0026#34; + i); Thread.sleep(1000); } producer.close(); session.close(); connection.close(); } } Basically we only changed the connection url. So now we send messages to the in-memory only embedded broker, connected to the remote broker. Of course, this is just an example, you can configure you embedded broker anyway you like. One thing that is important is that with the configuration like we have in this example, we must have a consumer on a remote broker in order to have messages forwarded there. This is configurable and you can have all your messages forwarded to the remote broker using staticallyIncludedDestinations.\nTo run a consumer, we can use ActiveMQ consumer tool and run something like\n/activemq/example$ ant -Dsubject=TEST -Durl=\u0026#34;failover:(tcp://localhost:61616)\u0026#34; consumer Now you can run the producer, stop and start the broker and see that messages are flowing through the system and that producers are not affected by the state of the remote broker.\nSo there you go, I hope I managed to explain how failover protocol affects producers and how you can find an ideal setup for your application. By the way, if you\u0026rsquo;re in Boston area be sure you pop by to FUSE meetup on August 17th. heather like viagra; Cheap Generic Viagra viagra and pulmonary fibrosis viagra enhancement Cheapest Viagra Prices health net hmo ca viagra viagra test; Lowest Price Viagra discount viagra sale \u0026ldquo;viagra sale prices\u0026rdquo; Viagra No Prescription viagra moa viagra dosages Viagra Soft Tabs viagra ibuprofen viagra and sexual misfunction Buying Viagra find search viagra free? availability of viagra in new zealand Viagra Alternative viagra patent expires holdere a href womens viagra a Viagra Prescription online viagra pharmacy effects viagra 200mg Viagra Professional viagra smaple\n","date":"August 16, 2010","externalUrl":null,"permalink":"/posts/2010-08-16-fast-producer-failover-with-activemq/","section":"Posts","summary":"When you’re sending messages to a cluster of ActiveMQ brokers using failover protocol and the current broker dies, the transport will try to connect and send messages to the next one. If that one is unavailable it will try next and so on and so on. So what happens when all brokers in the cluster are down? You’ll get the feeling that send call is hanging. At least until one of the brokers gets up again.\n","title":"Fast producer failover with ActiveMQ","type":"posts"},{"content":"For upcoming ActiveMQ 5.4.0 release we did a lot of work to make it a better citizen in OSGi land. Let\u0026rsquo;s walk through some of the stuff you can do now. First of all download and install recently released Apache Karaf 2.0.0.\nNow if you want to play with all these stuff before the ActiveMQ 5.4.0 is officially released, you need to edit\n${KARAF_HOME}/etc/org.ops4j.pax.url.mvn.cfg and add\nhttps://repository.apache.org/content/repositories/snapshots/ to the list of available repositories.\nOnce in the Felix runtime, you can now install all these new \u0026ldquo;features\u0026rdquo; by doing something like\nkaraf@root\u0026gt; features:addUrl mvn:org.apache.activemq/activemq-karaf/5.4-SNAPSHOT/xml/features Of course, when 5.4.0 is released (and for all newer versions), you should only change the appropriate version in the url above.\nYou want to install the broker? Easy. Just type\nkaraf@root\u0026gt; features:install activemq-spring and it\u0026rsquo;s there. Also, if you prefer to use Blueprint instead of Spring you can do\nkaraf@root\u0026gt; features:install activemq-blueprint Once installed, the broker can be started with\nkaraf@root\u0026gt; activemq:create-broker (add --type blueprint if you wish to use blueprint configuration).\nOf course, no ActiveMQ installation is complete without Web Console. To monitor our installed broker, we should take the following steps:\nInstall war feature\nkaraf@root\u0026gt; features:install war Configure system properties, by adding the following snippet\nwebconsole.type=properties webconsole.jms.url=tcp://localhost:61616 webconsole.jmx.url=service:jmx:rmi:///jndi/rmi://localhost:1099/karaf-root webconsole.jmx.user=karaf webconsole.jmx.password=karaf to etc/system.properties\nInstall and run the web console\nkaraf@root\u0026gt; features:install activemq-web-console .\nVisit the console at http://localhost:8181/activemqweb/ and enjoy.\nYou can find more detailed information on the topic reading the following article.\nAlso, if you haven\u0026rsquo;t already, check the free chapters of ActiveMQ and Camel in Action series books available at FUSESource\n","date":"August 2, 2010","externalUrl":null,"permalink":"/posts/2010-08-02-activemq-54-seamless-osgi-integration/","section":"Posts","summary":"For upcoming ActiveMQ 5.4.0 release we did a lot of work to make it a better citizen in OSGi land. Let’s walk through some of the stuff you can do now. First of all download and install recently released Apache Karaf 2.0.0.\nNow if you want to play with all these stuff before the ActiveMQ 5.4.0 is officially released, you need to edit\n${KARAF_HOME}/etc/org.ops4j.pax.url.mvn.cfg and add\nhttps://repository.apache.org/content/repositories/snapshots/ to the list of available repositories.\n","title":"ActiveMQ 5.4: Seamless OSGi Integration","type":"posts"},{"content":"I\u0026rsquo;ll be speaking on \u0026ldquo;Enterprise ActiveMQ\u0026rdquo; at \u0026ldquo;Software Scalability | Belgrade\u0026rdquo; first meetup on Saturday, July 03 2010. The full announcement could be found here\n","date":"July 1, 2010","externalUrl":null,"permalink":"/posts/2010-07-01-software-scalability-belgrade-meetup/","section":"Posts","summary":"I’ll be speaking on “Enterprise ActiveMQ” at “Software Scalability | Belgrade” first meetup on Saturday, July 03 2010. The full announcement could be found here\n","title":"Software scalability \u0026#124; Belgrade meetup","type":"posts"},{"content":"In many environments, users want to restrict access to ActiveMQ web server (Jetty) and web console application in particular. Here\u0026rsquo;s how to do it for ActiveMQ 5.3.1 version of broker.\nIn 5.3.1, the whole web server configuration is placed in the ${ACTIVEMQ_HOME}/conf/jetty.xml file. The configuration file you can find at here is a drop-in replacement for a default jetty configuration and you should place it in your configuration folder.\nBesides that you\u0026rsquo;ll need to create a ${ACTIVEMQ_HOME}/conf/jetty-realm.properties with the following content:\nIt\u0026rsquo;s a classic Jetty hash user realm file that defines one user, with it\u0026rsquo;s password and roles in each line (Downloadable from here). By default, as you can see in the realm file, you can use admin/admin credentials to access ActiveMQ web server. You should adapt this file to your security needs.\nSo, after making these changes and restarting your broker, you should get basic authentication dialog before you\u0026rsquo;d be able to proceed. If you want to later on disable the authentication, you can do that easily by changing the line\nto\nActiveMQ 5.4.0 will come with this configuration enabled by default and if you wish to secure older versions of the ActiveMQ take a look at this article.\n","date":"May 21, 2010","externalUrl":null,"permalink":"/posts/2010-05-21-securing-activemq-531-console/","section":"Posts","summary":"In many environments, users want to restrict access to ActiveMQ web server (Jetty) and web console application in particular. Here’s how to do it for ActiveMQ 5.3.1 version of broker.\nIn 5.3.1, the whole web server configuration is placed in the ${ACTIVEMQ_HOME}/conf/jetty.xml file. The configuration file you can find at here is a drop-in replacement for a default jetty configuration and you should place it in your configuration folder.\nBesides that you’ll need to create a ${ACTIVEMQ_HOME}/conf/jetty-realm.properties with the following content:\n","title":"Securing ActiveMQ 5.3.1 console","type":"posts"},{"content":"Apache ActiveMQ 5.3.1 has just been released. It\u0026rsquo;s primarily the maintenance release, including nearly 100 bug fixes and improvements over the previous 5.3.0 version. The full list of improvements and bug fixes, as well as the download link, can be found at the release page.\nJDBC message store - a big effort has been made to make JDBC store as reliable as other file-based stores for use in complex high-load use cases. nio and stomp+nio transports - initial implementation of stomp+nio transport, introduced in 5.3.0 version contained some resource leaks, but also revealed some problems with the nio transport. All these are now fixed, thoroughly tested and ready for production use OSGi integration - a lot of small improvements in this area should provide much better integration of the broker in OSGi environments. Especially, we provided resources for seamless deployment in Apache Karaf OSGi runtime. This will be the topic of the following blog post (so stay tuned!) Web console security - Web console is now secured against XSS and XSRF attacks, so it\u0026rsquo;s safe to be deployed publicly (of course with proper authentication set in place) Enjoy this release, while we work on delivering 5.4.0 in coming months (or even weeks) with more bug fixes and features, such as scheduled messages and web socket support\n","date":"March 23, 2010","externalUrl":null,"permalink":"/posts/2010-03-23-activemq-531-released/","section":"Posts","summary":"Apache ActiveMQ 5.3.1 has just been released. It’s primarily the maintenance release, including nearly 100 bug fixes and improvements over the previous 5.3.0 version. The full list of improvements and bug fixes, as well as the download link, can be found at the release page.\nJDBC message store - a big effort has been made to make JDBC store as reliable as other file-based stores for use in complex high-load use cases. nio and stomp+nio transports - initial implementation of stomp+nio transport, introduced in 5.3.0 version contained some resource leaks, but also revealed some problems with the nio transport. All these are now fixed, thoroughly tested and ready for production use OSGi integration - a lot of small improvements in this area should provide much better integration of the broker in OSGi environments. Especially, we provided resources for seamless deployment in Apache Karaf OSGi runtime. This will be the topic of the following blog post (so stay tuned!) Web console security - Web console is now secured against XSS and XSRF attacks, so it’s safe to be deployed publicly (of course with proper authentication set in place) Enjoy this release, while we work on delivering 5.4.0 in coming months (or even weeks) with more bug fixes and features, such as scheduled messages and web socket support\n","title":"ActiveMQ 5.3.1 Released","type":"posts"},{"content":"Exchanging messages with the broker directly from the web browser was always interesting use case (and used by many developers). That\u0026rsquo;s why ActiveMQ was supporting Ajax API for the long time. It uses Jetty Continuations to implement threadless waiting and asynchronous delivery of messages to the web page.\nHTML 5 introduced web sockets, as a standardized way to communicate asynchronously with the server from a web page. This is practically an ideal channel for implementing asynchronous messaging for web pages, so it\u0026rsquo;s no surprise we had it on a todo list for a long time. Also, since JavaScript easily handles text and JSON formatted data, Stomp protocol is a natural choice for the wire protocol to be used over web sockets.\nThis solution should bring better messaging capabilities to JavaScript clients then simple Ajax API, as implementing Stomp in JavaScript brings much more messaging-oriented API and features such as transactions, for example.\nJeff Mesnil, of JBoss, implemented a nice JavaScript library for doing Stomp over Web Sockets. So it was time to get this off todo list and implement Web Socket support for ActiveMQ. So, in the latest ActiveMQ 5.4 snapshot, you can find new ws (WebSocket) protocol that allows you to exchange message with the broker, using JavaScript client from your browser.\nIn the rest of this post, I\u0026rsquo;ll walk you through the steps needed to configure this transport in the broker and run chat example that comes with the Jeff\u0026rsquo;s library.\nThere\u0026rsquo;s nothing spectacular you need to do on the broker side to enable this support:\nDownload the latest ActiveMQ 5.4 snapshot and install it properly.\nEdit ${ACTIVEMQ_HOME}/conf/activemq.xml file and add ws transport, like this\n\u0026lt;transportConnectors\u0026gt; \u0026lt;transportConnector name=\u0026#34;openwire\u0026#34; uri=\u0026#34;tcp://0.0.0.0:61616\u0026#34;/\u0026gt; \u0026lt;transportConnector name=\u0026#34;websocket\u0026#34; uri=\u0026#34;ws://0.0.0.0:61614\u0026#34;/\u0026gt; \u0026lt;/transportConnectors\u0026gt; Get the client library\ngit clone git://github.com/jmesnil/stomp-websocket.git and copy it to the ${ACTIVEMQ_HOME}/webapps/demo/ folder\nStart ActiveMQ\n${ACTIVEMQ_HOME}/bin/activemq Now you can see chat example in the demo application\nhttp://localhost:8161/demo/stomp-websocket/example/chat\nEnjoy playing with your new toy :) WebSocket Chat Demo One thing worth noting is that web sockets (just as Ajax) implements same origin policy, so you can access only brokers running on the same host as the web application running the client.\nOf course, this is an initial implementation of this functionality so your feedback is more then welcome. Before ActiveMQ 5.4 is released, we\u0026rsquo;ll polish it further and integrate client and example in the ActiveMQ web demo application.\n","date":"February 22, 2010","externalUrl":null,"permalink":"/posts/2010-02-22-activemq-54-stomp-over-web-sockets/","section":"Posts","summary":"Exchanging messages with the broker directly from the web browser was always interesting use case (and used by many developers). That’s why ActiveMQ was supporting Ajax API for the long time. It uses Jetty Continuations to implement threadless waiting and asynchronous delivery of messages to the web page.\nHTML 5 introduced web sockets, as a standardized way to communicate asynchronously with the server from a web page. This is practically an ideal channel for implementing asynchronous messaging for web pages, so it’s no surprise we had it on a todo list for a long time. Also, since JavaScript easily handles text and JSON formatted data, Stomp protocol is a natural choice for the wire protocol to be used over web sockets.\n","title":"ActiveMQ 5.4: Stomp over Web Sockets","type":"posts"},{"content":"ActiveMQ producer flow control feature allows you to prevent overflowing the broker by slowing down fast producers. Thus far you had two options, the producer send() method will either wait until space becomes available, or fail if it\u0026rsquo;s configured through sendFailIfNoSpace property, like this:\n\u0026lt;systemUsage\u0026gt; \u0026lt;systemUsage sendFailIfNoSpace=\u0026#34;true\u0026#34;\u0026gt; \u0026lt;memoryUsage\u0026gt; \u0026lt;memoryUsage limit=\u0026#34;20 mb\u0026#34;/\u0026gt; \u0026lt;/memoryUsage\u0026gt; \u0026lt;/systemUsage\u0026gt; \u0026lt;/systemUsage\u0026gt; For 5.3.1 version of the broker we added a third option. You can now configure the broker to do the producer flow control with timeout. If you configure \u0026lt;systemUsage\u0026gt; like this (using sendFailIfNoSpaceAfterTimeout property),\n\u0026lt;systemUsage\u0026gt; \u0026lt;systemUsage sendFailIfNoSpaceAfterTimeout=\u0026#34;3000\u0026#34;\u0026gt; \u0026lt;memoryUsage\u0026gt; \u0026lt;memoryUsage limit=\u0026#34;20 mb\u0026#34;/\u0026gt; \u0026lt;/memoryUsage\u0026gt; \u0026lt;/systemUsage\u0026gt; \u0026lt;/systemUsage\u0026gt; the producer\u0026rsquo;s send() method will wait for space for 3 seconds and if it don\u0026rsquo;t get it, it will fail. This feature can be very useful if you don\u0026rsquo;t want your producers wait for the space for the unspecified amount of time.\n","date":"January 29, 2010","externalUrl":null,"permalink":"/posts/2010-01-29-activemq-producer-flow-control-with-timeout/","section":"Posts","summary":"ActiveMQ producer flow control feature allows you to prevent overflowing the broker by slowing down fast producers. Thus far you had two options, the producer send() method will either wait until space becomes available, or fail if it’s configured through sendFailIfNoSpace property, like this:\n\u003csystemUsage\u003e \u003csystemUsage sendFailIfNoSpace=\"true\"\u003e \u003cmemoryUsage\u003e \u003cmemoryUsage limit=\"20 mb\"/\u003e \u003c/memoryUsage\u003e \u003c/systemUsage\u003e \u003c/systemUsage\u003e For 5.3.1 version of the broker we added a third option. You can now configure the broker to do the producer flow control with timeout. If you configure \u003csystemUsage\u003e like this (using sendFailIfNoSpaceAfterTimeout property),\n","title":"ActiveMQ producer flow control with timeout","type":"posts"},{"content":"","date":"January 18, 2010","externalUrl":null,"permalink":"/categories/java/","section":"Categories","summary":"","title":"Java","type":"categories"},{"content":"Jettison version 1.2 has been released. The highlights of this release are:\nRefactored MappedXMLStreamWriter - which solved many issues with serializing arrays\nPlugable type converters and support for 64-bit long conversion\nYou can find the full change log for this release on the Download page. Enjoy\n","date":"January 18, 2010","externalUrl":null,"permalink":"/posts/2010-01-18-jettison-12-released/","section":"Posts","summary":"Jettison version 1.2 has been released. The highlights of this release are:\nRefactored MappedXMLStreamWriter - which solved many issues with serializing arrays\nPlugable type converters and support for 64-bit long conversion\nYou can find the full change log for this release on the Download page. Enjoy\n","title":"Jettison 1.2 Released","type":"posts"},{"content":"When you encounter IOException trying to persist a message on the disk, you know something has gone wrong. One of two things usually happen:\nEither your disk is dead, or disconnected in case you use network disks Or you just don\u0026rsquo;t have more space on the disk Depending on the type of the exception you may encounter, you might want to take a different action. For upcoming 5.3.1 release we implemented fully configurable IOException handling which can be tuned to your need.\nA default handler stops the broker when the message persistence fails in all cases except when it detects that the failure is caused by the lack of space on the disk. In the later case, it just wait for the space to be reclaimed and continues.\nFor more information on this topic, check http://activemq.apache.org/configurable-ioexception-handling.html\n","date":"November 20, 2009","externalUrl":null,"permalink":"/posts/2009-11-20-handling-ioexception-in-activemq/","section":"Posts","summary":"When you encounter IOException trying to persist a message on the disk, you know something has gone wrong. One of two things usually happen:\nEither your disk is dead, or disconnected in case you use network disks Or you just don’t have more space on the disk Depending on the type of the exception you may encounter, you might want to take a different action. For upcoming 5.3.1 release we implemented fully configurable IOException handling which can be tuned to your need.\n","title":"Handling IOException in ActiveMQ","type":"posts"},{"content":"In our attempt to provide better future for Stomp protocol, we already moved specification under ActiveMQ project umbrella, where all future specification improvements will be done. Another necessary step is to provide high-quality Stomp clients for use in different development environments. For that purpose, we created Stomp project on FUSE Forge. It should provide a project hosting environment for various Stomp clients.\nFor starters I released PHP Stomp Client 1.0.0. It\u0026rsquo;s a natural extension of all the work previously hosted on Codehaus + Google Code. It is now stabilized, with a lot of bug fixes and released as 1.0.0. All future development will be continued on the FUSE Forge as it provides much better hosting environment than we used thus far.\nSo, if you\u0026rsquo;re interested in Stomp for your application development, join the community and help us create high-quality clients for your environment.\n","date":"October 29, 2009","externalUrl":null,"permalink":"/posts/2009-10-29-fuse-stomp-project/","section":"Posts","summary":"In our attempt to provide better future for Stomp protocol, we already moved specification under ActiveMQ project umbrella, where all future specification improvements will be done. Another necessary step is to provide high-quality Stomp clients for use in different development environments. For that purpose, we created Stomp project on FUSE Forge. It should provide a project hosting environment for various Stomp clients.\nFor starters I released PHP Stomp Client 1.0.0. It’s a natural extension of all the work previously hosted on Codehaus + Google Code. It is now stabilized, with a lot of bug fixes and released as 1.0.0. All future development will be continued on the FUSE Forge as it provides much better hosting environment than we used thus far.\n","title":"Fuse Stomp project","type":"posts"},{"content":"I found myself recently with a task of testing various Python messaging clients. In this article I\u0026rsquo;ll present my findings regarding performance and scalability on two Python clients connecting to ActiveMQ and RabbitMQ message brokers.\nFor ActiveMQ Python client, I used pyactivemq library version 0.1.0. It\u0026rsquo;s basically a Python wrapper for ActiveMQ-CPP library, allowing Python clients to communicate with the broker using both OpenWire (ActiveMQ specific binary protocol) and Stomp (Simple text-oriented protocol) protocols. Since it uses ActiveMQ-CPP, installation requires special attention and some of those details you can find in a related blog post.\nAs a RabbitMQ client I used py-amqplib version 0.6, since that\u0026rsquo;s currently the most natural solution if you don\u0026rsquo;t want to use frameworks like Twisted.\nI used the latest broker versions, which means ActiveMQ 5.3.0 and RabbitMQ 1.7. Also, all numbers shown below are for tests executed on an \u0026ldquo;average linux desktop box\u0026rdquo; running Ubuntu 9.0.4.\nNow let\u0026rsquo;s go testing.\nPerformance # The performance test I used is really simple: One producer, one consumer and one queue. Both producer and consumer tries to do their best in terms of performances and we\u0026rsquo;re not going to use any transactions. I used small text messages, with text Example message __num__. The full source code of tests can be found at http://github.com/dejanb/pymsg/. For every client (and broker) there are two Python scripts:\ntest_receive_async.py - which starts an asynchronous consumer in a thread and samples consuming rates every 10 seconds test_send.py - which starts a producer in a thread and samples producing rates every 10 seconds Both of these scripts try to get 100 rate samples, which means tests last for about 15 minutes.\nPersistent messages # ActiveMQ 5.3.0 comes with the number of example configuration files that helps you configure it for different usage scenarios. One of those configuration files is called conf/activemq-throughput.xml and it is the one that should be used for high performance scenarios.\nTo start a broker with this configuration file, just execute:\nbin/activemq xbean:conf/activemq-throughput.xml Now you can run the consumer and producer with\npython test_receive_async.py and\npython test_send.py in separate console windows.\nWhen ran like this, the client will use OpenWire protocol. The following diagram shows the result (the full output can be found here).\nAs you can see, after the initial spike, both producer and consumer have consistent rates of around 1300 msg/sec.\nTo repeat the same test, now using Stomp wire protocol, we\u0026rsquo;ll execute the scripts with one additional parameter, stomp (of course, a clean broker start is needed)\npython test_receive_async.py stomp and\npython test_send.py stomp The results for pyactivemq client using Stomp protocols can be found here and the diagram visualizing those data is shown below.\nAgain, after the initial glitches, producer and consumer settles on a bit more than 1150 msg/sec. This is an interesting result that shows that with persistent messages the limit is not in the network protocol, but the ability of the broker to successfully persist messages.\nNow let\u0026rsquo;s try do the same with RabbitMQ and py-amqplib client. The output with the result samples can be found here and they are visualized on the following diagram.\nOn the first look you can notice the high message producing rates, starting with more than 3000 msg/sec and slowly decreasing toward 2000 messages per second. On the other hand the consumer is considerably slower at rates around 1000 msg/sec. This situation causes more and more messages being stored in the broker, when it finally crashes after 12-13 minutes. I tried setting Memory-based flow control, but without much success.\nThe high value on a producer side have one more important drawback regarding reliability. The AMQP protocol send operation is strictly asynchronous, meaning that producer does not have any confirmation from the broker that the message was actually queued. So what I observed is that the number of messages sent shown by the producer and messages stored in the broker are not in sync. You can check this by starting the producer that sends a large number of messages for some time and check the number of messages in the broker. You\u0026rsquo;ll notice that messages arrive to the broker, \u0026ldquo;long\u0026rdquo; after the producer has finished its job. So if broker crashes in the meantime, all messages producer thought it sent are lost. I didn\u0026rsquo;t test this with transactions, so I\u0026rsquo;m not sure if the behavior is somewhat different in this case. My guess it that it is and that is one of the things that I\u0026rsquo;d like to test further.\nAlso, RabbitMQ allows you to set the \u0026ldquo;returned listener\u0026rdquo; on the channel which can be used by the broker to return messages that were not routed (if the mandatory parameter is used during publishing) or could be immediately delivered (if the immediate parameter is used during publishing). py-amqplib library is currently missing this functionality, which can be another reliability issue for concern.\nSo generally, it seems like RabbitMQ have a very high producing rate (sacrificing reliability), while consuming rates are pretty standard and a bit lower than those seen by ActiveMQ consumers.\nNon-persistent messages # Now let\u0026rsquo;s try to do all that again with non-persistent messages. To modify pyactivemq producer to send non-persistent messages, we have to uncomment the following line\n#self.producer.deliveryMode = DeliveryMode.NON_PERSISTENT in perftest.py library.\nNow we can rerun our tests. For OpenWire protocol results now quite different\nshowing that the whole throughput of non-persistent messages through the broker is around 3000 msg/sec.\nSimilarly, the results for Stomp are visualized in the diagram below.\nThis shows that at around 2000 msg/sec the limitations of Stomp text-oriented protocol kicks in and limit the throughput.\nTo modify RabbitMQ client to send non-persistent messages, we have to comment the following line\nmsg.properties[\u0026#34;delivery_mode\u0026#34;] = 2 in the PerfProducer class.\nResults now look like this\nwhich is pretty much the same as in the persistent case. This is probably due to the nature of queuing and persisting messages in the broker discussed above. The only difference is that now the broker keep the rates at steady numbers of around 3200 msg/sec for producer and 950 for consumer.\nScalability # I also tried a simple scalability test against two brokers: try to send a message to as many queues as you can. The test source can be found in the appropriate test_scale.py file for both py-amqplib and pyactivemq libraries.\nWhen you run appropriate\npython test_scale.py against RabbitMQ you\u0026rsquo;ll get that the message was sent to the around 32000 queues before it crashes, which is very good result.\nActiveMQ, again, comes with the predefined configuration file which should be used if you want to scale your broker (conf/activemq-scalability.xml). As it\u0026rsquo;s stated in the configuration file, there a couple of minor changes needed to be made to the startup script in order to achieve maximum scalability. We\u0026rsquo;ll use these\nACTIVEMQ_OPTS=\u0026#34;-Xmx1024M -Dorg.apache.activemq.UseDedicatedTaskRunner=false\u0026#34; properties in order to give broker a bit more memory and turn of dedicated task runner.\nWhen started with the configuration like this, the\npython test_scale.py shows that message was sent to impressive 64000 queues before it crashed.\nWe can try the scalability of Stomp protocol as well. In order to do that, we should add\n\u0026lt;transportConnector name=\u0026#34;stomp+nio\u0026#34; uri=\u0026#34;stomp+nio://0.0.0.0:61613\u0026#34;/\u0026gt; to the list of available connectors.\nNow we can start the test again\npython test_scale.py stomp and we\u0026rsquo;ll get the result very similar to the one of the default OpenWire connector.\nConclusion # To conclude, both ActiveMQ and RabbitMQ are decent brokers that will serve their purpose well in normal conditions, but put to their extremes in terms of throughput, scalability and reliablilty, ActiveMQ currently outperforms RabbitMQ for messaging usage in Python. All tests performed here are done with honest intentions of providing realistic results. If you spot any problems or have any ideas what more can be tested (transactions, etc.), please let me know.\n","date":"October 20, 2009","externalUrl":null,"permalink":"/posts/2009-10-20-python-messaging-activemq-and-rabbitmq/","section":"Posts","summary":"I found myself recently with a task of testing various Python messaging clients. In this article I’ll present my findings regarding performance and scalability on two Python clients connecting to ActiveMQ and RabbitMQ message brokers.\nFor ActiveMQ Python client, I used pyactivemq library version 0.1.0. It’s basically a Python wrapper for ActiveMQ-CPP library, allowing Python clients to communicate with the broker using both OpenWire (ActiveMQ specific binary protocol) and Stomp (Simple text-oriented protocol) protocols. Since it uses ActiveMQ-CPP, installation requires special attention and some of those details you can find in a related blog post.\n","title":"Python messaging: ActiveMQ and RabbitMQ","type":"posts"},{"content":"After more than a year in development, we finally released 5.3.0 version of ActiveMQ. It contains over 300 bug fixes, but also some of the neat new features. The full list of features and bug fixes, as well as the download link can be found at the release page\nHere, I would like to emphasize just some of the new features:\nNew KahaDB persisten store, which improves recovery times and scalability in a great deal A default configuration now focused more on production then demoing all features. You can also find some useful configuration examples for different scenarios, like vertical scaling or throughput Camel 2.0.0 integrated along with it\u0026rsquo;s web console for managing endpoints and routes \u0026hellip; and much, much more You can expect more useful resources on ActiveMQ 5.3.0 in coming days.\n","date":"October 13, 2009","externalUrl":null,"permalink":"/posts/2009-10-13-apache-activemq-530-release/","section":"Posts","summary":"After more than a year in development, we finally released 5.3.0 version of ActiveMQ. It contains over 300 bug fixes, but also some of the neat new features. The full list of features and bug fixes, as well as the download link can be found at the release page\nHere, I would like to emphasize just some of the new features:\nNew KahaDB persisten store, which improves recovery times and scalability in a great deal A default configuration now focused more on production then demoing all features. You can also find some useful configuration examples for different scenarios, like vertical scaling or throughput Camel 2.0.0 integrated along with it’s web console for managing endpoints and routes … and much, much more You can expect more useful resources on ActiveMQ 5.3.0 in coming days.\n","title":"Apache ActiveMQ 5.3.0 Released","type":"posts"},{"content":"While working on Jettison, I often have need to convert XML to JSON. Here\u0026rsquo;s a simple method that uses XStream and Jettison to do this conversion.\nimport java.io.StringReader; import java.io.StringWriter; import com.thoughtworks.xstream.io.HierarchicalStreamReader; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; import com.thoughtworks.xstream.io.copy.HierarchicalStreamCopier; import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; import com.thoughtworks.xstream.io.xml.XppReader; public class Test { public static void main(String[] args) throws Exception { String xml = \u0026#34;ToveJaniReminder\u0026#34; + \u0026#34;Don\u0026#39;t forget me this weekend!\u0026#34;; HierarchicalStreamReader sourceReader = new XppReader(new StringReader(xml)); StringWriter buffer = new StringWriter(); JettisonMappedXmlDriver jettisonDriver = new JettisonMappedXmlDriver(); jettisonDriver.createWriter(buffer); HierarchicalStreamWriter destinationWriter = jettisonDriver.createWriter(buffer); HierarchicalStreamCopier copier = new HierarchicalStreamCopier(); copier.copy(sourceReader, destinationWriter); System.out.println(buffer.toString()); } } All conversion problems, like lists representation are handled by Jetttison. This example uses Mapped convention, but of course, BadgerFish notation can be used as well.\n","date":"September 21, 2009","externalUrl":null,"permalink":"/posts/2009-09-21-xml-to-json/","section":"Posts","summary":"While working on Jettison, I often have need to convert XML to JSON. Here’s a simple method that uses XStream and Jettison to do this conversion.\nimport java.io.StringReader; import java.io.StringWriter; import com.thoughtworks.xstream.io.HierarchicalStreamReader; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; import com.thoughtworks.xstream.io.copy.HierarchicalStreamCopier; import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; import com.thoughtworks.xstream.io.xml.XppReader; public class Test { public static void main(String[] args) throws Exception { String xml = \"ToveJaniReminder\" + \"Don't forget me this weekend!\"; HierarchicalStreamReader sourceReader = new XppReader(new StringReader(xml)); StringWriter buffer = new StringWriter(); JettisonMappedXmlDriver jettisonDriver = new JettisonMappedXmlDriver(); jettisonDriver.createWriter(buffer); HierarchicalStreamWriter destinationWriter = jettisonDriver.createWriter(buffer); HierarchicalStreamCopier copier = new HierarchicalStreamCopier(); copier.copy(sourceReader, destinationWriter); System.out.println(buffer.toString()); } } All conversion problems, like lists representation are handled by Jetttison. This example uses Mapped convention, but of course, BadgerFish notation can be used as well.\n","title":"XML to JSON","type":"posts"},{"content":"Some folks have been experiencing problems with wire format negotiation timeouts. Sometimes it was due to overloaded brokers or lousy networks, but misconfiguration of log4j jms appender could also be one of the causes. So, I wrote two FAQ entries that covers this topic:\nUsing log4j appender with ActiveMQ\nWire format negotiation timeout exception\nEnjoy\n","date":"August 11, 2009","externalUrl":null,"permalink":"/posts/2009-08-11-wire-format-negotiation-timeout-log4j-jms-appender-and/","section":"Posts","summary":"Some folks have been experiencing problems with wire format negotiation timeouts. Sometimes it was due to overloaded brokers or lousy networks, but misconfiguration of log4j jms appender could also be one of the causes. So, I wrote two FAQ entries that covers this topic:\nUsing log4j appender with ActiveMQ\nWire format negotiation timeout exception\nEnjoy\n","title":"Wire format negotiation timeout and log4j jms appender FAQs","type":"posts"},{"content":"While thinking about the future of Stomp protocol, we concluded that the best place for future maintenance of the specification is under umbrella of ActiveMQ project. There are a couple reasons for this, but it basically boils down to two facts:\nApache infrastructure is much better suited for this task than the one currently used at Codehaus Most of the Stomp contributors are also ActiveMQ committers, so this transition feels natural in this respect. As a starting point, we created an ActiveMQ sub-project http://activemq.apache.org/stomp/ which will be the home of the all future work on the protocol. At the moment, we only ported information related to Stomp version 1.0 (specification and related articles) to this new project. Soon, we\u0026rsquo;ll start working on protocol specification version 1.1, using the current idea pool as a base.\nThe whole documentation for the project is created using Webgen, so it consists of Markdown pages stored in an appropriate SVN repository (for example, Stomp 1.0 specification is located in here). You can also use Jira to file any tasks, issues and requests for the specification related work. So please feel free to contribute :)\nThis project is not meant to contain any Stomp clients, but only to be a home of the Stomp specification. This doesn\u0026rsquo;t mean that we don\u0026rsquo;t think about how to provide the better infrastructure to Stomp clients developers. But that is the topic for another discussion and you can expect more news regarding that soon.\n","date":"July 21, 2009","externalUrl":null,"permalink":"/posts/2009-07-21-stomp-future/","section":"Posts","summary":"While thinking about the future of Stomp protocol, we concluded that the best place for future maintenance of the specification is under umbrella of ActiveMQ project. There are a couple reasons for this, but it basically boils down to two facts:\nApache infrastructure is much better suited for this task than the one currently used at Codehaus Most of the Stomp contributors are also ActiveMQ committers, so this transition feels natural in this respect. As a starting point, we created an ActiveMQ sub-project http://activemq.apache.org/stomp/ which will be the home of the all future work on the protocol. At the moment, we only ported information related to Stomp version 1.0 (specification and related articles) to this new project. Soon, we’ll start working on protocol specification version 1.1, using the current idea pool as a base.\n","title":"Stomp Future","type":"posts"},{"content":"pyactivemq is a Python library that enables Python clients to communicate with ActiveMQ using both OpenWire and Stomp protocols. To do that it wraps ActiveMQ-CPP library, so it involves some compiling to make it all work. While building instructions for both ActiveMQ-CPP and pyactivemq and clear and concise, I found some additional steps were need to make it all work on Ubuntu box. I\u0026rsquo;ll post it here for my future reference and hopefully it can be useful to other folks.\nThis is tested with ActiveMQ-CPP version 2.2.6 and activemqpy 0.1.0\nLet\u0026rsquo;s start with ActiveMQ-CPP. ActiveMQ-CPP depends on a couple of libraries listed on the wiki page. You can easily obtain them using something like:\n``` $ sudo apt-get install autoconf $ sudo apt-get install automake $ sudo apt-get install libtool $ sudo apt-get install uuid-dev $ sudo apt-get install libcppunit-dev ```\nBut you also need to install the build-essential package with``` sudo apt-get install build-essential ```\nThis is now added to the wiki as well\nBefore starting the build, you\u0026rsquo;ll also need to install APR-util and APR libraries. Steps are pretty forward, so I\u0026rsquo;ll skip them here.\nNow we\u0026rsquo;re finally ready to start the ActiveMQ-CPP build. By following instructions on the wiki page, you should have ActiveMQ-CPP installed into /usr/local/include/activemq-cpp-x.x.x/.\nSo, let\u0026rsquo;s get back to the pyactivemq. First thing you need to do is to edit setup.py and point it to the location where ActiveMQ-CPP is installed. You can do that by changing all /opt/activemq-cpp-x.x.x references to your /usr/local/include/activemq-cpp-x.x.x/\nFor successful build of pyactivemq you need to install one more dependency (Boost.Python) and you can do that with the following command:``` sudo apt-get install libboost-python-dev ```\nAfter these steps you can build and install pyactivemq.\nThere is just one more thing to do in order to successfully run scripts that use pyactivemq. You need to add ActiveMQ-CPP location to the list of shared libraries. To do that add the following line:\n/usr/local/include/activemq-cpp-x.x.x/ to the /etc/ld.so.conf file and run\n$ sudo ldconfig It\u0026rsquo;s finally ready. To test it, start your broker, go to the src/examples directory and run\n$ python asynclistener.py Enjoy writing your Python application using ActiveMQ and pyactivemq.\n","date":"July 7, 2009","externalUrl":null,"permalink":"/posts/2009-07-07-pyactivemq-on-ubuntu/","section":"Posts","summary":"pyactivemq is a Python library that enables Python clients to communicate with ActiveMQ using both OpenWire and Stomp protocols. To do that it wraps ActiveMQ-CPP library, so it involves some compiling to make it all work. While building instructions for both ActiveMQ-CPP and pyactivemq and clear and concise, I found some additional steps were need to make it all work on Ubuntu box. I’ll post it here for my future reference and hopefully it can be useful to other folks.\n","title":"pyactivemq on Ubuntu","type":"posts"},{"content":"There are new chapters available on ActiveMQ in Action book in Manning Early Access Program (MEAP). This time you can read:\nChapter 12 - Tuning ActiveMQ for performance - gives detailed explanation on various techniques you can use to improve your brokers\u0026rsquo; performances Chapter 14 - Administering and managing ActiveMQ - explains how to monitor your broker using JMX, advisory messages and such Enjoy reading!\n","date":"June 12, 2009","externalUrl":null,"permalink":"/posts/2009-06-12-activemq-in-action-meap-update/","section":"Posts","summary":"There are new chapters available on ActiveMQ in Action book in Manning Early Access Program (MEAP). This time you can read:\nChapter 12 - Tuning ActiveMQ for performance - gives detailed explanation on various techniques you can use to improve your brokers’ performances Chapter 14 - Administering and managing ActiveMQ - explains how to monitor your broker using JMX, advisory messages and such Enjoy reading!\n","title":"ActiveMQ in Action MEAP update","type":"posts"},{"content":"Another month, another Fuse message broker 5.0 branch update. This time, it comes with HTTP transport and a message consumer improvements.\n","date":"June 12, 2009","externalUrl":null,"permalink":"/posts/2009-06-12-fuse-message-broker-50028-released/","section":"Posts","summary":"Another month, another Fuse message broker 5.0 branch update. This time, it comes with HTTP transport and a message consumer improvements.\n","title":"Fuse Message Broker 5.0.0.28 released","type":"posts"},{"content":"OSGi containers are becoming a deployment platform of choice for many developers these days. That\u0026rsquo;s why nearly all server-side Java software is packaged as OSGi bundles and ActiveMQ is not an exception. I wrote an article that goes into the details on how to deploy and use ActiveMQ broker and web console in Apache Karaf (and ServiceMix) OSGi environments. I hope you\u0026rsquo;ll enjoy reading it.\n","date":"June 10, 2009","externalUrl":null,"permalink":"/posts/2009-06-10-activemq-osgi-integration/","section":"Posts","summary":"OSGi containers are becoming a deployment platform of choice for many developers these days. That’s why nearly all server-side Java software is packaged as OSGi bundles and ActiveMQ is not an exception. I wrote an article that goes into the details on how to deploy and use ActiveMQ broker and web console in Apache Karaf (and ServiceMix) OSGi environments. I hope you’ll enjoy reading it.\n","title":"ActiveMQ OSGi integration","type":"posts"},{"content":"We\u0026rsquo;ve cut and thoroughly tested another Fuse Message Broker 5.3 release. If you need a stable 5.3 ActiveMQ version, try it out. You can find more info about this release here.\n","date":"June 1, 2009","externalUrl":null,"permalink":"/posts/2009-06-01-fuse-message-broker-5302-released/","section":"Posts","summary":"We’ve cut and thoroughly tested another Fuse Message Broker 5.3 release. If you need a stable 5.3 ActiveMQ version, try it out. You can find more info about this release here.\n","title":"Fuse Message Broker 5.3.0.2 released","type":"posts"},{"content":"Another incremental improvement of the ActiveMQ 5.0 branch. Check release notes for more details.\n","date":"May 19, 2009","externalUrl":null,"permalink":"/posts/2009-05-19-fuse-message-broker-50027-released/","section":"Posts","summary":"Another incremental improvement of the ActiveMQ 5.0 branch. Check release notes for more details.\n","title":"Fuse Message Broker 5.0.0.27 released","type":"posts"},{"content":"While waiting for Apache ActiveMQ 5.3, you can try our latest cut of Fuse Message Broker 5.3.0.1. A lot of issues are already merged and thoroughly tested. Also, it very easy to do a switch back and forth (take a look at this article for more details).\n","date":"April 23, 2009","externalUrl":null,"permalink":"/posts/2009-04-23-fuse-message-broker-5301-released/","section":"Posts","summary":"While waiting for Apache ActiveMQ 5.3, you can try our latest cut of Fuse Message Broker 5.3.0.1. A lot of issues are already merged and thoroughly tested. Also, it very easy to do a switch back and forth (take a look at this article for more details).\n","title":"Fuse Message Broker 5.3.0.1 released","type":"posts"},{"content":"Jettison 1.1 has been released. New features in this release are:\nDOM API Type converters OSGi bundle packaging You can find the full change log for this release on the Download page. Enjoy!\n","date":"April 23, 2009","externalUrl":null,"permalink":"/posts/2009-04-23-jettison-11-released/","section":"Posts","summary":"Jettison 1.1 has been released. New features in this release are:\nDOM API Type converters OSGi bundle packaging You can find the full change log for this release on the Download page. Enjoy!\n","title":"Jettison 1.1 released","type":"posts"},{"content":"ActiveMQ has been added to Hudson continuous-integration server instance at Apache http://hudson.zones.apache.org/hudson/job/ActiveMQ/. Now you can have more insight into test runs and snapshot builds. Hudson will also send failure reports to our dev mailing list, making us address them promptly. As a part of this change, the snapshots location and Maven repository has changed. If you\u0026rsquo;re using ActiveMQ snapshots in your projects, be sure to add the following repository to your Maven configuration:\n\u0026lt;repositories\u0026gt; \u0026lt;repository\u0026gt; \u0026lt;id\u0026gt;hudson.snapshots\u0026lt;/id\u0026gt; \u0026lt;url\u0026gt;https://repository.apache.org/content/repositories/snapshots/\u0026lt;/url\u0026gt; \u0026lt;releases\u0026gt; \u0026lt;enabled\u0026gt;false\u0026lt;/enabled\u0026gt; \u0026lt;/releases\u0026gt; \u0026lt;/repository\u0026gt; \u0026lt;/repositories\u0026gt; ","date":"April 17, 2009","externalUrl":null,"permalink":"/posts/2009-04-17-activemq-continuos-intergration/","section":"Posts","summary":"ActiveMQ has been added to Hudson continuous-integration server instance at Apache http://hudson.zones.apache.org/hudson/job/ActiveMQ/. Now you can have more insight into test runs and snapshot builds. Hudson will also send failure reports to our dev mailing list, making us address them promptly. As a part of this change, the snapshots location and Maven repository has changed. If you’re using ActiveMQ snapshots in your projects, be sure to add the following repository to your Maven configuration:\n","title":"ActiveMQ continuos intergration","type":"posts"},{"content":"Nice explanation of importance of asynchronous messaging by Dooplr CTO Matt Biddulph at dConstruct 2008\nAnd I am not going to any update, but I just want to say to every developer in the room that you need to be playing with asynchronous messaging right now on your servers. You need to grab Apache ActiveMQ or Beanstalk, or play with Amazon\u0026rsquo;s Simple Queue system. And start building a different sort of gearing into your website.\nThink of each of these layers as things that may want to run at different speeds in an engine. And the way you make things run at different speeds in a mechanism, is to put gearing in between them, and to allow them to freewheel from each other from time to time. And not all proceed in lock start. It\u0026rsquo;s, because, it\u0026rsquo;s going to be an enormously important engineering principle for the future.\n","date":"April 7, 2009","externalUrl":null,"permalink":"/posts/2009-04-07-asynchronous-messaging-for-web-sites/","section":"Posts","summary":"Nice explanation of importance of asynchronous messaging by Dooplr CTO Matt Biddulph at dConstruct 2008\nAnd I am not going to any update, but I just want to say to every developer in the room that you need to be playing with asynchronous messaging right now on your servers. You need to grab Apache ActiveMQ or Beanstalk, or play with Amazon’s Simple Queue system. And start building a different sort of gearing into your website.\n","title":"Asynchronous messaging for web sites","type":"posts"},{"content":"If you were planning to buy ActiveMQ in Action (ebook, print or both), you\u0026rsquo;re in luck. Until March 23rd, you can use coupon code activemq40 at Manning site and get 40% off the regular price.\n","date":"March 11, 2009","externalUrl":null,"permalink":"/posts/2009-03-11-activemq-in-action-discount/","section":"Posts","summary":"If you were planning to buy ActiveMQ in Action (ebook, print or both), you’re in luck. Until March 23rd, you can use coupon code activemq40 at Manning site and get 40% off the regular price.\n","title":"ActiveMQ in Action discount","type":"posts"},{"content":"Fuse Message Broker 5.0.0.26 is just released. It\u0026rsquo;s mostly a work towards better stability, but there is also a couple of important bug fixes (release notes). If you\u0026rsquo;re still on ActiveMQ 5.0 branch, be sure to give it a try.\n","date":"February 25, 2009","externalUrl":null,"permalink":"/posts/2009-02-25-fuse-message-broker-50026-released/","section":"Posts","summary":"Fuse Message Broker 5.0.0.26 is just released. It’s mostly a work towards better stability, but there is also a couple of important bug fixes (release notes). If you’re still on ActiveMQ 5.0 branch, be sure to give it a try.\n","title":"Fuse Message Broker 5.0.0.26 released","type":"posts"},{"content":"Quite often people ask how to \u0026ldquo;unacknowledge\u0026rdquo; the message using Stomp. I wrote a brief FAQ entry (with an example):\nhttp://activemq.apache.org/how-do-i-unack-the-message-with-stomp.html\nAlso, be sure to use 5.3-SNAPSHOT (or later), since there were some improvements in that area recently.\n","date":"February 17, 2009","externalUrl":null,"permalink":"/posts/2009-02-17-unacking-messages-with-stomp/","section":"Posts","summary":"Quite often people ask how to “unacknowledge” the message using Stomp. I wrote a brief FAQ entry (with an example):\nhttp://activemq.apache.org/how-do-i-unack-the-message-with-stomp.html\nAlso, be sure to use 5.3-SNAPSHOT (or later), since there were some improvements in that area recently.\n","title":"Unacking messages with Stomp","type":"posts"},{"content":"Fuse Message Broker 5.2.0.2 has just been released, with a couple of issues fixed. You can find release notes here.\nI would like to take this chance to explain Fuse releases a bit and how you can easily switch between Apache and Fuse releases of ActiveMQ. Apache ActiveMQ and Fuse Message Broker are practically the same software (created from the same code base), but while you can expect Apache ActiveMQ releases every six months or so we try to have a monthly release cycle at Fuse. So, if you wait for version 5.3 to be released and you don\u0026rsquo;t want to use snapshot releases, you can use Fuse Message Broker releases 5.2.0.x which every month include a couple of new fixes. Fuse releases are thoroughly tested, so you can safely use it in your production environment.\nThe good news is that Fuse releases are free to use, so all you have to do is add an additional repository to your POM file and change the version of ActiveMQ you want to use in your project.\nFor example, to use Fuse Message Broker 5.2.0.2 instead of Apache 5.2.0 release, just add the following repositories\n\u0026lt;repositories\u0026gt; \u0026lt;repository\u0026gt; \u0026lt;id\u0026gt;FUSESource\u0026lt;/id\u0026gt; \u0026lt;name\u0026gt;FUSESource Repository\u0026lt;/name\u0026gt; \u0026lt;url\u0026gt;http://repo.fusesource.com/maven2\u0026lt;/url\u0026gt; \u0026lt;/repository\u0026gt; \u0026lt;/repositories\u0026gt; \u0026lt;pluginRepositories\u0026gt; \u0026lt;pluginRepository\u0026gt; \u0026lt;id\u0026gt;FUSESource\u0026lt;/id\u0026gt; \u0026lt;name\u0026gt;FUSESource Repository\u0026lt;/name\u0026gt; \u0026lt;url\u0026gt;http://repo.fusesource.com/maven2\u0026lt;/url\u0026gt; \u0026lt;/pluginRepository\u0026gt; \u0026lt;/pluginRepositories\u0026gt; and change ActiveMQ version from\n\u0026lt;dependency\u0026gt; \u0026lt;groupId\u0026gt;org.apache.activemq\u0026lt;/groupId\u0026gt; \u0026lt;artifactId\u0026gt;activemq-all\u0026lt;/artifactId\u0026gt; \u0026lt;version\u0026gt;5.2.0\u0026lt;/version\u0026gt; \u0026lt;/dependency\u0026gt; to\n\u0026lt;dependency\u0026gt; \u0026lt;groupId\u0026gt;org.apache.activemq\u0026lt;/groupId\u0026gt; \u0026lt;artifactId\u0026gt;activemq-all\u0026lt;/artifactId\u0026gt; \u0026lt;version\u0026gt;5.2.0.2-fuse\u0026lt;/version\u0026gt; \u0026lt;/dependency\u0026gt; Yes, it\u0026rsquo;s really that easy.\n","date":"February 9, 2009","externalUrl":null,"permalink":"/posts/2009-02-09-fuse-message-broker-5202-released/","section":"Posts","summary":"Fuse Message Broker 5.2.0.2 has just been released, with a couple of issues fixed. You can find release notes here.\nI would like to take this chance to explain Fuse releases a bit and how you can easily switch between Apache and Fuse releases of ActiveMQ. Apache ActiveMQ and Fuse Message Broker are practically the same software (created from the same code base), but while you can expect Apache ActiveMQ releases every six months or so we try to have a monthly release cycle at Fuse. So, if you wait for version 5.3 to be released and you don’t want to use snapshot releases, you can use Fuse Message Broker releases 5.2.0.x which every month include a couple of new fixes. Fuse releases are thoroughly tested, so you can safely use it in your production environment.\n","title":"Fuse Message Broker 5.2.0.2 released","type":"posts"},{"content":"If you\u0026rsquo;re looking for ActiveMQ documentation, you can try reading online chapters of \u0026ldquo;ActiveMQ in Action\u0026rdquo; using Manning Early Access Program (MEAP) - http://www.manning.com/snyder/\nNew chapters has just been added:\nChapter 2 provides a detailed overview of ActiceMQ\nChapter 4 explains ActiveMQs message persistence options\nChapter 7 addresses the aspects related to providing messaging services to different platforms\nChapter 12 explains performance tuning techniques\nI hope you\u0026rsquo;ll enjoy reading them.\n","date":"February 5, 2009","externalUrl":null,"permalink":"/posts/2009-02-05-new-chapters-of-activemq-in-action-are-available-online/","section":"Posts","summary":"If you’re looking for ActiveMQ documentation, you can try reading online chapters of “ActiveMQ in Action” using Manning Early Access Program (MEAP) - http://www.manning.com/snyder/\nNew chapters has just been added:\nChapter 2 provides a detailed overview of ActiceMQ\nChapter 4 explains ActiveMQs message persistence options\nChapter 7 addresses the aspects related to providing messaging services to different platforms\nChapter 12 explains performance tuning techniques\nI hope you’ll enjoy reading them.\n","title":"New chapters of ActiveMQ in Action are available online","type":"posts"},{"content":"As the first sentence of the message groups documentation page says: message groups rock. One of the problem with them, however, was an inappropriate behavior in case you\u0026rsquo;re adding your consumers for the messages already stored in the broker (with appropriate message group parameters set). This also causes that message groups are not honored in master slave environment, because when master goes down you can end up with your producer sending some messages to the slave before your consumers subscribe.\nIn 5.3 this problem is solved, but there is one catch worth mentioning. If you connect your consumers and start dispatching immediately, you will probably end up with your first consumers acquiring all messages groups. There are a couple of mechanisms you can use to avoid this behavior. First, you can add a small pause between first consumer subscribed and actual message dispatch starts. You can do that with the timeBeforeDispatchStarts destination policy option, which defines the number of milliseconds the broker will wait before dispatch starts.\n\u0026lt;destinationPolicy\u0026gt; \u0026lt;policyMap\u0026gt; \u0026lt;policyEntries\u0026gt; \u0026lt;policyEntry queue=\u0026#34;\u0026gt;\u0026#34; timeBeforeDispatchStarts=\u0026#34;200\u0026#34;/\u0026gt; \u0026lt;/policyEntries\u0026gt; \u0026lt;/policyMap\u0026gt; \u0026lt;/destinationPolicy\u0026gt; If you know exact number of consumers, you can also do something like this\n\u0026lt;destinationPolicy\u0026gt; \u0026lt;policyMap\u0026gt; \u0026lt;policyEntries\u0026gt; \u0026lt;policyEntry queue=\u0026#34;\u0026gt;\u0026#34; consumersBeforeDispatchStarts=\u0026#34;2\u0026#34; timeBeforeDispatchStarts=\u0026#34;2000\u0026#34;/\u0026gt; \u0026lt;/policyEntries\u0026gt; \u0026lt;/policyMap\u0026gt; \u0026lt;/destinationPolicy\u0026gt; This configuration instructs the broker to wait for two consumers to subscribe (or 2 seconds) before it starts dispatching. If you omit the timeBeforeDispatchStarts parameter, the default timeout of 1 sec will be used.\n","date":"January 26, 2009","externalUrl":null,"permalink":"/posts/2009-01-26-message-groups-just-got-a-bit-better/","section":"Posts","summary":"As the first sentence of the message groups documentation page says: message groups rock. One of the problem with them, however, was an inappropriate behavior in case you’re adding your consumers for the messages already stored in the broker (with appropriate message group parameters set). This also causes that message groups are not honored in master slave environment, because when master goes down you can end up with your producer sending some messages to the slave before your consumers subscribe.\n","title":"Message groups just got a bit better","type":"posts"},{"content":"The failover transport proved to be useful for many use cases, but had one drawback. When no browsers are available, your send operation will hang. One of the ways to deal with this is to use TransportListener to detect and handle those cases.\nFrom 5.3 version onwards, you will be able to use new timeout option on the protocol that should solve this problem naturally. So, if you use an URL like this:\nfailover:(tcp://primary:61616)?timeout=3000 your send will throw an exception like this one:\njavax.jms.JMSException: Failover timeout of 3000 ms reached. if the connection isn\u0026rsquo;t established. The connection is not killed and the reconnection procedure will not be interrupted, so you can use it as you\u0026rsquo;d normally do (and hopefully your broker will come on-line soon :)\n","date":"January 12, 2009","externalUrl":null,"permalink":"/posts/2009-01-12-sending-over-failover-transport-with-timeout/","section":"Posts","summary":"The failover transport proved to be useful for many use cases, but had one drawback. When no browsers are available, your send operation will hang. One of the ways to deal with this is to use TransportListener to detect and handle those cases.\nFrom 5.3 version onwards, you will be able to use new timeout option on the protocol that should solve this problem naturally. So, if you use an URL like this:\n","title":"Sending over failover transport with timeout","type":"posts"},{"content":"Apache ActiveMQ 5.2 is finally released. It is mainly a maintenance release, but there are also a couple of new features, like extended Advisory support and such. If you use ActiveMQ, be sure to give this release a try.\n","date":"November 21, 2008","externalUrl":null,"permalink":"/posts/2008-11-21-apache-activemq-52/","section":"Posts","summary":"Apache ActiveMQ 5.2 is finally released. It is mainly a maintenance release, but there are also a couple of new features, like extended Advisory support and such. If you use ActiveMQ, be sure to give this release a try.\n","title":"Apache ActiveMQ 5.2","type":"posts"},{"content":"Update: There is now a wiki page on Stomp site for this, please go there if you are interested in Stomp v1.1\nAs discussed in this thread some time ago, there is a need to start working on Stomp version 1.1 protocol specification (and implementation), if nothing else then to support types for message properties. I would like to discuss some of the ideas regarding this, before I start working on it. So any thoughts and comment are more than welcomed.\nWe kind of agreed that we need wire format negotiations in order to make clients and brokers understand each other on what version of the protocol will be used. I think the best place to achieve this is during the connection procedure.\nThe client can include the version header into the CONNECT command frame, indicating the highest version of the protocol it supports. If there is no version header, version 1.0 is assumed (supports backward compatibility).\nThe server responds with CONNECTED frame and it can also include the version header, which also indicates the highest version of the protocol implemented. The lack of the version header assumes version 1.0.\nNow since both the client and the server knows capabilities of each other, they can use the highest version they both support.\nA few examples:\nCONNECT login: \u0026lt;username\u0026gt; passcode:\u0026lt;passcode\u0026gt; version: 1.1 ^@ CONNECTED session: \u0026lt;session-id\u0026gt; version: 1.1 ^@ version 1.1 will be used.\nCONNECT login: \u0026lt;username\u0026gt; passcode:\u0026lt;passcode\u0026gt; version: 1.1 ^@ CONNECTED session: \u0026lt;session-id\u0026gt; ^@ version 1.0 will be used.\nNow the features I would like to see in this new version.\nFirst of all, support for JSON basic type notation for header values.\nCurrently header values are interpreted as plain String, which makes usage of selectors with numerical values impossible with Stomp. The idea is to support following notation for header values:\nNumber (integer, real, or floating point) String (double-quoted Unicode with backslash escapement) Boolean (true and false) Array (an ordered sequence of values, comma-separated and enclosed in square brackets) Object (collection of key/value pairs, comma-separated and enclosed in curly brackets) null I\u0026rsquo;m not sure if we should include \u0026ldquo;message transformation\u0026rdquo; feature (implemented in ActiveMQ already, unfortunately not documented well), which allows you to do transformation of frame content to object, map or byte messages according to the transformation header provided. Currently, support for XML and JSON encoding is supported with the following values (jms-byte, jms-object-xml, jms-object-json, jms-map-xml, jms-map-json).\nSo for example, the following command\nSEND destination:/queue/TEST.Q transformation:jms-map-xml \u0026lt;map\u0026gt; \u0026lt;entry\u0026gt; \u0026lt;string\u0026gt;name\u0026lt;/string\u0026gt; \u0026lt;string\u0026gt;Dejan\u0026lt;/string\u0026gt; \u0026lt;/entry\u0026gt; \u0026lt;entry\u0026gt; \u0026lt;string\u0026gt;city\u0026lt;/string\u0026gt; \u0026lt;string\u0026gt;Belgrade\u0026lt;/string\u0026gt; \u0026lt;/entry\u0026gt; \u0026lt;/map\u0026gt; ^@ would send a map message to the queue.\nSupport content-encoding header for SEND and SUBSCRIBE commands allowing to send gziped and base64 encoded content.\nI would prefer to send and receive binary messages as base64 encoded text, since it seems more natural to me for this kind text-based protocol. Again, this introduces the concept of binary message to Stomp protocol, which I\u0026rsquo;m not sure we want to do. But surely, gziped content would be appreciated in many contexts.\nAll this looks great, but adds a lot of new concepts to simple text-oriented protocol, such as map and object messages for example. As useful as this can be in the JMS context, I\u0026rsquo;m still not sure whether this should be included in protocol for all those people wanting just to send and receive plain text messages. But on the other hand, people always can stick with the version 1.0 and let all others with more sophisticated demands to have a standardized protocol for their needs.\nSince these are just initial thoughts, all comments are more than welcomed. Also, if you have any new \u0026ldquo;requirements\u0026rdquo; you would like to see in Stomp, now it\u0026rsquo;s time to come forward.\n","date":"September 23, 2008","externalUrl":null,"permalink":"/posts/2008-09-23-stomp-v11-thoughts/","section":"Posts","summary":"Update: There is now a wiki page on Stomp site for this, please go there if you are interested in Stomp v1.1\nAs discussed in this thread some time ago, there is a need to start working on Stomp version 1.1 protocol specification (and implementation), if nothing else then to support types for message properties. I would like to discuss some of the ideas regarding this, before I start working on it. So any thoughts and comment are more than welcomed.\n","title":"Stomp v1.1 thoughts","type":"posts"},{"content":"Joel Confino of Chariot Solutions, LLC wrote an article on building Web 2.0 Web applications using jQuery, Spring MVC, and XStream/Jettison. It\u0026rsquo;s good to see Jettison in practice :)\n","date":"September 17, 2008","externalUrl":null,"permalink":"/posts/2008-09-17-jettison-in-practice/","section":"Posts","summary":"Joel Confino of Chariot Solutions, LLC wrote an article on building Web 2.0 Web applications using jQuery, Spring MVC, and XStream/Jettison. It’s good to see Jettison in practice :)\n","title":"Jettison in practice","type":"posts"},{"content":"","date":"August 11, 2008","externalUrl":null,"permalink":"/categories/links/","section":"Categories","summary":"","title":"Links","type":"categories"},{"content":" Home - Adhearsion.com\nrails-like framework for developing with asterisk\n(tags: voip ruby framework)\n","date":"August 11, 2008","externalUrl":null,"permalink":"/posts/2008-08-11-links-for-2008-08-11-deliciouscom/","section":"Posts","summary":" Home - Adhearsion.com\nrails-like framework for developing with asterisk\n(tags: voip ruby framework)\n","title":"links for 2008-08-11 [delicious.com]","type":"posts"},{"content":" As Bruce and Rob already said, our current work on \u0026ldquo;ActiveMQ in Action\u0026rdquo; book is available in Manning Early Access Program (MEAP).\nWe will try to cover all aspects of ActiveMQ, from basic stuff such as JMS basics and how to run ActiveMQ for the first time to complex broker topologies and performance tunning.\nI hope you\u0026rsquo;ll enjoy reading it.\n","date":"August 8, 2008","externalUrl":null,"permalink":"/posts/2008-08-08-activemq-in-action/","section":"Posts","summary":" As Bruce and Rob already said, our current work on “ActiveMQ in Action” book is available in Manning Early Access Program (MEAP).\nWe will try to cover all aspects of ActiveMQ, from basic stuff such as JMS basics and how to run ActiveMQ for the first time to complex broker topologies and performance tunning.\nI hope you’ll enjoy reading it.\n","title":"ActiveMQ in Action","type":"posts"},{"content":" Handling Joins in Ibatis\nMissing from the manual\n(tags: ibatis java)\n","date":"July 21, 2008","externalUrl":null,"permalink":"/posts/2008-07-21-links-for-2008-07-21/","section":"Posts","summary":" Handling Joins in Ibatis\nMissing from the manual\n(tags: ibatis java)\n","title":"links for 2008-07-21","type":"posts"},{"content":"We\u0026rsquo;re proud to present Jettison 1.0.1 release. This is just a bugfix release, while new features (such as new APIs (DOM and SAX) and type converters) are planed for 1.1 release (which is expected soon). Download 1.0.1 from the Download section and refer to the User\u0026rsquo;s Guide for more information.\n","date":"June 9, 2008","externalUrl":null,"permalink":"/posts/2008-06-09-jettison-101-released/","section":"Posts","summary":"We’re proud to present Jettison 1.0.1 release. This is just a bugfix release, while new features (such as new APIs (DOM and SAX) and type converters) are planed for 1.1 release (which is expected soon). Download 1.0.1 from the Download section and refer to the User’s Guide for more information.\n","title":"Jettison 1.0.1 released","type":"posts"},{"content":" Virtualbox VM + Ubuntu\nHave to try this out\n(tags: vm ubuntu)\n","date":"April 10, 2008","externalUrl":null,"permalink":"/posts/2008-04-10-links-for-2008-04-10/","section":"Posts","summary":" Virtualbox VM + Ubuntu\nHave to try this out\n(tags: vm ubuntu)\n","title":"links for 2008-04-10","type":"posts"},{"content":" Java Community News - Sun Releases Beta of Deployment-Focused Java SE 6 Update\nJRE 6 update with Java kernel and better support for desktop integration\n(tags: java update kernel)\n","date":"April 4, 2008","externalUrl":null,"permalink":"/posts/2008-04-04-links-for-2008-04-04/","section":"Posts","summary":" Java Community News - Sun Releases Beta of Deployment-Focused Java SE 6 Update\nJRE 6 update with Java kernel and better support for desktop integration\n(tags: java update kernel)\n","title":"links for 2008-04-04","type":"posts"},{"content":"Dependency management was always one of the crucial Java project management tasks. It\u0026rsquo;s where tools such as Maven and Ivy make all the difference and allow developers to maintain their project dependencies in an easy way. There are two important elements for this to happen:\nCentralized repositories - containing library JARs Metadata - describing those JARs and creating repository structure This is something we have for years thanks to the Maven developers. But if you ever tried to manage dependencies manually in your project, you know how tedious this task can be:\nFind a library you want to include Find out its metadata (groupid, artifactid and version) Put an appropriate XML snippet in your project management definition file I find step number two especially tedious and that\u0026rsquo;s why I\u0026rsquo;ve always thought we need an additional component to make our lives a bit easier. That missing link are \u0026ldquo;indexes\u0026rdquo; that would make repositories easily searchable and provide infrastructure for building useful tools for developers.\nFortunately, there has been some activity in this area lately. First, Eugene Kuleshov wrote about new Maven plugin for Eclipse and general purpose Nexus indexer. If you use Eclipse for the Maven-based project be sure to try this stuff out. It\u0026rsquo;s really refreshing approach to working with your poms (especially a quick search funcionality).\nWhile I was at this, I wanted to see if there were any progress on web sites that offers similar services (which I think is important tool for Java community). mvnrepository.com has some problems with stability (and performances) lately and I was glad to see Xavier Hanin\u0026rsquo;s new project called JavaRepo. It\u0026rsquo;s a promising start, (simple UI and useful info) and could be made into a really useful service. What I would like to see from a service like this is:\nAbility to add additional public repositories (snapshots, etc) and snippets for configuring poms with appropriate repository definition Ability to \u0026ldquo;subscribe\u0026rdquo; to a module and receive new release notifications in news readers (RSS/Atom) Better result sorting (newest revisions first, relevance, etc.) I know all this takes time to brush, but it\u0026rsquo;s great to see things are moving in the right direction.\n","date":"March 31, 2008","externalUrl":null,"permalink":"/posts/2008-03-31-indexing-repositories/","section":"Posts","summary":"Dependency management was always one of the crucial Java project management tasks. It’s where tools such as Maven and Ivy make all the difference and allow developers to maintain their project dependencies in an easy way. There are two important elements for this to happen:\nCentralized repositories - containing library JARs Metadata - describing those JARs and creating repository structure This is something we have for years thanks to the Maven developers. But if you ever tried to manage dependencies manually in your project, you know how tedious this task can be:\n","title":"Indexing repositories","type":"posts"},{"content":" John Resig - Cross-Site XMLHttpRequest\none small step for Firefox, one giant leap for browsers\n(tags: cross-domain ajax firefox)\n","date":"March 18, 2008","externalUrl":null,"permalink":"/posts/2008-03-18-links-for-2008-03-18/","section":"Posts","summary":" John Resig - Cross-Site XMLHttpRequest\none small step for Firefox, one giant leap for browsers\n(tags: cross-domain ajax firefox)\n","title":"links for 2008-03-18","type":"posts"},{"content":" O p t i m i z i n g\nthoughts that just make sense\n(tags: Java optimization)\nProject SAM - Simple Asynchronous Messaging -\nLooks a lot like PHP Stomp client\n(tags: php messaging)\n","date":"February 25, 2008","externalUrl":null,"permalink":"/posts/2008-02-25-links-for-2008-02-25/","section":"Posts","summary":" O p t i m i z i n g\nthoughts that just make sense\n(tags: Java optimization)\nProject SAM - Simple Asynchronous Messaging -\nLooks a lot like PHP Stomp client\n(tags: php messaging)\n","title":"links for 2008-02-25","type":"posts"},{"content":"Enumerated types (enums) are a way to define fixed set of constants, so helpful in many areas of software development. In the most common case, in your Java code written for Java 5 or newer, you will use enums for int constants and replace chunks of code that look like this\npublic static final int DIRECTION_NORTH = 0; public static final int DIRECTION_SOUTH = 1; public static final int DIRECTION_EAST = 2; public static final int DIRECTION_WEST = 3; with something like this\npublic enum Direction { NORTH, SOUTH, EAST, WEST; } Then, you\u0026rsquo;ll change method definitions that look like\npublic void changeDirection(int direction) { // do something } with something like this\npublic void changeDirection(Direction direction) { // do something } And finally, the method call will be changed too, from\nship.changeDirection(DIRECTION_EAST); to\nship.changeDirection(Direction.NORTH); There are a few obvious benefits from using enums over the standard int constants, such as the type safety and namespaces for example.\nBut we can also use enums to define other types of constants, string constants for example. You can often see examples of using enums to make a switch idiom for strings possible in Java. Take a look at the following example\nString direction = \u0026#34;WEST\u0026#34;; switch (Direction.valueOf(direction)) { case WEST : System.out.println(\u0026#34;Go west!\u0026#34;); break; case EAST : System.out.println(\u0026#34;Go east!\u0026#34;); break; default : System.out.println(\u0026#34;Go somewhere!\u0026#34;); } It prints Go west! as a result which is great.\nBut in order to be truly useful for string constants purpose, enums needs some extra tuning and here\u0026rsquo;s why.\nAs the JavaDoc of the valueOf method used above says:\nThe name must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)\nSo if you want your switch work well you need to be sure that you\u0026rsquo;ve passed a string with the value exact to some of the identifiers defined in the enum. So if you change your direction variable value to west, you\u0026rsquo;ll get the following exception\nException in thread \u0026#34;main\u0026#34; java.lang.IllegalArgumentException: No enum const class net.scriptinginjava.test.EnumTest$Direction.west at java.lang.Enum.valueOf(Enum.java:192) at net.scriptinginjava.test.EnumTest$Direction.valueOf(EnumTest.java:1) at net.scriptinginjava.test.EnumTest.main(EnumTest.java:28) which could be tricky in some situations.\nAnother scenario where enums could benefit from extra customization is when you have to have a kind of string mapping between identifiers and their values. Take for example that you want to deal with HTTP headers in this way. You cannot use names like if-modified-since as an enum identifier since it is not a regular Java variable name so some kind of transformation is needed and the question is, what can we do to customize enums?\nAs we have seen earlier enums extend java.lang.Enum class so we can start looking there for enhancements we need. In order to customize represenation of strings in our enum, we need to pay attention to two methods:\ntoString - which prints the value of a constant. By default, this method returns the exact name of the constant identifier, just as the name method. valueOf - which returns a enum value from a string. Unfortunately, this method cannot be overridden so we have to find a workaround for converting custom strings to enum values without using valueOf method. Now, take a look at the following enum declaration\npublic enum HttpHeader { IF_MODIFIED_SINCE, USER_AGENT, UNKNOWN; public String toString() { return name().replaceAll(\u0026#34;_\u0026#34;, \u0026#34;-\u0026#34;).toLowerCase(); } public static HttpHeader getValue(String value) { try { return valueOf(value.replaceAll(\u0026#34;-\u0026#34;, \u0026#34;_\u0026#34;).toUpperCase()); } catch (Exception e) { return UNKNOWN; } } } The first thing to notice is that we defined uppercased values with \u0026ldquo;_\u0026rdquo; char as a word separator. It\u0026rsquo;s kind of a \u0026ldquo;good practice\u0026rdquo; so let it be. Now take a look at the toString method, which replaces _ with - in the name and returns such modified value. So, the following line\nSystem.out.println(HttpHeader.IF_MODIFIED_SINCE); will print if-modified-since value.\nNow let\u0026rsquo;s see how to use the switch statement with this enum. Take a look at this example\nString[] headers = new String[]{\u0026#34;if-modified-since\u0026#34;, \u0026#34;User-Agent\u0026#34;, \u0026#34;test\u0026#34;}; for (String header : headers) { switch (HttpHeader.getValue(header)) { case IF_MODIFIED_SINCE : System.out.println(\u0026#34;if-modified-since header found\u0026#34;); break; case USER_AGENT : System.out.println(\u0026#34;user-agent header found\u0026#34;); break; case UNKNOWN : default : System.out.println(\u0026#34;unkown header found: \u0026#34; + header); } } It will print the following output\nif-modified-since header found user-agent header found unkown header found: test As you can see, this enum has a greater flexibility in matching strings to enum constants. Also, you can note that now we can gracefully fail if the passed string does not match any value. It returns the UNKNOWN value instead of throwing an exception. Of course, whether this is a desirable funcionality depends on your requirements and design.\nIn the previous example, we used a simple transformation in the toString method to customize the value of the printed constant. In case that you have needs for more complex transformation you can apply another technique. Take a look at this example:\npublic enum HttpHeader { IF_MODIFIED_SINCE(\u0026#34;If-Modified-Since\u0026#34;), USER_AGENT(\u0026#34;User-Agent\u0026#34;), UNKNOWN(\u0026#34;\u0026#34;); private String realName; private HttpHeader(String realName) { this.realName = realName; } public String toString() { return realName; } public static HttpHeader getValue(String value) { try { return valueOf(value.replaceAll(\u0026#34;-\u0026#34;, \u0026#34;_\u0026#34;).toUpperCase()); } catch (Exception e) { return UNKNOWN; } } } This enum definition defines a constructor with a string parameter. We can use this parameter to define a string representation of the constant. So now, the code snippet\nSystem.out.println(HttpHeader.IF_MODIFIED_SINCE); will print the following output\nIf-Modified-Since Everything else remains the same as in our previous examples.\nCustomized like this, enums could be used for dealing with string constants, which could be helpful in processing header names (and values) for example.\n","date":"February 11, 2008","externalUrl":null,"permalink":"/posts/2008-02-11-customizing-enums/","section":"Posts","summary":"Enumerated types (enums) are a way to define fixed set of constants, so helpful in many areas of software development. In the most common case, in your Java code written for Java 5 or newer, you will use enums for int constants and replace chunks of code that look like this\npublic static final int DIRECTION_NORTH = 0; public static final int DIRECTION_SOUTH = 1; public static final int DIRECTION_EAST = 2; public static final int DIRECTION_WEST = 3; with something like this\n","title":"Customizing Enums","type":"posts"},{"content":" The year 2038 bug\nwill it ever end?\n(tags: 2038 bug programming)\n","date":"February 8, 2008","externalUrl":null,"permalink":"/posts/2008-02-08-links-for-2008-02-08/","section":"Posts","summary":" The year 2038 bug\nwill it ever end?\n(tags: 2038 bug programming)\n","title":"links for 2008-02-08","type":"posts"},{"content":"For those who can\u0026rsquo;t wait for 1.0 RC3 to be released (with fixed behavior for converting nested lists and maps from XStream), you can download patched snapshot from here\n","date":"February 6, 2008","externalUrl":null,"permalink":"/posts/2008-02-06-jettison-10-rc3-snapshot/","section":"Posts","summary":"For those who can’t wait for 1.0 RC3 to be released (with fixed behavior for converting nested lists and maps from XStream), you can download patched snapshot from here\n","title":"Jettison 1.0 RC3 Snapshot","type":"posts"},{"content":" Jonathan Schwartz\u0026rsquo;s Blog: Helping Dolphins Fly\nsun buys mysql form $1billio\n(tags: sun mysql)\nJava SE 6 Update 4 Release Notes.\na lot of bug fixes\n(tags: java)\n","date":"January 17, 2008","externalUrl":null,"permalink":"/posts/2008-01-17-links-for-2008-01-17/","section":"Posts","summary":" Jonathan Schwartz’s Blog: Helping Dolphins Fly\nsun buys mysql form $1billio\n(tags: sun mysql)\nJava SE 6 Update 4 Release Notes.\na lot of bug fixes\n(tags: java)\n","title":"links for 2008-01-17","type":"posts"},{"content":" How To Install Internet Explorer On Ubuntu (Feisty Fawn, Edgy Eft And Dapper Drake) | HowtoForge - Linux Howtos and Tutorials\ninstalled 2.0.5 on gutsy \u0026hellip; works like a charm\n(tags: ubuntu linux ie)\n","date":"January 9, 2008","externalUrl":null,"permalink":"/posts/2008-01-09-links-for-2008-01-09/","section":"Posts","summary":" How To Install Internet Explorer On Ubuntu (Feisty Fawn, Edgy Eft And Dapper Drake) | HowtoForge - Linux Howtos and Tutorials\ninstalled 2.0.5 on gutsy … works like a charm\n(tags: ubuntu linux ie)\n","title":"links for 2008-01-09","type":"posts"},{"content":" Sam Ruby: WORA\ndjango on jython\n(tags: django jython jvm)\n","date":"January 4, 2008","externalUrl":null,"permalink":"/posts/2008-01-04-links-for-2008-01-04/","section":"Posts","summary":" Sam Ruby: WORA\ndjango on jython\n(tags: django jython jvm)\n","title":"links for 2008-01-04","type":"posts"},{"content":"If you haven\u0026rsquo;t already, be sure to read Steve Yegge\u0026rsquo;s post on his experience of dealing with large code bases (it\u0026rsquo;s a bit long post but an excellent read).\nHe explains the maintenance nightmare of his 500.000 lines of code game written in Java and quite correctly concludes that code size is a crucial problem for big software projects.\nMy minority opinion is that a mountain of code is the worst thing that can befall a person, a team, a company. I believe that code weight wrecks projects and companies, that it forces rewrites after a certain size, and that smart teams will do everything in their power to keep their code base from becoming a mountain. Tools or no tools. That\u0026rsquo;s what I believe.\nI know this seems too much at first, but it\u0026rsquo;s actually quite common for projects that are developed over the few years period. Especially when you have a team that changes team members (even juniors) on regular basis, fast development pace and limited amount of resources for project management (aren\u0026rsquo;t there always?).\nSteve goes then on explaining how, from his point of view, refactoring doesn\u0026rsquo;t help much in this case since it will only enlarge a code base and actually make things even worse. I don\u0026rsquo;t see it that way, since a better organized code is definitely more readable and easier to maintain. The other problem I often see with refactoring is team\u0026rsquo;s reluctance to perform them for two reasons: laziness and fear. Both of these are psychological and related with \u0026ldquo;if ain\u0026rsquo;t broken don\u0026rsquo;t fix it\u0026rdquo; approach. So the team see the part of the system as \u0026ldquo;not ideal\u0026rdquo; but working and usually dedicates resources to \u0026ldquo;new features\u0026rdquo; and customer demands.\nThe \u0026ldquo;fear\u0026rdquo; part means that people (in general) are not eager to take responsibility for doing risky modifications which can possibly break the whole system. I find this especially hard in cases when modifications include data layer (database schemes) and a huge amount of \u0026ldquo;live\u0026rdquo; data. This kind of \u0026ldquo;refactoring\u0026rdquo; impose a big risk on the current system, since you have one chance to do it right, it can be very time consuming and if something goes wrong it\u0026rsquo;s hard to go back (if it is possible at all). Badly designed database schemes tend to live in systems for the long time, so be sure to put an extra effort trying to make them as good as possible in the first place.\nIn the end, Steve decided to reimplement the whole application using Rhino (JavaScript for the JVM) and try to keep the code base under the 200.000 lines of code (which is by some theories an upper boundary of how much one developer can handle).\nSo taking for granted today that VMs are \u0026ldquo;good\u0026rdquo;, and acknowledging that my game is pretty heavily tied to the JVM - not just for the extensive libraries and monitoring tools, but also for more subtle architectural decisions like the threading and memory models - the rational answer to code bloat is to use another JVM language.\nOne nice thing about JVM languages is that Java programmers can learn them pretty fast, because you get all the libraries, monitoring tools and architectural decisions for free.\nWhile I agree that JVM languages are one of the greatest advantages of JVM as a development platform, I would take Ola Bini\u0026rsquo;s side on this matter, who says in his post\nNow, if I would have tackled the same problem, I would never reimplement the whole application in Rhino - rather, it would be more interesting to try to find the obvious place where the system needs to be dynamic and split it there, keep those parts in Java and then implement the new functionality on top of the stable Java layer.\nThat\u0026rsquo;s exactly why I think dynamic languages and frameworks (APIs) for their integration in Java should be an important tool in every developer\u0026rsquo;s tool box. There are places in your application where both programming approaches makes more sense over the other and the possibility to combine them to make a better architecture of your project can only be a good thing. And of course, it would improve maintainability of your projects as well, both in code size and ability to make appropriate refactoring and improvements while you go.\n","date":"January 2, 2008","externalUrl":null,"permalink":"/posts/2008-01-02-dealing-with-large-code-bases/","section":"Posts","summary":"If you haven’t already, be sure to read Steve Yegge’s post on his experience of dealing with large code bases (it’s a bit long post but an excellent read).\nHe explains the maintenance nightmare of his 500.000 lines of code game written in Java and quite correctly concludes that code size is a crucial problem for big software projects.\nMy minority opinion is that a mountain of code is the worst thing that can befall a person, a team, a company. I believe that code weight wrecks projects and companies, that it forces rewrites after a certain size, and that smart teams will do everything in their power to keep their code base from becoming a mountain. Tools or no tools. That’s what I believe.\n","title":"Dealing with large code bases","type":"posts"},{"content":"If you ever wanted to use Stomp messaging protocol with secured ActiveMQ broker, you can now do it by downloading a 5.1 snapshot distribution. For more Stomp messaging security over unsecured networks you can additionally use Stomp over SSL, which makes Stomp + ActiveMQ perfectly secure messaging environment over unsecured networks. If PHP is your environment of choice, the PHP Stomp client implements these security mechanisms completely (including SSL connectivity).\nHappy Holidays.\n","date":"December 25, 2007","externalUrl":null,"permalink":"/posts/2007-12-25-securing-stomp/","section":"Posts","summary":"If you ever wanted to use Stomp messaging protocol with secured ActiveMQ broker, you can now do it by downloading a 5.1 snapshot distribution. For more Stomp messaging security over unsecured networks you can additionally use Stomp over SSL, which makes Stomp + ActiveMQ perfectly secure messaging environment over unsecured networks. If PHP is your environment of choice, the PHP Stomp client implements these security mechanisms completely (including SSL connectivity).\nHappy Holidays.\n","title":"Securing Stomp","type":"posts"},{"content":" Andreas Sterbenz\u0026rsquo;s Blog : Weblog\nuseful utility class/application for adding server ssl certificates to keystores\n(tags: java ssl jsse)\n","date":"December 17, 2007","externalUrl":null,"permalink":"/posts/2007-12-17-links-for-2007-12-17/","section":"Posts","summary":" Andreas Sterbenz’s Blog : Weblog\nuseful utility class/application for adding server ssl certificates to keystores\n(tags: java ssl jsse)\n","title":"links for 2007-12-17","type":"posts"},{"content":" GNOME Do\nquick-launcher for gnome\n(tags: gnome launcher ubuntu)\nxo-laptop: On the Open-Sourcing of Business « The Wayward Word Press\nbusiness side of open source\n(tags: opensource business)\n","date":"December 7, 2007","externalUrl":null,"permalink":"/posts/2007-12-07-links-for-2007-12-07/","section":"Posts","summary":" GNOME Do\nquick-launcher for gnome\n(tags: gnome launcher ubuntu)\nxo-laptop: On the Open-Sourcing of Business « The Wayward Word Press\nbusiness side of open source\n(tags: opensource business)\n","title":"links for 2007-12-07","type":"posts"},{"content":"There\u0026rsquo;s a quite interesting discussion in the blogosphere about proposed extension methods feature for Java 7. The problem tackled by this proposal is how to extend an API (interface) with new methods without breaking existing implementations. The example used in a discussion is a List interface and the sort() method. In order to add another method to the existing interface, Java developers today create static utility functions. Take for example the java.util.Collections class, which is a set of static helper methods for working with collections. Among them is of course the aforementioned sort method. Here\u0026rsquo;s a simple example:\npublic class Extension { public static void main(String[] args) { ArrayList list = new ArrayList() ; list.add(\u0026#34;123\u0026#34;); list.add(\u0026#34;678\u0026#34;); list.add(\u0026#34;456\u0026#34;); java.util.Collections.sort(list); System.out.println(list); } } Here we have defined a list and used static sort method of the java.util.Collections class to sort it. As a result we get the following output\n[123, 456, 678] Since Java 5, we are able to do static imports so we can do this in a bit more elegant way. The previous example can be rewritten as follows\nimport static java.util.Collections.sort; public class Extension { public static void main(String[] args) { ArrayList list = new ArrayList() ; list.add(\u0026#34;123\u0026#34;); list.add(\u0026#34;678\u0026#34;); list.add(\u0026#34;456\u0026#34;); sort(list); System.out.println (list); } } There are many things about static import feature that are declared as \u0026ldquo;controversial\u0026rdquo; by developers, such as shadowing of imports by locally defined static methods and importing more then one static method with the same name (look at this post by David Flanagan for more info).\nThe idea of \u0026ldquo;extension methods\u0026rdquo; for Java 7 is based on static imports and it adds another \u0026ldquo;feature\u0026rdquo; for such methods. It all started with the initial Neal Gafter\u0026rsquo;s proposal. The proposal is to enable usage of statically imported functions as methods of the original interface. So instead of\nsort(list) we can use it in a more natural way\nlist.sort() Some of the potential problems of this use-site extension methods approach as called and spotted by Peter Ahe are the same as with ordinary statically imported methods. Additionally, it transparently enables end users to extend final classes which could be one more source of bugs in the applications.\nThat\u0026rsquo;s why he proposes the declaration-site extension methods mechanism which means that API developer must specifically mark methods that could be extended in this way. For example\nvoid sort() import static java.util.Collections.sort; Stephen Colebourne joined the discussion arguing that Peter\u0026rsquo;s approach prevents users to extend the API which is probably the most important usage of this mechanism.\nHe proposed usage of the special syntax for using extension methods, such as\nlist.do.sort(); or\nlist-\u0026gt;sort(); and that is probably better to annotate methods we want to be extensible (if we must) since it will give more flexibility over Peter\u0026rsquo;s approach, such as\n@ExtensionMethod public void sort(List list) { ...} But this mechanism changes the language syntax, which is probably something Neal wanted to avoid in the first place.\nFinally, there are mechanisms that other languages use for this kind of tasks (but of course require language syntax change). For example, in Groovy you can use Categories to do this. Take a look at this example.\nclass EnhancedInteger { static boolean greaterThanAll(Integer self, Object[] others) { greaterThanAll(self, others) } static boolean greaterThanAll(Integer self, others) { others.every{ self \u0026gt; it } } } use(EnhancedInteger) { assert 4.greaterThanAll(1, 2, 3) assert !5.greaterThanAll(2, 4, 6) assert 5.greaterThanAll(-4..4) assert 5.greaterThanAll([]) assert !5.greaterThanAll([4, 5]) } In any case I think this is an important topic (which is something you can see by the number of comments found on aforementioned blog posts) and it is important to find a balance between the feature and how it will affect the syntax. I think it will all end up with Neal\u0026rsquo;s original proposal with note to developers \u0026ldquo;use with care\u0026rdquo;. But one thing is certain, it is great to see this kind of topics discussed in blogosphere this early in the process. What\u0026rsquo;s your take on this?\n","date":"December 5, 2007","externalUrl":null,"permalink":"/posts/2007-12-05-extension-methods-proposals/","section":"Posts","summary":"There’s a quite interesting discussion in the blogosphere about proposed extension methods feature for Java 7. The problem tackled by this proposal is how to extend an API (interface) with new methods without breaking existing implementations. The example used in a discussion is a List interface and the sort() method. In order to add another method to the existing interface, Java developers today create static utility functions. Take for example the java.util.Collections class, which is a set of static helper methods for working with collections. Among them is of course the aforementioned sort method. Here’s a simple example:\n","title":"Extension methods proposals","type":"posts"},{"content":" Programming less (Scripting News)\nThe design of the central data structure of an app determines the quality of the app, in every way.\n(tags: complexity development software)\nOpen Flash Chart -\nBeautiful flash chart library\n(tags: flash graph opensource charts)\n","date":"November 29, 2007","externalUrl":null,"permalink":"/posts/2007-11-29-links-for-2007-11-29/","section":"Posts","summary":" Programming less (Scripting News)\nThe design of the central data structure of an app determines the quality of the app, in every way.\n(tags: complexity development software)\nOpen Flash Chart -\nBeautiful flash chart library\n(tags: flash graph opensource charts)\n","title":"links for 2007-11-29","type":"posts"},{"content":"","date":"November 27, 2007","externalUrl":null,"permalink":"/categories/devops/","section":"Categories","summary":"","title":"DevOps","type":"categories"},{"content":"I\u0026rsquo;ve started looking how to enable both PHP4 and PHP5 on our (relatively) new dev box running Gentoo. The box is already running PHP4 so the task was to add PHP5 support as well.\nThe official guide is rich in options you can use to achieve this. I didn\u0026rsquo;t want any CGI since we use PHP vhost configurations extensively and I didn\u0026rsquo;t want to deal with suPHP as well. Since it is a dev box, it is totally OK to have two instances with similar configurations running on two different ports. Unfortunately, it is the part of the official docs that is not as complete as other parts and not working as advertised. So, here\u0026rsquo;s a mental note (for me) and perhaps a few hour saver for others.\nFirst of all, just copy /etc/init.d/apache2 to /etc/init.d/apache2-php5. There\u0026rsquo;s no need to change anything in this file\n$ diff /etc/init.d/apache2 /etc/init.d/apache2-php5 $ since it will look to /etc/conf.d/apache2-php5 for default configuration and that is where we will make our changes. So, copy /etc/conf.d/apache2 to /etc/conf.d/apache2-php5\nHere\u0026rsquo;s a list of changes that works for me\n$ diff /etc/conf.d/apache2 /etc/conf.d/apache2-php5 1c1 \u0026lt; # /etc/conf.d/apache2: config file for /etc/init.d/apache2 --- \u0026gt; # /etc/conf.d/apache2-php5: config file for /etc/init.d/apache2-php5 20c20 \u0026lt; APACHE2_OPTS=\u0026#34;-D DEFAULT_VHOST -D PHP4\u0026#34; --- \u0026gt; APACHE2_OPTS=\u0026#34;-D DEFAULT_VHOST -D PHP5\u0026#34; 34c34 \u0026lt; #CONFIGFILE=/etc/apache2/httpd.conf --- \u0026gt; CONFIGFILE=/etc/apache2/httpd-php5.conf Basically, it uses PHP 5 and points to other httpd.conf file. So the next step is to copy /etc/apache2/httpd.conf to /etc/apache2/httpd-php5.conf and make some changes (port numbers, files used, etc). Here\u0026rsquo;s an example\n$ diff /etc/apache2/httpd.conf /etc/apache2/httpd-php5.conf 88c88 \u0026lt; PidFile \u0026#34;/var/run/apache2.pid\u0026#34; --- \u0026gt; PidFile \u0026#34;/var/run/apache2-php5.pid\u0026#34; 214c213 \u0026lt; Listen 80 --- \u0026gt; Listen 8000 587c586 \u0026lt; ErrorLog logs/error_log --- \u0026gt; ErrorLog logs/error-php5_log 617c616 \u0026lt; CustomLog logs/access_log common --- \u0026gt; CustomLog logs/access-php5_log common Finally, you\u0026rsquo;ll have to modify your existing virtual host configurations to include a conf for the new port (8000 in this case). So for the default vhost configuration located in /etc/apache2/vhosts.d/00_default_vhost.conf you should add this line\nNameVirtualHost *:8000 and make another copy of default configuration of port 80\n\u0026lt;VirtualHost *:80\u0026gt; \u0026lt;/VirtualHost\u0026gt; for port 8000\n\u0026lt;VirtualHost *:8000\u0026gt; \u0026lt;/VirtualHost\u0026gt; Start these two Apache instances\n/etc/init.d/apache2 start /etc/init.d/apache2-php5 start and that\u0026rsquo;s all folks!\n","date":"November 27, 2007","externalUrl":null,"permalink":"/posts/2007-11-27-multiple-apache-instances-on-gentoo-box/","section":"Posts","summary":"I’ve started looking how to enable both PHP4 and PHP5 on our (relatively) new dev box running Gentoo. The box is already running PHP4 so the task was to add PHP5 support as well.\nThe official guide is rich in options you can use to achieve this. I didn’t want any CGI since we use PHP vhost configurations extensively and I didn’t want to deal with suPHP as well. Since it is a dev box, it is totally OK to have two instances with similar configurations running on two different ports. Unfortunately, it is the part of the official docs that is not as complete as other parts and not working as advertised. So, here’s a mental note (for me) and perhaps a few hour saver for others.\n","title":"Multiple Apache instances on Gentoo box","type":"posts"},{"content":"I\u0026rsquo;ve always loved Groovy builders concept for handling (mostly creating) hierarchical documents. On the other hand I find StAX, pull-based processing API, to be one of my favorite methods for dealing with simple XML processing. It\u0026rsquo;s simple and fast, so what more can I ask for? Additionally, thanks to the Jettison project you can also use the StAX API to handle JSON documents. So, basically we can use one simple (standard) API to handle both XML and JSON documents in the same manner. The next logical step is to merge these two great pieces of technology into one.\nMeet the StaxBuilder, a Groovy builder that uses StAX API to create documents. You can currently find it here, but I hope it will find a more appropriate place soon (Groovy code base, for example).\nAnyway, here are a few examples that demonstrate how to build XML and JSON documents using this builder (taken from test cases).\nCreating XML using Woodstox # WstxOutputFactory factory = new WstxOutputFactory() StringWriter writer = new StringWriter() StaxBuilder builder = new StaxBuilder( factory.createXMLStreamWriter(writer) ) builder.root1(a:5, b:7) { elem1(\u0026#39;hello1\u0026#39;) elem2(\u0026#39;hello2\u0026#39;) elem3(x:7) } assert writer, \u0026#34;\u0026#34;\u0026#34;\u0026lt;root1 a=\u0026#34;5\u0026#34; b=\u0026#34;7\u0026#34;\u0026gt; \u0026lt;elem1\u0026gt;hello1\u0026lt;/elem1\u0026gt; \u0026lt;elem2\u0026gt;hello2\u0026lt;/elem2\u0026gt; \u0026lt;elem3 x=\u0026#34;7\u0026#34; /\u0026gt; \u0026lt;/root1\u0026gt;\u0026#34;\u0026#34;\u0026#34; Creating JSON using Jettison # MappedNamespaceConvention con = new MappedNamespaceConvention(); StringWriter writer = new StringWriter() MappedXMLStreamWriter mappedWriter = new MappedXMLStreamWriter(con, writer); StaxBuilder builder = new StaxBuilder(mappedWriter) builder.root1(a:5, b:7) { elem1(\u0026#39;hello1\u0026#39;) elem2(\u0026#39;hello2\u0026#39;) elem3(x:7) } assert writer, \u0026#34;\u0026#34;\u0026#34;{\u0026#34;root1\u0026#34;:{\u0026#34;@a\u0026#34;:\u0026#34;5\u0026#34;,\u0026#34;@b\u0026#34;:\u0026#34;7\u0026#34;, \u0026#34;elem1\u0026#34;:\u0026#34;hello1\u0026#34;, \u0026#34;elem2\u0026#34;:\u0026#34;hello2\u0026#34;, \u0026#34;elem3\u0026#34;:{\u0026#34;@x\u0026#34;:\u0026#34;7\u0026#34;} }}\u0026#34;\u0026#34;\u0026#34; ","date":"November 26, 2007","externalUrl":null,"permalink":"/posts/2007-11-26-groovy-stax-builder/","section":"Posts","summary":"I’ve always loved Groovy builders concept for handling (mostly creating) hierarchical documents. On the other hand I find StAX, pull-based processing API, to be one of my favorite methods for dealing with simple XML processing. It’s simple and fast, so what more can I ask for? Additionally, thanks to the Jettison project you can also use the StAX API to handle JSON documents. So, basically we can use one simple (standard) API to handle both XML and JSON documents in the same manner. The next logical step is to merge these two great pieces of technology into one.\n","title":"Groovy StAX builder","type":"posts"},{"content":" Ctrl-Shift-B: Interactive Application Architecture Patterns\narticle discussing/comparing MVC and a few similar design patterns\n(tags: Patterns programming architecture)\n","date":"November 26, 2007","externalUrl":null,"permalink":"/posts/2007-11-26-links-for-2007-11-26/","section":"Posts","summary":" Ctrl-Shift-B: Interactive Application Architecture Patterns\narticle discussing/comparing MVC and a few similar design patterns\n(tags: Patterns programming architecture)\n","title":"links for 2007-11-26","type":"posts"},{"content":" Zdot » Blog Archive » Building a Megajar with Maven2 - The Right Way\nUse assembly plugin to create uberjar\n(tags: maven2 uberjar assembly)\n","date":"November 20, 2007","externalUrl":null,"permalink":"/posts/2007-11-20-links-for-2007-11-20/","section":"Posts","summary":" Zdot » Blog Archive » Building a Megajar with Maven2 - The Right Way\nUse assembly plugin to create uberjar\n(tags: maven2 uberjar assembly)\n","title":"links for 2007-11-20","type":"posts"},{"content":"It all started when I tried to find a solution for customizing an XStream instance for my ActiveMQ XStream message transformer that would be better than currently used (extending a base transformer and providing a custom factory method that will do things like alias, converter, annotation, etc. settings). I wanted an easy solution to configure XStream instance in a Spring xml configuration file used in my application and provide that instance to all beans that need it (message transformer among others).\nXStream is a very nice library that I\u0026rsquo;ve used and written about before, but there is no Spring factory builder that could be used for this purpose. A little googling got me to the OXM framework, a part of Spring WS project.\nThe main purpose of this library is to provide a layer above various Object/XML mapping frameworks, such as Castor, Jaxb, XStream, etc. It contains two main abstractions, Marshaller and Unmarshaller wrapping these basic two operations found in appropriate frameworks. For the context objects, this framework use standard classes located in the javax.xml.transform package, so you can work with Stream, Sax and DOM sources and results. Also, it is distributed in two JARs, one that is fully JDK1.4 compatible and one that adds extra features for JDK5 where it is appropriate, which is very nice.\nNow back to the XStream and some examples. First of all, in order to use this library you must have the appropriate version of spring-oxm jar file in your classpath. You can achieve this, for example, by adding the following dependency in your pom.xml\n\u0026lt;dependency\u0026gt; \u0026lt;groupId\u0026gt;org.springframework.ws\u0026lt;/groupId\u0026gt; \u0026lt;artifactId\u0026gt;spring-oxm\u0026lt;/artifactId\u0026gt; \u0026lt;version\u0026gt;1.0.2\u0026lt;/version\u0026gt; \u0026lt;/dependency\u0026gt; Now, we can make our Spring definition of the OXM marshaller\n\u0026lt;bean id=\u0026#34;plainMarshaller\u0026#34; class=\u0026#34;org.springframework.oxm.xstream.XStreamMarshaller\u0026#34;/\u0026gt; After the application initialization we have a plainMarshaller bean ready to use\nXStreamMarshaller marshaller = (XStreamMarshaller)context.getBean(\u0026#34;plainMarshaller\u0026#34;); JobDetails job = createJob(); StringResult result = new StringResult(); marshaller.marshal(job, result); System.out.println(result.toString()); which should marshall and print my JobDetails class to standard output. So, the following output is expected\n\u0026lt;org.sensatic.jqr.jobs.JobDetails\u0026gt; \u0026lt;group\u0026gt;testGroup\u0026lt;/group\u0026gt; \u0026lt;name\u0026gt;testJob\u0026lt;/name\u0026gt; \u0026lt;params\u0026gt; \u0026lt;map\u0026gt; \u0026lt;entry\u0026gt; \u0026lt;string\u0026gt;password\u0026lt;/string\u0026gt; \u0026lt;string\u0026gt;test\u0026lt;/string\u0026gt; \u0026lt;/entry\u0026gt; \u0026lt;entry\u0026gt; \u0026lt;string\u0026gt;username\u0026lt;/string\u0026gt; \u0026lt;string\u0026gt;dejanb\u0026lt;/string\u0026gt; \u0026lt;/entry\u0026gt; \u0026lt;/map\u0026gt; \u0026lt;/params\u0026gt; \u0026lt;/org.sensatic.jqr.jobs.JobDetails\u0026gt; Now let\u0026rsquo;s add some aliases and converters\n\u0026lt;bean id=\u0026#34;configuredMarshaller\u0026#34; class=\u0026#34;org.springframework.oxm.xstream.XStreamMarshaller\u0026#34;\u0026gt; \u0026lt;property name=\u0026#34;aliases\u0026#34;\u0026gt; \u0026lt;props\u0026gt; \u0026lt;prop key=\u0026#34;job\u0026#34;\u0026gt;org.sensatic.jqr.jobs.JobDetails\u0026lt;/prop\u0026gt; \u0026lt;/props\u0026gt; \u0026lt;/property\u0026gt; \u0026lt;property name=\u0026#34;converters\u0026#34;\u0026gt; \u0026lt;list\u0026gt; \u0026lt;bean class=\u0026#34;org.sensatic.jqr.jobs.ParamsConverter\u0026#34;/\u0026gt; \u0026lt;/list\u0026gt; \u0026lt;/property\u0026gt; \u0026lt;/bean\u0026gt; Yes, it is really as easy as that. If we now use a marshaller set like this, it will produce the following result\n\u0026lt;job\u0026gt; \u0026lt;group\u0026gt;testGroup\u0026lt;/group\u0026gt; \u0026lt;name\u0026gt;testJob\u0026lt;/name\u0026gt; \u0026lt;params\u0026gt;\u0026lt;password\u0026gt;test\u0026lt;/password\u0026gt;\u0026lt;username\u0026gt;dejanb\u0026lt;/username\u0026gt;\u0026lt;/params\u0026gt; \u0026lt;/job\u0026gt; As you probably know, XStream can use annotations to set aliases and converters for classes. To demonstrate this we will of course need the additional JAR that provides JDK5 (Tiger) funcionality to the XStream marshaller. For that just add the following dependency to your pom.xml file (it will include the base file as well), or just provide this additional JAR to your classpath.\n\u0026lt;dependency\u0026gt; \u0026lt;groupId\u0026gt;org.springframework.ws\u0026lt;/groupId\u0026gt; \u0026lt;artifactId\u0026gt;spring-oxm-tiger\u0026lt;/artifactId\u0026gt; \u0026lt;version\u0026gt;1.0.2\u0026lt;/version\u0026gt; \u0026lt;/dependency\u0026gt; So, instead of defining the aliases and converters manually, we can just point to the classes that are properly annotated. In this case, we have to use AnnotationXStreamMarshaller class\n\u0026lt;bean id=\u0026#34;annotatedMarshaller\u0026#34; class=\u0026#34;org.springframework.oxm.xstream.AnnotationXStreamMarshaller\u0026#34;\u0026gt; \u0026lt;property name=\u0026#34;annotatedClasses\u0026#34;\u0026gt; \u0026lt;list\u0026gt; \u0026lt;value\u0026gt;org.sensatic.jqr.jobs.JobDetails\u0026lt;/value\u0026gt; \u0026lt;/list\u0026gt; \u0026lt;/property\u0026gt; \u0026lt;/bean\u0026gt; and the final result should be the same as the previously generated one (of course in case we annotated our class properly).\nNow, the real beauty of this is that OXM\u0026rsquo;s XStreamMarshaller is that it could be used as XStream bean factory (until some better solution comes along). For this to happen, we first have to define a factory bean like this.\n\u0026lt;bean id=\u0026#34;XStream\u0026#34; factory-bean=\u0026#34;annotatedMarshaller\u0026#34; factory-method=\u0026#34;getXStream\u0026#34;/\u0026gt; Then we can use this to set properly configured XStream instance in any other bean (message transformer for example)\n\u0026lt;bean id=\u0026#34;messageTransformer\u0026#34; class=\u0026#34;org.apache.activemq.util.xstream.XStreamMessageTransformer\u0026#34;\u0026gt; \u0026lt;property name=\u0026#34;XStream\u0026#34;\u0026gt;\u0026lt;ref bean=\u0026#34;XStream\u0026#34;/\u0026gt;\u0026lt;/property\u0026gt; \u0026lt;/bean\u0026gt; For the end, here\u0026rsquo;re a couple of things that could be very helpful if happened in the future:\nXStream should get the proper spring bean factory (which could be used in OXM as well)\nOXM\u0026rsquo;s XStreamMarshaller currently can not be set to use specified HiearachicalStreamDriver to be used with streams. For example set the following property on marshaller\n\u0026lt;property name=\u0026#34;streamDriver\u0026#34;\u0026gt; \u0026lt;bean class=\u0026#34;com.thoughtworks.xstream.io.json.JsonHierarchicalStreamDriver\u0026#34;\u0026gt; \u0026lt;/bean\u0026gt; \u0026lt;/property\u0026gt; to use JSON instead of XML. The patch is provided and I hope it will be availabe in future versions of OXM.\nEven with this patch, the XStream instance created by OXM does not have appropriate driver set (and will not be used by other beans where it is injected). Instead the (un)marshaller use it in appropriate methods. This is because of how XStream deals with this property (it could be set only in constructor) so I guess a bit of tweaking on both sides would be required (I guess it could be also sovled through additional constructor in the marshaller, but the universal Spring configuration mechanism would solve this perfectly)\nAs for the ActiveMQ and transforming messages between XML and Objects:\nThe XStreamMessageTransformer could be modified to work with custom HierarchicalStreamDriver, until we are able to provide fully configured XStream instance completely configured through Spring XML.\nOXMMessageTransformer would be great stuff to have, as it would provide more flexibility to people who needs it.\nI hope I\u0026rsquo;ll have these two finished real soon.\nFinally, take a look at the following two posts from Arjen on the topic\nThoughts on Web Services, part 5: To serialize or not to serialize\nSpring Web Services: Object-XML Mapping\n","date":"November 16, 2007","externalUrl":null,"permalink":"/posts/2007-11-16-xstream-and-spring-oxm-objectxml-mapping-framework/","section":"Posts","summary":"It all started when I tried to find a solution for customizing an XStream instance for my ActiveMQ XStream message transformer that would be better than currently used (extending a base transformer and providing a custom factory method that will do things like alias, converter, annotation, etc. settings). I wanted an easy solution to configure XStream instance in a Spring xml configuration file used in my application and provide that instance to all beans that need it (message transformer among others).\n","title":"XStream and Spring OXM (Object/XML Mapping framework)","type":"posts"},{"content":"I had some really great time in Dublin at IJTC last week. Good people, good sessions and a lot of fun; what else could one expect?\nThere were a few sessions that covered projects that I\u0026rsquo;ve had on my radar for some time but never found time to look closer, such as Apache Camel and Spring Batch. Also, it\u0026rsquo;s always good to hear about good ol\u0026rsquo; stuff (and what\u0026rsquo;s new about them), so sessions about Spring 2.5, ActiveMQ, Groovy \u0026amp; Grails were well appreciated.\nHere are some pictures of Dublin.\nI\u0026rsquo;m surely sad I\u0026rsquo;ve missed Bill de Hora since I enjoy reading his blog for quite some time, but that\u0026rsquo;s life.\nThe final note to conference organizers; thanks guys for putting all this together.\n","date":"November 12, 2007","externalUrl":null,"permalink":"/posts/2007-11-12-ijtc-wrap-up/","section":"Posts","summary":"I had some really great time in Dublin at IJTC last week. Good people, good sessions and a lot of fun; what else could one expect?\nThere were a few sessions that covered projects that I’ve had on my radar for some time but never found time to look closer, such as Apache Camel and Spring Batch. Also, it’s always good to hear about good ol’ stuff (and what’s new about them), so sessions about Spring 2.5, ActiveMQ, Groovy \u0026 Grails were well appreciated.\n","title":"IJTC Wrap up","type":"posts"},{"content":"Tomorrow, on Wednesday 7th, there will be a panel at IJTC with Joel Spolsky and James Strachan discussing the future of Java. It sounds very compiling to me and I hope to meet you there.\n","date":"November 6, 2007","externalUrl":null,"permalink":"/posts/2007-11-06-future-of-java/","section":"Posts","summary":"Tomorrow, on Wednesday 7th, there will be a panel at IJTC with Joel Spolsky and James Strachan discussing the future of Java. It sounds very compiling to me and I hope to meet you there.\n","title":"Future of Java","type":"posts"},{"content":"I was migrating a CVS repository from one server to another today and ran on the interesting issue. I was getting a \u0026ldquo;Permission denied\u0026rdquo; error on the CVSROOT/config file no matter what privileges were set. It turns out that problem is with SELinux on CentOS, so the easiest solution is to just turn it off.\n/usr/sbin/setenforce 0\nIf you want to be sure that it will be turned off after the server restart, just edit the /etc/sysconfig/selinux file and set SELINUX to permissive\n","date":"November 2, 2007","externalUrl":null,"permalink":"/posts/2007-11-02-cvs-centos-and-selinux/","section":"Posts","summary":"I was migrating a CVS repository from one server to another today and ran on the interesting issue. I was getting a “Permission denied” error on the CVSROOT/config file no matter what privileges were set. It turns out that problem is with SELinux on CentOS, so the easiest solution is to just turn it off.\n/usr/sbin/setenforce 0\nIf you want to be sure that it will be turned off after the server restart, just edit the /etc/sysconfig/selinux file and set SELINUX to permissive\n","title":"CVS, CentOS and SELinux","type":"posts"},{"content":" Move or migrate user accounts from old Linux server to a new Linux server\nnice checklist for migrating linux servers - just copy/paste commands and you\u0026rsquo;re done\n(tags: linux migration sysadmin server)\n","date":"November 1, 2007","externalUrl":null,"permalink":"/posts/2007-11-01-links-for-2007-11-01/","section":"Posts","summary":" Move or migrate user accounts from old Linux server to a new Linux server\nnice checklist for migrating linux servers - just copy/paste commands and you’re done\n(tags: linux migration sysadmin server)\n","title":"links for 2007-11-01","type":"posts"},{"content":" Mozilla Labs Blog » Blog Archive » Prism\nthank you!\n(tags: mozilla web applications)\n","date":"October 26, 2007","externalUrl":null,"permalink":"/posts/2007-10-26-links-for-2007-10-26/","section":"Posts","summary":" Mozilla Labs Blog » Blog Archive » Prism\nthank you!\n(tags: mozilla web applications)\n","title":"links for 2007-10-26","type":"posts"},{"content":"I will be speaking on Scripting with balance at Irish Java Technology Conference in Dublin (IJTC) on November 9th, 2007. The full announcement could be found here\n","date":"October 24, 2007","externalUrl":null,"permalink":"/posts/2007-10-24-ijtc-session/","section":"Posts","summary":"I will be speaking on Scripting with balance at Irish Java Technology Conference in Dublin (IJTC) on November 9th, 2007. The full announcement could be found here\n","title":"IJTC Session","type":"posts"},{"content":" Migrating data centers with zero downtime on Dion Almaer\u0026rsquo;s Blog\noften forgotten knowledge of web application migration\n(tags: web application migration)\nInfoQ: Read/Write Splitting with MySQL-Proxy\nvery nice stuff\n(tags: database mysql)\n","date":"October 18, 2007","externalUrl":null,"permalink":"/posts/2007-10-18-links-for-2007-10-18/","section":"Posts","summary":" Migrating data centers with zero downtime on Dion Almaer’s Blog\noften forgotten knowledge of web application migration\n(tags: web application migration)\nInfoQ: Read/Write Splitting with MySQL-Proxy\nvery nice stuff\n(tags: database mysql)\n","title":"links for 2007-10-18","type":"posts"},{"content":"OpenJDK community has a new project, Multi-Language VM (or just mlvm). It is announced by John Rose, from Sun, on the announcement list. The focus of the project will be to prototype JVM features beneficial for dynamic languages and remove \u0026ldquo;pain points\u0026rdquo; that current dynamic language developers have with standard JVM.\nHere\u0026rsquo;s the snippet from the announcement:\nThis project will be open for prototyping JVM features aimed at efficiently supporting languages other than Java.\nThe emphasis will be on completing the existing bytecode and execution architecture with general purpose extensions, as opposed to a new feature for just one language, or adjoining an unrelated new execution model.\nThe emphasis will also be on work which removes \u0026ldquo;pain points\u0026rdquo; already observed by implementors of successful or influential languages, as opposed to more speculative work on unproven features or niche languages.\nIt is definitely a step in the right direction for making Java a true multi-language development platform.\n","date":"October 17, 2007","externalUrl":null,"permalink":"/posts/2007-10-17-multi-language-vm/","section":"Posts","summary":"OpenJDK community has a new project, Multi-Language VM (or just mlvm). It is announced by John Rose, from Sun, on the announcement list. The focus of the project will be to prototype JVM features beneficial for dynamic languages and remove “pain points” that current dynamic language developers have with standard JVM.\nHere’s the snippet from the announcement:\nThis project will be open for prototyping JVM features aimed at efficiently supporting languages other than Java.\n","title":"Multi-Language VM","type":"posts"},{"content":" Software Is Hard\nthe title says it all\n(tags: software development complexity)\n","date":"October 6, 2007","externalUrl":null,"permalink":"/posts/2007-10-06-links-for-2007-10-06/","section":"Posts","summary":" Software Is Hard\nthe title says it all\n(tags: software development complexity)\n","title":"links for 2007-10-06","type":"posts"},{"content":" Monitor and diagnose performance in Java SE 6\nJava SE 6 Monitoring and management enhancements\n(tags: Java jmx)\nWelcome to ntop.org\nnetwork monitoring tool\n(tags: network monitoring)\n","date":"September 26, 2007","externalUrl":null,"permalink":"/posts/2007-09-26-links-for-2007-09-26/","section":"Posts","summary":" Monitor and diagnose performance in Java SE 6\nJava SE 6 Monitoring and management enhancements\n(tags: Java jmx)\nWelcome to ntop.org\nnetwork monitoring tool\n(tags: network monitoring)\n","title":"links for 2007-09-26","type":"posts"},{"content":"java.net has published an article titled Scripting with Balance in Design and Performance\n","date":"September 21, 2007","externalUrl":null,"permalink":"/posts/2007-09-21-scripting-with-balance-in-design-and-performance/","section":"Posts","summary":"java.net has published an article titled Scripting with Balance in Design and Performance\n","title":"Scripting with Balance in Design and Performance","type":"posts"},{"content":"I will be speaking on Scripting in Java in Novi Sad on September 19th, 2007. The full announcement could be found here (in Serbian)\n","date":"September 18, 2007","externalUrl":null,"permalink":"/posts/2007-09-18-jug-ns-session-2/","section":"Posts","summary":"I will be speaking on Scripting in Java in Novi Sad on September 19th, 2007. The full announcement could be found here (in Serbian)\n","title":"JUG-NS session","type":"posts"},{"content":" Jayasoft Community Site - Ivy\nDependency manager for Ant\n(tags: Java Ant opensource)\nLiquiBase: Database Refactoring\nNice database refactoring tool\n(tags: database refactoring java opensource)\n","date":"September 12, 2007","externalUrl":null,"permalink":"/posts/2007-09-12-links-for-2007-09-12/","section":"Posts","summary":" Jayasoft Community Site - Ivy\nDependency manager for Ant\n(tags: Java Ant opensource)\nLiquiBase: Database Refactoring\nNice database refactoring tool\n(tags: database refactoring java opensource)\n","title":"links for 2007-09-12","type":"posts"},{"content":"I definitely think that dynamic languages for Java platform is an important topic. In that context, a Scripting API as a standardized scripting framework has its own role for Java developers. It is definitely a good thing it is included in JDK 6, but the lack of proper support for earlier JDK\u0026rsquo;s, in my opinion, slows down its wider adoption.\nWhy is this important? On one side, there are developers that work on \u0026ldquo;in-house\u0026rdquo; applications and solutions. Although it may seem that JDK (or JRE) upgrade process in such environments is not a big deal, it is usually a process that is pretty inertial. Many arguments are used in discussions, from compatibility issues and testing needs to \u0026ldquo;don\u0026rsquo;t fix it if it ain\u0026rsquo;t broken\u0026rdquo;, but also the inertia factor could be often associated to plain laziness.\nOn other side, you have developers of Java libraries and general-purpose Java applications who try to have user base as wide as possible. In that manner, they usually keep their products either compatible with JDK 1.4 or provide a special \u0026ldquo;retrotranslated\u0026rdquo; version of it.\nSo, it is not hard to see why general scripting support (through JDK 6 exclusive Scripting API) in applications and libraries is not something that we can see on regular basis in Java projects today (especially when there is no official JDK 6 release for OS X yet).\nSo, let\u0026rsquo;s see what we can be done to enable Scripting API for Java applications of today. There are three artifacts you need to have in order to successfully use the API. The first is, of course, the API implementation. Next, you need a script engine API interface implementation for the specific language you want to use and finally you\u0026rsquo;ll need an interpreter (engine) of the same language. If you are using JDK 6, the Scripting API implementation is already integrated in your Java environment. You also have a full support for Rhino (JavaScript) script engine (both engine and API interface implementation). For other languages, you can find script engine API interface implementations in Scripting Project on java.net. For language interpreters (engines), you have to look at particular project\u0026rsquo;s site or general-purpose Maven repositories.\nIf you have your project developed on JDK 5, things are somewhat different. There is no problem with the first artifact needed. You can always download the reference implementation of the Scripting API. It is compiled with JDK 5 so you are free to use it in your project. The things are somewhat different with script engine interface implementations. All binaries distributed with the Scripting Project are built using JDK 6, so you cannot use them in your project as they are. There are two things you can do. The first, obvious one, is to get the source of the project and try to rebuild the engine interface implementation that you need. While this option is always viable, it is not automated enough for wider use. The second approach you can use is explained below and it is the same technique used with JDK 1.4.\nSo what if you want to use Scripting API (and appropriate engines) with JDK 1.4? Fortunately, good guys of the Mule fame have done some good work in that field, so all there is left for us to do is to use it. In the Maven repository of Mule dependencies (http://dist.codehaus.org/mule/dependencies/maven2/javax/script/), you can find JARs of Scripting API and some script engine implementations retrotranslated to JDK 1.4. So, you can download it or set up your maven build process to use those JARs in your projects and enable Scripting API even in your JDK 1.4 compatible projects (of course, the JDK 5 projects can also use this stuff). In the rest of this post, I\u0026rsquo;ll explain Maven project setup needed for this and provide some notes on compatibility issues.\nFirst of all, you have to add aforementioned repository to the list of repositories in your pom.xml file.\n\u0026lt;repository\u0026gt; \u0026lt;id\u0026gt;mule-deps\u0026lt;/id\u0026gt; \u0026lt;name\u0026gt;Mule Dependencies\u0026lt;/name\u0026gt; \u0026lt;url\u0026gt;http://dist.codehaus.org/mule/dependencies/maven2\u0026lt;/url\u0026gt; \u0026lt;snapshots\u0026gt; \u0026lt;enabled\u0026gt;false\u0026lt;/enabled\u0026gt; \u0026lt;/snapshots\u0026gt; \u0026lt;/repository\u0026gt; Now, you can add necessary dependencies\n\u0026lt;dependency\u0026gt; \u0026lt;groupId\u0026gt;javax.script\u0026lt;/groupId\u0026gt; \u0026lt;artifactId\u0026gt;script-api\u0026lt;/artifactId\u0026gt; \u0026lt;version\u0026gt;1.0\u0026lt;/version\u0026gt; \u0026lt;classifier\u0026gt;jdk14\u0026lt;/classifier\u0026gt; \u0026lt;/dependency\u0026gt; \u0026lt;dependency\u0026gt; \u0026lt;groupId\u0026gt;net.sf.retrotranslator\u0026lt;/groupId\u0026gt; \u0026lt;artifactId\u0026gt;retrotranslator-runtime\u0026lt;/artifactId\u0026gt; \u0026lt;version\u0026gt;1.2.1\u0026lt;/version\u0026gt; \u0026lt;/dependency\u0026gt; You can notice, that Retrotranslator runtime engine is needed for successful usage of this JAR. And that\u0026rsquo;s it, now you can include script engines of your choice (or let your users/customers to do so) and start using scripts in your applications according to your needs.\nFor example, to add Groovy engine you\u0026rsquo;ll add something like this to your project\u0026rsquo;s configuration\n\u0026lt;dependency\u0026gt; \u0026lt;groupId\u0026gt;javax.script\u0026lt;/groupId\u0026gt; \u0026lt;artifactId\u0026gt;groovy-engine\u0026lt;/artifactId\u0026gt; \u0026lt;version\u0026gt;1.0\u0026lt;/version\u0026gt; \u0026lt;classifier\u0026gt;jdk14\u0026lt;/classifier\u0026gt; \u0026lt;/dependency\u0026gt; \u0026lt;dependency\u0026gt; \u0026lt;groupId\u0026gt;groovy\u0026lt;/groupId\u0026gt; \u0026lt;artifactId\u0026gt;groovy-all\u0026lt;/artifactId\u0026gt; \u0026lt;version\u0026gt;1.0\u0026lt;/version\u0026gt; \u0026lt;/dependency\u0026gt; Now you can write something like this in your application\npublic void testScriptingAPI() throws Exception { ScriptEngineManager factory = new ScriptEngineManager(); ScriptEngine engine = factory.getEngineByName(\u0026#34;groovy\u0026#34;); Object ret = engine.eval(\u0026#34;return \u0026#39;test\u0026#39;\u0026#34;); assertEquals(\u0026#34;test\u0026#34;, ret); } The important thing to note is that Scripting API specification is compatible with Java 5 syntax. This means that if you use this retrotranslated version with JDK 5 you\u0026rsquo;ll have no compatibility issues, but if you insist on using it with JDK 1.4 you must take care about these syntax differences. For example, the Invocable interface use varargs for function and method calls, so the calls like these are used:\nObject result = ((Invocable)engine).invokeFunction( \u0026#34;hello\u0026#34;, \u0026#34;Arg1\u0026#34;, \u0026#34;Arg2\u0026#34; ); On JDK 1.4, you must use the \u0026ldquo;older\u0026rdquo; syntax:\nObject result = ((Invocable)engine).invokeFunction( \u0026#34;hello\u0026#34;, new Object[] {\u0026#34;Arg1\u0026#34;, \u0026#34;Arg2\u0026#34;} ); No compatibility will be broken when you upgrade your project to full JDK 6 support, so it\u0026rsquo;s small price to pay.\nIf we lived in a perfect world there would be Scripting API (and all script engines from the Scripting Project) accessible in mainstream Maven repositories (or even only in the java.net repository) in versions for all JDKs mentioned above (so you can choose). I guess it would lead to much higher adoption of this API and scripting support in Java projects. And after all, it seems to me that it is not too much to ask for.\n","date":"September 12, 2007","externalUrl":null,"permalink":"/posts/2007-09-12-scripting-api-for-everyone/","section":"Posts","summary":"I definitely think that dynamic languages for Java platform is an important topic. In that context, a Scripting API as a standardized scripting framework has its own role for Java developers. It is definitely a good thing it is included in JDK 6, but the lack of proper support for earlier JDK’s, in my opinion, slows down its wider adoption.\nWhy is this important? On one side, there are developers that work on “in-house” applications and solutions. Although it may seem that JDK (or JRE) upgrade process in such environments is not a big deal, it is usually a process that is pretty inertial. Many arguments are used in discussions, from compatibility issues and testing needs to “don’t fix it if it ain’t broken”, but also the inertia factor could be often associated to plain laziness.\n","title":"Scripting API for everyone","type":"posts"},{"content":"From today on, continuous integration process is set up for JQR and daily snapshots are available in the repository.\n","date":"July 27, 2007","externalUrl":null,"permalink":"/posts/2007-07-27-daily-snapshots/","section":"Posts","summary":"From today on, continuous integration process is set up for JQR and daily snapshots are available in the repository.\n","title":"Daily Snapshots","type":"posts"},{"content":"In software development we are often encouraged to decouple things in order to achieve greater flexibility in our code. So we decouple model objects from views, interfaces from their implementation, etc.\nHere, I would like to write about different kind of decoupling, front-end from back-end. In many cases, projects tend to depend on resources that are either unreliable or overloaded. For example, besides your \u0026ldquo;main\u0026rdquo; database, you may need to write data to some LDAP server that is overloaded or you need to provide some data to the resources over the unreliable network connection. In most of these use cases, these operations are triggered by users through the user interface (web or stand-alone application). It is totally unnecessary (and usually unacceptable) to have your users wait a few minutes for operation to complete or in worse case to have dysfunctional system just because one resource is unavailable.\nQueuing in one of the most common \u0026ldquo;patterns\u0026rdquo; in information technology and it is one of the patterns that could be used to solve problems described above in a natural way. You can, for example, identify potentially unreliable and slow operations and implement a kind of \u0026ldquo;job queuing engine\u0026rdquo; that will queue and execute those jobs in the batch. Of course, it is only applicable to actions that does not need to return data to the user immediately, which are in most cases insert/update operations of various kinds.\nIn the past, I often used Quartz scheduler to emulate this functionality which provided a solution that worked but was not easy to scale and maintain. For one of the recent projects I decided to \u0026ldquo;start fresh\u0026rdquo; and create an open-source engine (JQR) that will serve this purpose for my future projects (and could be potentially helpful to others with the same requirements). I based it on ActiveMQ open-source broker, since it provides a natural mechanism of queueing messages, has built-in many utilities that I needed and proved to be stable in earlier projects. Also, it provides great infrastructure to build upon and possibilities to create a real distributed job execution engine.\nThe basic principle of JQR is quite simple. You implement your job by defining code for four basic events:\nWhen job is received for queuing When job is executed (the main logic of the job) When job finishes it execution successfully When job fails for any reason The job implemented like this is then deployed to the system (by its name and group) and could be triggered from any appropriate client (implemented in a language of your choice). Since the job will be queued and executed in the batch, client does not wait for the job to be executed. Instead it can proceed to its other activities. When finished (successfully or not), the job will execute appropriate actions, and could notify the client of its result (by calling some URL via HTTP for example). Of course, appropriate parameters are transferred between client and JQR, which provides the context for the job execution.\nYou can also, define a number of retires (job execution failures) before the job is declared as failed and send to the \u0026ldquo;failed jobs queue\u0026rdquo;. The usual scenario is to send a notification to the administrator who will inspect reasons for job failure and when right conditions are met trigger job again or delete it if he finds it appropriate.\nBasically that would be the whole philosophy of the JQR, which could be summarized as: do this job for me and just let me know when you finish. It is not applicable for all problems, but there is a lot of problem domains where this approach is natural fit (just as in real life).\nI must say that project is currently in the \u0026ldquo;infant\u0026rdquo; phase, meaning that is has implemented minimum requirements that I need at this moment. It contains a PHP client which communicates with the engine through the REST protocol and contains a few predefined jobs that could be used \u0026ldquo;off the shelf\u0026rdquo;. But the most important thing for this kind of project is to be easy to configure, maintain and use and I think that it is headed in right direction so far. It is easy to set basic configuration and start/stop the engine and it is fairly easy to develop and deploy new jobs for it.\nIn the future, there is a lot of things that should be added in order to make it easier to use and more useful. Some of the planned features are:\nfull support for most of the scripting languages both on the client and server (job writing tasks) sides. It would make it more easily to create new jobs and maintain existing ones and it would make it useful for projects written in different languages. more different protocols both for job manipulation and global management, which could ease integration in different projects. Of course, a full-featured console for management of failed jobs should be integral part of the project. access control for all operations job scheduling (both dynamic and static) which would leverage this engine to the next level providing a full job manipulation engine for most scripting languages (and available instantly) \u0026hellip; many other stuff. I intended this post to be just a starter of the conversation on this \u0026ldquo;usually overlooked\u0026rdquo; topic. I want to hear whether other people have similar requirements and what were their solutions? What a project like this should have? All constructive comments are welcome.\n","date":"July 18, 2007","externalUrl":null,"permalink":"/posts/2007-07-18-asynchronous-job-execution/","section":"Posts","summary":"In software development we are often encouraged to decouple things in order to achieve greater flexibility in our code. So we decouple model objects from views, interfaces from their implementation, etc.\nHere, I would like to write about different kind of decoupling, front-end from back-end. In many cases, projects tend to depend on resources that are either unreliable or overloaded. For example, besides your “main” database, you may need to write data to some LDAP server that is overloaded or you need to provide some data to the resources over the unreliable network connection. In most of these use cases, these operations are triggered by users through the user interface (web or stand-alone application). It is totally unnecessary (and usually unacceptable) to have your users wait a few minutes for operation to complete or in worse case to have dysfunctional system just because one resource is unavailable.\n","title":"Asynchronous job execution","type":"posts"},{"content":"Sensatic JQR 1.2.0 has been released.\n","date":"June 29, 2007","externalUrl":null,"permalink":"/posts/2007-06-29-jqr-120-released/","section":"Posts","summary":"Sensatic JQR 1.2.0 has been released.\n","title":"JQR 1.2.0 released","type":"posts"},{"content":" Apache ActiveMQ # Status: Active committer and PMC member\nApache ActiveMQ is the most popular and powerful open source Message Broker and Enterprise Integration Patterns provider.\nFuse Fabric # Status: Active committer\nFuse Fabric is open source integration platform\n","date":"June 19, 2007","externalUrl":null,"permalink":"/projects/","section":"Dejan Bosanac","summary":"Apache ActiveMQ # Status: Active committer and PMC member\nApache ActiveMQ is the most popular and powerful open source Message Broker and Enterprise Integration Patterns provider.\nFuse Fabric # Status: Active committer\nFuse Fabric is open source integration platform\n","title":"Projects","type":"page"},{"content":"On 29 June, Eclipse community will be richer for the new Europa release. It is a coordinate release of 21 Eclipse Foundation projects. The main component of this release is certainly new 3.3 version of the Eclipse Platform. Others include prominent projects from domains of administration, modeling, development and tools, such as Eclipse Communications Framework (ECF), Eclipse Modeling Framework Project (EMF), Dynamic Languages Tool Kit (DLTK) and Business Intelligence Reporting Tools (BIRT). This is definitely an important Eclipse release and a good news for all Eclipse users.\n","date":"June 15, 2007","externalUrl":null,"permalink":"/posts/2007-06-15-eclipse-europa/","section":"Posts","summary":"On 29 June, Eclipse community will be richer for the new Europa release. It is a coordinate release of 21 Eclipse Foundation projects. The main component of this release is certainly new 3.3 version of the Eclipse Platform. Others include prominent projects from domains of administration, modeling, development and tools, such as Eclipse Communications Framework (ECF), Eclipse Modeling Framework Project (EMF), Dynamic Languages Tool Kit (DLTK) and Business Intelligence Reporting Tools (BIRT). This is definitely an important Eclipse release and a good news for all Eclipse users.\n","title":"Eclipse Europa","type":"posts"},{"content":"If you build an application that integrates ActiveMQ broker, it makes sense that you want to integrate its web console as well. It provides your users with basic monitoring and management operations. One road you can take is to integrate it as a WAR archive, but as you already have a whole lot of ActiveMQ integrated, you probably want to include just necessary subset of libraries and files and always have most up to date version of it.\nThis integrations is not as seamless as it probably should be, but here are a couple of steps I found do the job for me (and hope can help someone else with the same requirements). I use Maven2 as a build tool and its assembly plugin to create a final distribution. If you are using some different building environment it is probably the best to stick with customized WAR archive.\nFirst of all, you need to use version 2.2 (or later) of the maven assembly plugin. For that, put the following snippet to the appropriate pom.xml\n\u0026lt;build\u0026gt; \u0026lt;plugins\u0026gt; \u0026lt;plugin\u0026gt; \u0026lt;groupId\u0026gt;org.apache.maven.plugins\u0026lt;/groupId\u0026gt; \u0026lt;artifactId\u0026gt;maven-assembly-plugin\u0026lt;/artifactId\u0026gt; \u0026lt;version\u0026gt;2.2-beta-1\u0026lt;/version\u0026gt; \u0026lt;configuration\u0026gt; \u0026lt;descriptors\u0026gt; \u0026lt;descriptor\u0026gt; src/main/descriptors/unix-bin.xml \u0026lt;/descriptor\u0026gt; \u0026lt;/descriptors\u0026gt; \u0026lt;finalName\u0026gt;sensatic-jqr-${pom.version}\u0026lt;/finalName\u0026gt; \u0026lt;appendAssemblyId\u0026gt;false\u0026lt;/appendAssemblyId\u0026gt; \u0026lt;/configuration\u0026gt; \u0026lt;/plugin\u0026gt; \u0026lt;/plugins\u0026gt; \u0026lt;/build\u0026gt; The version 2.2 of the plugin is needed for some additional WAR extraction manipulations, as we will see in the moment. Now, let\u0026rsquo;s see some things we should add to the deployment descriptor. First of all, we need to create a dependency set that will extract the WAR to the specified folder inside our application\n\u0026lt;dependencySet\u0026gt; \u0026lt;outputDirectory\u0026gt;/webapps/admin\u0026lt;/outputDirectory\u0026gt; \u0026lt;outputFileNameMapping\u0026gt;\u0026lt;/outputFileNameMapping\u0026gt; \u0026lt;unpack\u0026gt;true\u0026lt;/unpack\u0026gt; \u0026lt;unpackOptions\u0026gt; \u0026lt;excludes\u0026gt; \u0026lt;exclude\u0026gt;**/activemq.xml\u0026lt;/exclude\u0026gt; \u0026lt;exclude\u0026gt;**/webconsole-*.xml\u0026lt;/exclude\u0026gt; \u0026lt;exclude\u0026gt;WEB-INF/lib/**\u0026lt;/exclude\u0026gt; \u0026lt;/excludes\u0026gt; \u0026lt;/unpackOptions\u0026gt; \u0026lt;scope\u0026gt;runtime\u0026lt;/scope\u0026gt; \u0026lt;includes\u0026gt; \u0026lt;include\u0026gt; org.apache.activemq:activemq-web-console \u0026lt;/include\u0026gt; \u0026lt;/includes\u0026gt; \u0026lt;/dependencySet\u0026gt; There are a few notes worth commenting about this snippet. As you can see we have configured our assembler to extract war file into /webapps/admin folder. The thing why we needed version 2.2 of the assembly plugin is the usage of tag, which allows us to exclude some elements of the WAR archive. I excluded default configuration files, since I will later include just one that I need. Also, I stripped all JARs from the WEB-INF/lib folder. As I said earlier, the most of those libraries are already in the classpath of your application. Those that are not (and are exclusively related to the web) we can include with the following snippet.\n\u0026lt;dependencySet\u0026gt; \u0026lt;outputDirectory\u0026gt;/webapps/admin/WEB-INF/lib\u0026lt;/outputDirectory\u0026gt; \u0026lt;scope\u0026gt;runtime\u0026lt;/scope\u0026gt; \u0026lt;includes\u0026gt; \u0026lt;include\u0026gt;opensymphony:sitemesh\u0026lt;/include\u0026gt; \u0026lt;include\u0026gt;javax.servlet:jstl\u0026lt;/include\u0026gt; \u0026lt;include\u0026gt;org.mortbay.jetty:jsp-2.1\u0026lt;/include\u0026gt; \u0026lt;include\u0026gt;org.mortbay.jetty:jsp-api-2.1\u0026lt;/include\u0026gt; \u0026lt;include\u0026gt;taglibs:standard\u0026lt;/include\u0026gt; \u0026lt;include\u0026gt;rome:rome\u0026lt;/include\u0026gt; \u0026lt;include\u0026gt;jdom:jdom\u0026lt;/include\u0026gt; \u0026lt;/includes\u0026gt; \u0026lt;/dependencySet\u0026gt; My application already starts jetty (to run ActiveMQ Rest/Ajax interface), which means that all appropriate JAR\u0026rsquo;s are already in application\u0026rsquo;s classpath. So here, we will include only JARs related to this specific web application. A few more things that I found interesting while making this work are:\nWeb console threw exceptions (can\u0026rsquo;t find resources such as TLD\u0026rsquo;s) when some of these libraries were not directly in its classpath (but in parent application\u0026rsquo;s classpath instead). I\u0026rsquo;m not sure why this is, but I guess it\u0026rsquo;s a class loading issue. In this case I wanted to have it specifically in the web application\u0026rsquo;s classpath (which is the combination that works), so I didn\u0026rsquo;t investigate this issue further. If web console is using ActiveMQ from its classpath, it throws an exception trying to locate the embedded broker. There are three solutions here: one to remove all ActiveMQ JARs from the WEB-INF/lib (solution used here), tell Jetty to give priority to parent application\u0026rsquo;s loader (more about this later) or use some other mechanism for configuring web console. After we set up the classpath, it\u0026rsquo;s time to deal with the proper configuration of our web console. By default, web console tries to load webconsole-embedded.xml which tries to start a broker and use it. Because we already have our broker started this is totally unnecessary, so we need to provide our own \u0026ldquo;lightweight\u0026rdquo; configuration as follows\n\u0026lt;!DOCTYPE beans PUBLIC \u0026#34;-//SPRING//DTD BEAN//EN\u0026#34; \u0026#34;http://www.springframework.org/dtd/spring-beans.dtd\u0026#34;\u0026gt; \u0026lt;beans\u0026gt; \u0026lt;bean id=\u0026#34;placeholderConfig\u0026#34; class=\u0026#34;org.springframework.beans.factory.config.PropertyPlaceholderConfigurer\u0026#34; /\u0026gt; \u0026lt;!-- use the following bean for a local in-JVM broker --\u0026gt; \u0026lt;bean id=\u0026#34;brokerQuery\u0026#34; class=\u0026#34;org.apache.activemq.web.SingletonBrokerFacade\u0026#34; autowire=\u0026#39;constructor\u0026#39; singleton=\u0026#34;false\u0026#34;/\u0026gt; \u0026lt;bean id=\u0026#34;sessionPool\u0026#34; class=\u0026#34;org.apache.activemq.web.SessionPool\u0026#34;\u0026gt; \u0026lt;property name=\u0026#34;connectionFactory\u0026#34; ref=\u0026#34;connectionFactory\u0026#34;/\u0026gt; \u0026lt;/bean\u0026gt; \u0026lt;bean id=\u0026#34;connectionFactory\u0026#34; class=\u0026#34;org.apache.activemq.ActiveMQConnectionFactory\u0026#34;\u0026gt; \u0026lt;property name=\u0026#34;brokerURL\u0026#34; value=\u0026#34;vm://localhost\u0026#34;/\u0026gt; \u0026lt;/bean\u0026gt; \u0026lt;bean id=\u0026#34;queueBrowser\u0026#34; class=\u0026#34;org.apache.activemq.web.QueueBrowseQuery\u0026#34; autowire=\u0026#39;constructor\u0026#39; singleton=\u0026#34;false\u0026#34;/\u0026gt; \u0026lt;bean id=\u0026#34;messageQuery\u0026#34; class=\u0026#34;org.apache.activemq.web.MessageQuery\u0026#34; autowire=\u0026#39;constructor\u0026#39; singleton=\u0026#34;false\u0026#34;/\u0026gt; \u0026lt;/beans\u0026gt; Finally, the only thing left to do is to configure our web application. If you don\u0026rsquo;t have Jetty already configured, you\u0026rsquo;ll have to do that first. In other case, all you need to do is to provide additional web application configurations, such as\n\u0026lt;bean class=\u0026#34;org.mortbay.jetty.webapp.WebAppContext\u0026#34;\u0026gt; \u0026lt;property name=\u0026#34;contextPath\u0026#34; value=\u0026#34;/admin\u0026#34;/\u0026gt; \u0026lt;property name=\u0026#34;resourceBase\u0026#34; value=\u0026#34;webapps/admin\u0026#34;/\u0026gt; \u0026lt;property name=\u0026#34;parentLoaderPriority\u0026#34; value=\u0026#34;false\u0026#34;/\u0026gt; \u0026lt;/bean\u0026gt; if you are using Spring, or this\n\u0026lt;webAppContext contextPath=\u0026#34;/admin\u0026#34; resourceBase=\u0026#34;webapps/admin\u0026#34; parentLoaderPriority=\u0026#34;false\u0026#34; /\u0026gt; in case of XBean. The parentLoaderPriority property tells Jetty whether to give priority to classes from the parent application or the web application, in case it finds duplicate classes. I generally found that giving parent application\u0026rsquo;s classes a priority could raise problems in case that it uses older versions of the libraries web console needs. For that reason I set it to false.\nIn the future, I would like to move these libraries from the WEB-INF/lib folder in some folder where all (potential) web applications could share it. Finally, it would be great if we could grab zipped version from the repository (without libraries and with proper configuration), unzip it and embed in the parent application. It would make this process a breeze.\n","date":"June 7, 2007","externalUrl":null,"permalink":"/posts/2007-06-07-integrating-activemq-web-console/","section":"Posts","summary":"If you build an application that integrates ActiveMQ broker, it makes sense that you want to integrate its web console as well. It provides your users with basic monitoring and management operations. One road you can take is to integrate it as a WAR archive, but as you already have a whole lot of ActiveMQ integrated, you probably want to include just necessary subset of libraries and files and always have most up to date version of it.\n","title":"Integrating ActiveMQ Web Console","type":"posts"},{"content":"Sensatic JQR 1.1.0 has been released.\n","date":"June 2, 2007","externalUrl":null,"permalink":"/posts/2007-06-02-jqr-110-released/","section":"Posts","summary":"Sensatic JQR 1.1.0 has been released.\n","title":"JQR 1.1.0 released","type":"posts"},{"content":"If you ever tried to work with SSL Socket connections in Java, you probably know that Java, by default, supports its own JKS and PKCS12 certificate formats. For those who need to work with OpenSSL it is usually suggested to convert keys and certificates to PKCS12 and then import them in the keystore using the keytool command provided with the JDK.\nWhile all this is not a big deal for most of the applications, there should be a better solution for projects that rely heavily on SSL. Not-yet-commons-ssl project, called liked this because it is still in the Apache incubation process, aims to simplify Java and SSL integration.\nFirst of all, it supports OpenSSL and PKCS8 formats and provides handy classes for dealing with keys and certificates in that format (see PKCS8 examples.\nAlso, it provides mechanism for easy creation of SSL Sockets regardless of certificate format you are using (see examples). This mechanism also allows us to configure multiple ssl socket factories inside a single JVM.\nCommons SSL is a really important toolkit for all that have above modest SSL requirements. The proper support from Apache and a better documentation could help this project become even more useful.\n","date":"May 30, 2007","externalUrl":null,"permalink":"/posts/2007-05-30-not-yetcommons-ssl/","section":"Posts","summary":"If you ever tried to work with SSL Socket connections in Java, you probably know that Java, by default, supports its own JKS and PKCS12 certificate formats. For those who need to work with OpenSSL it is usually suggested to convert keys and certificates to PKCS12 and then import them in the keystore using the keytool command provided with the JDK.\nWhile all this is not a big deal for most of the applications, there should be a better solution for projects that rely heavily on SSL. Not-yet-commons-ssl project, called liked this because it is still in the Apache incubation process, aims to simplify Java and SSL integration.\n","title":"(Not yet)Commons SSL","type":"posts"},{"content":"XStream 1.2.2 is released with JettisonMappedXmlDriver used for serialization and deserialization from JSON. It is the driver first presented in Java and JSON post. All modifications are submitted to Jettison and XStream projects respectfully and documented in an appropriate tutorial (http://xstream.codehaus.org/json-tutorial.html). From now on, XStream has a full support for JSON serialization. Enjoy.\n","date":"May 25, 2007","externalUrl":null,"permalink":"/posts/2007-05-25-xstream-122/","section":"Posts","summary":"XStream 1.2.2 is released with JettisonMappedXmlDriver used for serialization and deserialization from JSON. It is the driver first presented in Java and JSON post. All modifications are submitted to Jettison and XStream projects respectfully and documented in an appropriate tutorial (http://xstream.codehaus.org/json-tutorial.html). From now on, XStream has a full support for JSON serialization. Enjoy.\n","title":"XStream 1.2.2","type":"posts"},{"content":"Here\u0026rsquo;s a simple script that recursively changes CVS/Root files in the project tree\nfind . -name Root -exec sh -c \u0026#39;echo :pserver:example@cvs.example.com:2401/var/cvsroot \u0026gt; {}\u0026#39; \\; Note sh -c segment of -exec switch, which is necessary in order to successfully redirect to appropriate files.\nThis could be useful for updating deployed projects with the repository that has moved (for any reason).\n","date":"May 24, 2007","externalUrl":null,"permalink":"/posts/2007-05-24-changing-cvs-root-from-shell/","section":"Posts","summary":"Here’s a simple script that recursively changes CVS/Root files in the project tree\nfind . -name Root -exec sh -c 'echo :pserver:example@cvs.example.com:2401/var/cvsroot \u003e {}' \\; Note sh -c segment of -exec switch, which is necessary in order to successfully redirect to appropriate files.\nThis could be useful for updating deployed projects with the repository that has moved (for any reason).\n","title":"Changing CVS Root from shell","type":"posts"},{"content":"One of the lessons we can learn from early success of the Web was making of ideal environment for use of scripts. There were two main components of the Web platform:\nWeb server (Apache), as an infrastructural component that had to be fast and reliable Web application as a collection of scripts (Perl, PHP, Python), providing the content in an easy manner The Web as we know it today is a much different place; applications talk to each other through variety of web service protocols, we have Ajax and all these new cool toys. But one principle remains the same: we need reliable infrastructure software with easy integration of scripts for fast creation of content and logic.\nI\u0026rsquo;ve always seen Java as an ideal platform for building infrastructural applications. One of the proofs for this claim is existence of many production-ready asynchronous-messaging solutions on the Java platform. Asynchronous messaging is an important programming concept which is one of the reasons for Java\u0026rsquo;s success in the enterprise environment. JMS specification and many quality implementations of brokers and clients led to wide adoption of messaging paradigm among Java developers.\nRecent trend towards bringing asynchronous messaging closer to scripting world is very encouraging (in my opinion) as it will bring completely new programming concepts to script developers and much wider adoption of asynchronous messaging patterns.\nWhat I primarily have in mind here is Stomp (Streaming Text Orientated Messaging Protocol), a lightweight messaging protocol, which makes it easy to implement clients for most of the scripting languages (the most of the mainstream scripting languages already have Stomp clients implemented). Currently only ActiveMQ implements native Stomp support and enables script developers to enjoy all goodness of loosely-coupled asynchronous integration of their applications. Support for virtually any JMS broker is provided through StompConnect project.\nOne other potential alternative to Stomp is AMQP (Advanced Message Queuing Protocol), the specification that aims to standardize messaging. Intention of AMQP is not to be simple, but to provide standard specification that will allow implementation of brokers and clients in virtually any programming language.\nAMQP is young specification and currently you can find it implemented in Qpid (http://cwiki.apache.org/qpid/) project in Apache\u0026rsquo;s incubator. It currently implements brokers in Java and C++ and clients in Java, C++, C#, Python and Ruby. The other open source project that implements AMQP protocol is RabbitMQ, which is written in Erlang and provides clients in Java, JavaScript and native Erlang.\nRegardless of the actual protocol and technology being used, I think that asynchronous messaging and scripting provides a lot of potential to developers and I\u0026rsquo;m sure we will hear a lot of about these two playing together in coming years.\n","date":"May 4, 2007","externalUrl":null,"permalink":"/posts/2007-05-04-scripting-and-asynchronous-messaging/","section":"Posts","summary":"One of the lessons we can learn from early success of the Web was making of ideal environment for use of scripts. There were two main components of the Web platform:\nWeb server (Apache), as an infrastructural component that had to be fast and reliable Web application as a collection of scripts (Perl, PHP, Python), providing the content in an easy manner The Web as we know it today is a much different place; applications talk to each other through variety of web service protocols, we have Ajax and all these new cool toys. But one principle remains the same: we need reliable infrastructure software with easy integration of scripts for fast creation of content and logic.\n","title":"Scripting and asynchronous messaging","type":"posts"},{"content":" ActiveMQ in Action # ActiveMQ in Action Publisher: Manning Publications Co. Pub Date: March 24th 2011 Pages: 408 pages Print ISBN: 1933988940\nScripting in Java # Scripting in Java: Languages, Frameworks, and Patterns Publisher: Addison Wesley Professional Pub Date: August 31, 2007 (est.) Print ISBN-10: 0-321-32193-6 Print ISBN-13: 978-0-321-32193-0 eText ISBN-10: 0-321-50933-1 eText ISBN-13: 978-0-321-50933-8 Pages: 552\n","date":"April 19, 2007","externalUrl":null,"permalink":"/books/","section":"Dejan Bosanac","summary":"ActiveMQ in Action # ActiveMQ in Action Publisher: Manning Publications Co. Pub Date: March 24th 2011 Pages: 408 pages Print ISBN: 1933988940\nScripting in Java # Scripting in Java: Languages, Frameworks, and Patterns Publisher: Addison Wesley Professional Pub Date: August 31, 2007 (est.) Print ISBN-10: 0-321-32193-6 Print ISBN-13: 978-0-321-32193-0 eText ISBN-10: 0-321-50933-1 eText ISBN-13: 978-0-321-50933-8 Pages: 552\n","title":"Books","type":"page"},{"content":"Filip Hanik of Covalent Technologies wrote an excellent article in which he describes his series of performance/scalability tests of the new NIO connector that has been added to Tomcat 6. In tests he also includes Jetty and Glassfish containers. The article contains very good explanation of challenges in adapting NIO environment to blocking IO requirements. The good news is that the answer to the question from the title is yes, servlet containers can scale, led by Tomcat 6 that handled 16000 concurrent connections without problems.\n","date":"April 4, 2007","externalUrl":null,"permalink":"/posts/2007-04-04-can-servlet-containers-scale/","section":"Posts","summary":"Filip Hanik of Covalent Technologies wrote an excellent article in which he describes his series of performance/scalability tests of the new NIO connector that has been added to Tomcat 6. In tests he also includes Jetty and Glassfish containers. The article contains very good explanation of challenges in adapting NIO environment to blocking IO requirements. The good news is that the answer to the question from the title is yes, servlet containers can scale, led by Tomcat 6 that handled 16000 concurrent connections without problems.\n","title":"Can Servlet containers scale?","type":"posts"},{"content":"As you all have probably heard, Velocity 1.5 was released last week. It is the first release of this project in last three years. This is certainly a long release cycle and it is not unusual that some people considered it a \u0026ldquo;dead project\u0026rdquo;.\nI have some projects that use Velocity as a template engine of choice and over the time I\u0026rsquo;ve collected a \u0026ldquo;wish list\u0026rdquo; of features that I missed. Due to lack of new releases, I\u0026rsquo;ve considered switching to other template engines, such as FreeMarker and WebMacro, but actually never found time to do that.\nAs I go through the release note, I see that some of the wish-list features have been added to this release. Some of them would be nice to be seen in the future (road map looks promising). Here are some details:\nnull value - this is certainly one of the most important issues from developers\u0026rsquo; point of view. From a template engine designed for use in Java projects, you\u0026rsquo;d expect to support work with null values in a natural way. However, this is not the case with Velocity. On this wiki page, you can find details on what is missing and what are usual workarounds. New release comes with added support for null values in #set and #foreach statements. What apparently seems to be missing (both from this release and the road-map) is support for #if directive and general support for other cases that are usually found in Java projects.\nbreak statement - for any non-trivial loop usage, you will need a mechanism to exist the loop prematurely. The break statement is usual way to achieve this, but is unfortunately lacking in Velocity. According to road-map, it should be added in 2.0. The continue would be nice too, but it is not as critical as break.\nbetter support for comparing objects - this seems to be fixed in this release too, but it could get you lose a lot of time with trivial stuff in earlier versions. Imagine that you have Java property of type Long and value 10. So, what would you expect of this snippet to write\n#if ($obj.prop == 10) true #else false #end Despite all our wishes, until 1.5 release, this snippet would print false. I know that there are number of workarounds for this, but after a long day it could be frustrating to search for this kind of errors in your templates.\nsupport for automatic string to number casting - every script language treats strings as type with special status. I think that template engines should do the same. It makes life much easier for their users. For example, if you have a method that accepts integer as a parameter and you have a string value in your template (for any reason), it would be great if Velocity would do the conversion and spear us from unpleasant task of casting simple types in templates.\nThis is certainly just a small subset of enhancements that are (and could be) implemented in Velocity. Anyhow, it is great to see new release of Velocity and I think it is important to have modern templating engine implementation under Apache\u0026rsquo;s roof. I hope that Velocity team would continue to roll-up new releases regularly and keep the pace with other modern templating engines.\n","date":"March 21, 2007","externalUrl":null,"permalink":"/posts/2007-03-21-velocity-15/","section":"Posts","summary":"As you all have probably heard, Velocity 1.5 was released last week. It is the first release of this project in last three years. This is certainly a long release cycle and it is not unusual that some people considered it a “dead project”.\nI have some projects that use Velocity as a template engine of choice and over the time I’ve collected a “wish list” of features that I missed. Due to lack of new releases, I’ve considered switching to other template engines, such as FreeMarker and WebMacro, but actually never found time to do that.\n","title":"Velocity 1.5","type":"posts"},{"content":"There has been some very interesting activity in JCP land lately, namely acceptance of new Date and Time API (JSR 310) and proposal of the JavaTM API for RESTful Web Services (JSR 311).\nUsual first reactions to the JSR 310 that I saw on the web were \u0026ldquo;finally\u0026rdquo; or \u0026ldquo;too late\u0026rdquo;, but I think that \u0026ldquo;better late then never\u0026rdquo; should be applied in this case. People behind this specification are developers of Joda time and this API will be heavily based on Joda time, which has been an excellent replacement for traditional Java date/calendar API (and must-have tool in your toolbox) for years. Beside the initial goal, to provide lightweight and simple API, one of the area of interest will be interoperability with JDBC. The general attitude toward this spec is maybe best described by the Google\u0026rsquo;s voting comment: On 2007-01-30 Google Inc. voted Yes with the following comment: We are thrilled to see this happen! Hopefully, this specification will be included in Java 7.\nNow back to the RESTful Web Services and the specification request 311. Although it is not crucial part of the language as Date/Time API, I think that this specification deserves to pass approval process and we (Java developers) deserve to have standard API to deal with RESTfull web services.\nThe introductory example, from Marc Hadley (one of the spec leads) looks promising\n@UriTemplate(\u0026#34;widgets/{widgetid}\u0026#34;) @ConsumeMime(\u0026#34;application/widgets+xml\u0026#34;) @ProduceMime(\u0026#34;application/widgets+xml\u0026#34;) public class Widget { @HttpMethod(GET) public Representation getWidget(@UriParam(\u0026#34;widgetid\u0026#34;) String id) { String replyStr = getWidgetAsXml(id); return new StringRepresentation(replyStr, \u0026#34;application/widgets+xml\u0026#34;); } @HttpMethod(PUT) public void updateWidget(@UriParam(\u0026#34;widgetid\u0026#34;) String id, Representation update) { updateWidgetFromXml(id, update); } @LastModified public Date getChangeDate(@UriParam(\u0026#34;widgetid\u0026#34;) String id) { return getLastChanged(id); } } but I\u0026rsquo;ll second usual comments found on this topic: \u0026ldquo;I hope that they don\u0026rsquo;t screw it up\u0026rdquo;.\n","date":"February 22, 2007","externalUrl":null,"permalink":"/posts/2007-02-22-new-datetime-and-rest-apis-for-java/","section":"Posts","summary":"There has been some very interesting activity in JCP land lately, namely acceptance of new Date and Time API (JSR 310) and proposal of the JavaTM API for RESTful Web Services (JSR 311).\nUsual first reactions to the JSR 310 that I saw on the web were “finally” or “too late”, but I think that “better late then never” should be applied in this case. People behind this specification are developers of Joda time and this API will be heavily based on Joda time, which has been an excellent replacement for traditional Java date/calendar API (and must-have tool in your toolbox) for years. Beside the initial goal, to provide lightweight and simple API, one of the area of interest will be interoperability with JDBC. The general attitude toward this spec is maybe best described by the Google’s voting comment: On 2007-01-30 Google Inc. voted Yes with the following comment: We are thrilled to see this happen! Hopefully, this specification will be included in Java 7.\n","title":"New Date/Time and Rest APIs for Java","type":"posts"},{"content":"OnJava has published an article titled Tuning Derby\n","date":"January 31, 2007","externalUrl":null,"permalink":"/posts/2007-01-31-tuning-derby/","section":"Posts","summary":"OnJava has published an article titled Tuning Derby\n","title":"Tuning Derby","type":"posts"},{"content":"Probably the first design pattern that every software developer learns is Singleton and lazy loading of Singleton classes.\nThe usual example, goes something like this:\npublic class Singleton { static Singleton instance; public static synchronized Singleton getInstance() { if (instance == null) instance == new Singleton(); return instance; } } The problem with this solution is that synchronized method getInstance() is called every time, while synchronization is actually needed only for the first call of the method (which introduces performance overhead in your application). There were attempts to tackle this problem by using Double-checked locking pattern, which although great in theory didn\u0026rsquo;t work in practice.\nToday, thanks to Bob Lee, I found out that there is a solution to this problem that is both simple and fast: Initialization on Demand Holder (IODH) idiom. The appropriate example follows:\npublic class Singleton { static class SingletonHolder { static Singleton instance = new Singleton(); } public static Singleton getInstance() { return SingletonHolder.instance; } } Basicaly, Java Language Specification (JLS) guarantees that instance would not be initialized until someone calls getInstance() method (more information could be found in articles that I\u0026rsquo;ve linked to before). Elegant and fast, just as it should be.\n","date":"January 26, 2007","externalUrl":null,"permalink":"/posts/2007-01-26-singletons-and-lazy-loading/","section":"Posts","summary":"Probably the first design pattern that every software developer learns is Singleton and lazy loading of Singleton classes.\nThe usual example, goes something like this:\npublic class Singleton { static Singleton instance; public static synchronized Singleton getInstance() { if (instance == null) instance == new Singleton(); return instance; } } The problem with this solution is that synchronized method getInstance() is called every time, while synchronization is actually needed only for the first call of the method (which introduces performance overhead in your application). There were attempts to tackle this problem by using Double-checked locking pattern, which although great in theory didn’t work in practice.\n","title":"Singletons and lazy loading","type":"posts"},{"content":"It seems that JSON vs. XML debate was one of the hot topics for this winter. Again, I think that \u0026ldquo;vs.\u0026rdquo; part is sufficient and that both XML and JSON should have their place in overall technology landscape. One of the obvious JSON advantages is that it can be directly evaluated in JavaScript. And for the Ajax-world we live in, it is not a small thing.\nFor one project, I started looking for a library that would enable me easy transformations between Java and JSON data. JSON in Java looks nice, but what I really want is a more automated and configurable library like those we have for XML processing. My first thought was XStream since I like its simple API, extensible architecture, powerful converters and support for annotations. After first check I found that from version 1.2 on there is a partial support for JSON (which was logical thing to expect). So, currently you can serialize your Java objects to JSON format. Here\u0026rsquo;s a little example:\npublic class JSONWrite { public static void main(String[] args) { Product product = new Product(\u0026#34;Banana\u0026#34;, \u0026#34;123\u0026#34;, 23.00); XStream xstream = new XStream(new JsonHierarchicalStreamDriver()); String result = xstream.toXML(product); System.out.println(result); } } This example initiates a Product object (with name, id and price properties) and serialize it through JsonHierarchicalDriver. As a result we will get the following output:\n{\u0026#34;org.sensatic.jqr.json.Product\u0026#34;: { \u0026#34;name\u0026#34;: \u0026#34;Banana\u0026#34;, \u0026#34;id\u0026#34;: \u0026#34;123\u0026#34;, \u0026#34;price\u0026#34;: {\u0026#34;23.0\u0026#34;} }} Unfortunately, there is no read support at this moment for JSON format. So if you try to convert this JSON data back to Java object\npublic class JSONRead { public static void main(String[] args) { String json = \u0026#34;{\u0026#34;org.sensatic.jqr.json.Product\u0026#34;: {\u0026#34; + \u0026#34;\u0026#34;name\u0026#34;: \u0026#34;Banana\u0026#34;,\u0026#34; + \u0026#34;\u0026#34;id\u0026#34;: \u0026#34;123\u0026#34;,\u0026#34; + \u0026#34;\u0026#34;price\u0026#34;: {\u0026#34;23.0\u0026#34;}\u0026#34; + \u0026#34;}}\u0026#34;; XStream xstream = new XStream(new JsonHierarchicalStreamDriver()); Product product = (Product)xstream.fromXML(json); System.out.println(product); } } you\u0026rsquo;ll get the following exception\njava.lang.UnsupportedOperationException: The JsonHierarchicalStreamDriver can only write JSON After a little more search, I stumbled upon Jettison project which implements \u0026ldquo;a collection of Stax parsers and writers which read and write JSON\u0026rdquo;. So instantly I wanted to create a XStream driver that uses Jettison as an underlying library to parse to and from JSON.\nIt was a little bit trickier then I first thought, since I had to patch Jettison (Mapped convention classes) to support nested arrays, element names with \u0026ldquo;.\u0026rdquo; (so it can use full class names as element names) and some other minor things. After all this, it worked at least for the usage that I needed at the moment (I didn\u0026rsquo;t test its behavior when used with namespaces and attributes).\nSo, if we now use JettisonDriver with the previous write example:\npublic class JSONWrite { public static void main(String[] args) { Product product = new Product(\u0026#34;Banana\u0026#34;, \u0026#34;123\u0026#34;, 23.00); XStream xstream = new XStream(new JettisonDriver()); String result = xstream.toXML(product); System.out.println(result); } } We\u0026rsquo;ll get the similar result:\n{\u0026#34;org.sensatic.jqr.json.Product\u0026#34;:{\u0026#34;name\u0026#34;:\u0026#34;Banana\u0026#34;,\u0026#34;id\u0026#34;:\u0026#34;123\u0026#34;,\u0026#34;price\u0026#34;:\u0026#34;23.0\u0026#34;}} But read operation now works as well. So the following code:\npublic class JSONRead { public static void main(String[] args) { String json = \u0026#34;{\u0026#34;org.sensatic.jqr.json.Product\u0026#34;: {\u0026#34; + \u0026#34;\u0026#34;name\u0026#34;: \u0026#34;Banana\u0026#34;,\u0026#34; + \u0026#34;\u0026#34;id\u0026#34;: \u0026#34;123\u0026#34;,\u0026#34; + \u0026#34;\u0026#34;price\u0026#34;: \u0026#34;23.0\u0026#34;\u0026#34; + \u0026#34;}}\u0026#34;; XStream xstream = new XStream(new JettisonDriver()); Product product = (Product)xstream.fromXML(json); System.out.println(product); } } prints:\n[Banana, 123, 23.0] The real point of processing JSON with XStream is that now we can use all features already built-in for processing XML documents. For example we can add alias for the Product class. In order to do that we can put the following annotation in front of the Product class:\n@XStreamAlias(\u0026#34;product\u0026#34;) and modify our write example a bit:\npublic class JSONWrite { public static void main(String[] args) { Product product = new Product(\u0026#34;Banana\u0026#34;, \u0026#34;123\u0026#34;, 23.00); XStream xstream = new XStream(new JettisonDriver()); Annotations.configureAliases(xstream, Product.class); String result = xstream.toXML(product); System.out.println(result); } } and we\u0026rsquo;ll get a more compact JSON as a result:\n{\u0026#34;product\u0026#34;:{\u0026#34;name\u0026#34;:\u0026#34;Banana\u0026#34;,\u0026#34;id\u0026#34;:\u0026#34;123\u0026#34;,\u0026#34;price\u0026#34;:\u0026#34;23.0\u0026#34;}} You can grab the source of this driver from this:\nsvn co https://jqr.svn.sourceforge.net/svnroot/jqr/trunk/json json\nSubversion repository. If you are interested only in binary version, you can download it from here:\nhttp://surfnet.dl.sourceforge.net/sourceforge/jqr/jqr-json-1.0-SNAPSHOT.jar\nFor more complex examples you can look at unit tests. It also contains a driver based on BadgerFish Stax implementation (part of Jettison). It has the same problem with nested arrays and since I didn\u0026rsquo;t need it at the moment I left it as it is.\nIt currently includes patched Jettison source, but I\u0026rsquo;ll see to forward those changes where they belong and include Jettison as a dependency in the future. Frankly, this driver shouldn\u0026rsquo;t be a standalone code but integral part of some of those two projects. I\u0026rsquo;ll write here if anything changes about that, but if you need something like this today, you can take it from above locations.\n","date":"January 12, 2007","externalUrl":null,"permalink":"/posts/2007-01-12-java-and-json/","section":"Posts","summary":"It seems that JSON vs. XML debate was one of the hot topics for this winter. Again, I think that “vs.” part is sufficient and that both XML and JSON should have their place in overall technology landscape. One of the obvious JSON advantages is that it can be directly evaluated in JavaScript. And for the Ajax-world we live in, it is not a small thing.\nFor one project, I started looking for a library that would enable me easy transformations between Java and JSON data. JSON in Java looks nice, but what I really want is a more automated and configurable library like those we have for XML processing. My first thought was XStream since I like its simple API, extensible architecture, powerful converters and support for annotations. After first check I found that from version 1.2 on there is a partial support for JSON (which was logical thing to expect). So, currently you can serialize your Java objects to JSON format. Here’s a little example:\n","title":"Java and JSON","type":"posts"},{"content":"I have this project that started years ago and still uses old Apache 1.1 version of the XML-RPC library. A few days ago I needed to add an extra functionality to the services it exposes. The underlying API for the new service works a lot with array of objects which is not friendly with that version of XML-RPC library.\nThe thing is that up until version 3.x of Apache library, Vector and Hashtable were only Java classes that could be used for transferring collections (\u0026lt;array\u0026gt; and \u0026lt;struct\u0026gt; XML-RPC types respectively). So naturally, I thought this was an ideal opportunity to upgrade to 3.x version, which is much better in handling various Java constructs (Object[] among them) as XML-RPC types. This is where surprises started to pop up.\nFirst of all, the 3.x branch is not compatible with older versions. That’s usually not a problem, just provide a migration guide and it all should be well. But things are not that simple in this case. The problem with 3.x branch is that (so far) it doesn’t support registering objects as XML-RPC handlers. This is one of fundamental requests for this kind of library, and I still can’t believe how it could be missing in such a project. Instead, it is advised that you configure your handlers through properties file, such as:\nCalculator=org.apache.xmlrpc.demo.Calculator or the same thing thorough the code:\nPropertyHandlerMapping phm = new PropertyHandlerMapping(); phm.addHandler(\u0026#34;Calculator\u0026#34;, org.apache.xmlrpc.demo.Calculator.class); But I don’t want that. I want that my “fully-configured” objects serve requests. This approach, suggested by project documentation, forces that every object must be responsible for obtaining its own configuration, which is exactly the opposite of configuring our applications through various IoC containers (as preached in last few years). In this way there is no simple way in which you can expose your Spring beans through the XML-RPC interface.\nI’m aware that I can make my own implementation of the XmlRpcHandlerMapping interface (or some of its derivates), but I don’t really want to go that way. For now, it’s just simpler to modify my current handlers to return Vectors and Hashtables. So I’ll stick to the branch 2.x of the Apache’s library.\nAnd for the future, if I ever need to change my XML-RPC infrastructure, here’s my wish list (influenced mostly by positive experiences with XFire):\nSupport for “advanced” type conversion between Java and XML-RPC types\nSupport for annotation similar to those defined in JSR 181 (much simpler of course). I want to be able to say, this class is a handler for this URL and these methods should be exposed. The library should do the rest.\nSupport for Spring integration (in more than one way) - through servlets, remoting, XBeans, etc.\nNo need for standalone web-server, a proper Jetty integration would be more than enough.\nThe previous request simplifies the whole implementation a lot, since an appropriate HTTP server (Jetty in case of standalone applications) would be responsible of security and similar tasks.\nOr to put it in other words, it should be just an simple implementation of the protocol (with type support like in Apache 3.x) focused on good integration in Java infrastructure (as an easily configured component for various Java servers, containers and frameworks). No HTTP-related stuff is needed.\n","date":"December 1, 2006","externalUrl":null,"permalink":"/posts/2006-12-01-apache-xml-rpc-30-no-thanks/","section":"Posts","summary":"I have this project that started years ago and still uses old Apache 1.1 version of the XML-RPC library. A few days ago I needed to add an extra functionality to the services it exposes. The underlying API for the new service works a lot with array of objects which is not friendly with that version of XML-RPC library.\nThe thing is that up until version 3.x of Apache library, Vector and Hashtable were only Java classes that could be used for transferring collections (\u003carray\u003e and \u003cstruct\u003e XML-RPC types respectively). So naturally, I thought this was an ideal opportunity to upgrade to 3.x version, which is much better in handling various Java constructs (Object[] among them) as XML-RPC types. This is where surprises started to pop up.\n","title":"Apache XML-RPC 3.0 - No thanks","type":"posts"},{"content":"Every once in a while I get some WSDL file and a task to create a Java client (and a service for testing purposes) that will use a defined service. I\u0026rsquo;ve tried XFire a couple of times before (version was 1.1 in those days). But it never actually managed to create stub client and servers classes from \u0026ldquo;my\u0026rdquo; WSDL files. So, without much time left to investigate I usually decided to give it a bit more time and fallback to good old Axis. But, a few weeks ago everything changed. I got a definition file and decided to try XFire again. This time I found an Eclipse plugin for it, which does exactly what I needed to do. It needs Java 5 and Eclipse 3.2 \u0026hellip; checked and checked \u0026hellip; I ran the wizard that plugin provides, entered some basic facts (location of the file, package and the location for the generated sources) and that was all. I was up and running in under five minutes. Excellent. But that is not the end of the story. The real surprise came when I browsed the generated code. It was much more \u0026ldquo;elegant\u0026rdquo; (readable) then equivalent Axis stub. With a heavy use of annotations it will be much easier to maintain in the coming years. Also, support for XBeans and Spring definitely makes my life much easier with XFire. I didn\u0026rsquo;t have time to verify whether it is as efficient as people say, but it doesn\u0026rsquo;t matter for me at this moment. And with all good coding that has been put into that project, I don\u0026rsquo;t see how it could be any different. So with all modern features, elegant stub classes and \u0026ldquo;probably\u0026rdquo; good performance, I think that I will stick to the XFire for my future SOAP coding.\n","date":"November 17, 2006","externalUrl":null,"permalink":"/posts/2006-11-17-playing-with-xfire/","section":"Posts","summary":"Every once in a while I get some WSDL file and a task to create a Java client (and a service for testing purposes) that will use a defined service. I’ve tried XFire a couple of times before (version was 1.1 in those days). But it never actually managed to create stub client and servers classes from “my” WSDL files. So, without much time left to investigate I usually decided to give it a bit more time and fallback to good old Axis. But, a few weeks ago everything changed. I got a definition file and decided to try XFire again. This time I found an Eclipse plugin for it, which does exactly what I needed to do. It needs Java 5 and Eclipse 3.2 … checked and checked … I ran the wizard that plugin provides, entered some basic facts (location of the file, package and the location for the generated sources) and that was all. I was up and running in under five minutes. Excellent. But that is not the end of the story. The real surprise came when I browsed the generated code. It was much more “elegant” (readable) then equivalent Axis stub. With a heavy use of annotations it will be much easier to maintain in the coming years. Also, support for XBeans and Spring definitely makes my life much easier with XFire. I didn’t have time to verify whether it is as efficient as people say, but it doesn’t matter for me at this moment. And with all good coding that has been put into that project, I don’t see how it could be any different. So with all modern features, elegant stub classes and “probably” good performance, I think that I will stick to the XFire for my future SOAP coding.\n","title":"Playing with XFire","type":"posts"},{"content":"Reading this interview with Jean Elliott, director of product marketing for the Java SE platform at Sun Microsystems, got me into thinking about adoption of Java platform editions among developers (and plain users). I think that 1.4 is still very widely deployed runtime environment out there and that it is the main reason why many developers still hesitate to use Java 5 syntax and features in their projects.\nThere are three kinds of projects that we can differentiate:\napplications developed for the managed environments applications developed for unknown (potentially large) customer base and libraries developed to be used in other Java applications In the first case there is no restriction for the development team and their management to make an appropriate case study and upgrade their development and runtime environments. This is well documented in Wall-Mart\u0026rsquo;s case (mentioned even in Jean\u0026rsquo;s interview).\nIn other two cases, this issue becomes even more important because you don\u0026rsquo;t want to restrict yourself by limiting number of hosts (projects) your code is compatible with. But existence of Retrotranslator (and Retroweaver) project makes this excuse obsolete.\nRetrotranlator is a\nJava bytecode transformer that translates Java classes compiled with JDK 5.0 into classes that can be run on JVM 1.4\nwhich basically means that you can very easily make all of your Java 5 code compatible with JVM 1.4. Retrotranslator even offers Ant and Maven tasks that are very easy to use. So there is no reason why you shouldn\u0026rsquo;t modify your build process to create distributions for both platform editions. Of course, there are some limitations introduced in this process, so additional testing is required.\nI think that this is very important topic for wide range of Java projects and that would be great to see Sun back a project like this one.\n","date":"November 2, 2006","externalUrl":null,"permalink":"/posts/2006-11-02-retrotranslator/","section":"Posts","summary":"Reading this interview with Jean Elliott, director of product marketing for the Java SE platform at Sun Microsystems, got me into thinking about adoption of Java platform editions among developers (and plain users). I think that 1.4 is still very widely deployed runtime environment out there and that it is the main reason why many developers still hesitate to use Java 5 syntax and features in their projects.\nThere are three kinds of projects that we can differentiate:\n","title":"Retrotranslator","type":"posts"},{"content":"In this excellent article Christophe Coenraets gives few examples of how you can use Adobe Flex as a presentation layer for your Spring applications.\nIt is good to see that my Spring middle-layer classes could be reused with one more presentation technology. I like to have options.\n","date":"October 27, 2006","externalUrl":null,"permalink":"/posts/2006-10-27-spring-and-flex/","section":"Posts","summary":"In this excellent article Christophe Coenraets gives few examples of how you can use Adobe Flex as a presentation layer for your Spring applications.\nIt is good to see that my Spring middle-layer classes could be reused with one more presentation technology. I like to have options.\n","title":"Spring and Flex","type":"posts"},{"content":"In this post I will try to summarize a case-study for implementing Cross-Domain Ajax support for ActiveMQ.\nUse Case # In the current implementation of Ajax support for ActiveMQ, you can use JavaScript to consume and send messages, but only directly in your application. This stands mostly due to \u0026ldquo;same-domain\u0026rdquo; restriction of the XmlHttpRequest calls.\nThis makes impossible to use those messages in \u0026ldquo;trusted\u0026rdquo; applications and make them all use the same underlying mechanism. For example, you might want to create an embeddable Ajax message browser that could be used in various related applications to allow \u0026ldquo;operators\u0026rdquo; (non-technical people) to work with messages in certain queues and topics.\nPossible techniques # There are many techniques that are used today to solve this problem. Every one of them has its strengths and weaknesses. So here I will try to summarize all of them and find the best fit for messaging purposes and current ActiveMQ implementation.\n1. Proxy\nThis technique assumes that you put a server-side script on your client application. The purpose of this script is to get your local XmlHttpRequest calls and forward it to the \u0026ldquo;original\u0026rdquo; provider of the Ajax service. While this solution is perfectly valid, it is a little bit clumsy as a \u0026ldquo;general-purpose\u0026rdquo; solution, because we must provide proxies for many languages (Java, Ruby, PHP, \u0026hellip;) and developers must find a way to \u0026ldquo;install and configure\u0026rdquo; this proxy in their application.\n2. JSON and dynamic Script tag\nWith this technique you create a script tag that calls a remote JS script and define a callback function that script should call when it finishes. The remote script returns a result in JSON format and calls a function. In this way we have achieved a kind of web service functionality without using XML and XMLHttpRequest. The only problem with this solution is that it is impossible to do POST method calls with it, so it is hard to send messages with it. We can implement this solution for those who are only interested in consuming messages from arbitrary Ajax client.\n3. FlashXMLHttpRequest\nThanks to the Julien Couvreur\u0026rsquo;s excellent work (http://blog.monstuff.com/FlashXMLHttpRequest), there is another solution that is the most complete and would suit given requirement the best. It is basically a Flash proxy for HTTP calls that could be used directly from JavaScript. It supports both GET and POST methods, does not require any server-side proxy and could be designed to be compatible with current ActiveMQ Ajax API. The user would use the same approach as now\n\u0026lt;script type=\u0026#34;text/javascript\u0026#34; src=\u0026#34;http://example.com/amq.js\u0026#34;\u0026gt;\u0026lt;/script\u0026gt; \u0026lt;script type=\u0026#34;text/javascript\u0026#34;\u0026gt;amq.uri=\u0026#39;http://example.com/amq\u0026#39;;\u0026lt;/script\u0026gt; We would detect whether it is a cross-domain or a local call case. If it is a local call everything would be the same as now. In case of cross-domain usage we would include all necessary files and instantiate remote version of the amq object.\nImplementation # From now on, I will mostly focus on the third solution (FlashXMLHttpRequest) and talk about design issues. Besides detection of remote access and inclusion of appropriate libraries, there are several more things that should be changed on the server-side of the ActiveMQ Ajax implementation. First of all, FlashXMLHttpRequest does not support setting of arbitrary request headers. The only supported header in this moment is content-type. The current ActiveMQ Ajax implementation use request parameters to pass parameters between Ajax client and server. I thought a bit how we can deal with this issue and came with the solution that not only solves this issue, but also could make the whole implementation much more flexible and extensible in the future. It is practically a combination of methods two and three: JSON and Flash used together. The solution is to use JSON and send JavaScript objects between client and server. The MessageListenerServlet would make this special handling of requests that has text/javascript content type. It could parse the JSON object and use all necessary details from it (destination, priority, content \u0026hellip;). On the other hand, messages that are received by the client could be transformed into JavaScript objects and used directly further on. I have tried some experiments on this particular topic and it is evident that it could be easily built. In this way, we have the best of the solutions (POST method of the Flash client and JSON format for the messages). Also, since messages now are objects in JavaScript world too, we can extend them and build our solutions on them much easier. For example, we can now easily add support for MapMessages and client acknowledgment mode, to name two.\nSecurity # In the FlashXMLHttpRequest technique, the security is handled by the crossdomain.xml file. I\u0026rsquo;m aware that this solution also has some security problems (http://shiflett.org/archive/263), but since we are controlling the server-side of the solution we can implement various additional security mechanisms on top of that. Also, I see this solution as primarily used in private (not public) domain and applications that knows who should do they trust. So all this should be taken cared of in the final implementation. Of course, everything is open to discussion.\nConclusion # This post is intended to be a conversation starter. Any comments and ideas are welcome.\n","date":"October 18, 2006","externalUrl":null,"permalink":"/posts/2006-10-18-cross-domain-ajax-support-for-activemq/","section":"Posts","summary":"In this post I will try to summarize a case-study for implementing Cross-Domain Ajax support for ActiveMQ.\nUse Case # In the current implementation of Ajax support for ActiveMQ, you can use JavaScript to consume and send messages, but only directly in your application. This stands mostly due to “same-domain” restriction of the XmlHttpRequest calls.\nThis makes impossible to use those messages in “trusted” applications and make them all use the same underlying mechanism. For example, you might want to create an embeddable Ajax message browser that could be used in various related applications to allow “operators” (non-technical people) to work with messages in certain queues and topics.\n","title":"Cross-Domain Ajax support for ActiveMQ","type":"posts"},{"content":"As you probably know, Jetty is a web server (and servlet container) written purely in Java. Because it is small, fast and has a well designed configuration API it is often used as a embedded server in various Java applications (Continuum, FishEye, …).\nOf course, when you use Jetty in a Spring-based application, you will want to configure it as you configure the rest of your application (as a Spring bean). Since it has a well defined configuration API, this is not a problem to achieve.\nHere’s an example of a standard Spring bean that, if included in the configuration, would start Jetty on port 8181 and load a web application from the webapp subfolder:\n\u0026lt;bean id=\u0026#34;Server\u0026#34; class=\u0026#34;org.mortbay.jetty.Server\u0026#34; init-method=\u0026#34;start\u0026#34; destroy-method=\u0026#34;stop\u0026#34;\u0026gt; \u0026lt;property name=\u0026#34;connectors\u0026#34;\u0026gt; \u0026lt;list\u0026gt; \u0026lt;bean id=\u0026#34;Connector\u0026#34; class=\u0026#34;org.mortbay.jetty.nio.SelectChannelConnector\u0026#34;\u0026gt; \u0026lt;property name=\u0026#34;port\u0026#34; value=\u0026#34;8181\u0026#34;/\u0026gt; \u0026lt;/bean\u0026gt; \u0026lt;/list\u0026gt; \u0026lt;/property\u0026gt; \u0026lt;property name=\u0026#34;handler\u0026#34;\u0026gt; \u0026lt;bean id=\u0026#34;handlers\u0026#34; class=\u0026#34;org.mortbay.jetty.handler.HandlerCollection\u0026#34;\u0026gt; \u0026lt;property name=\u0026#34;handlers\u0026#34;\u0026gt; \u0026lt;list\u0026gt; \u0026lt;bean id=\u0026#34;contexts\u0026#34; class=\u0026#34;org.mortbay.jetty.handler.ContextHandlerCollection\u0026#34;\u0026gt; \u0026lt;property name=\u0026#34;handlers\u0026#34;\u0026gt; \u0026lt;list\u0026gt; \u0026lt;bean class=\u0026#34;org.mortbay.jetty.webapp.WebAppContext\u0026#34;\u0026gt; \u0026lt;property name=\u0026#34;contextPath\u0026#34; value=\u0026#34;/\u0026#34;/\u0026gt; \u0026lt;property name=\u0026#34;resourceBase\u0026#34; value=\u0026#34;webapp\u0026#34;/\u0026gt; \u0026lt;property name=\u0026#34;parentLoaderPriority\u0026#34; value=\u0026#34;false\u0026#34;/\u0026gt; \u0026lt;/bean\u0026gt; \u0026lt;/list\u0026gt; \u0026lt;/property\u0026gt; \u0026lt;/bean\u0026gt; \u0026lt;/list\u0026gt; \u0026lt;/property\u0026gt; \u0026lt;/bean\u0026gt; \u0026lt;/property\u0026gt; \u0026lt;/bean\u0026gt; Now, although this configuration is valid it is hard to read and maintain. But starting with Jetty 6, there is cure for this too. You have probably heard of XBean project. Among other things XBean, supports custom XML schemas that could be used inside Spring configuration files and Jetty 6 supports XBean configuration.\nTo demonstrate this we will create a XBean configuration snippet, which is equivalent to the above Spring bean:\n\u0026lt;jetty xmlns=\u0026#34;http://mortbay.com/schemas/jetty/1.0\u0026#34;\u0026gt; \u0026lt;connectors\u0026gt; \u0026lt;nioConnector port=\u0026#34;8181\u0026#34; /\u0026gt; \u0026lt;/connectors\u0026gt; \u0026lt;handlers\u0026gt; \u0026lt;webAppContext contextPath=\u0026#34;/\u0026#34; resourceBase=\u0026#34;webapp\u0026#34; parentLoaderPriority=\u0026#34;false\u0026#34; /\u0026gt; \u0026lt;/handlers\u0026gt; \u0026lt;/jetty\u0026gt; All that is left to be done is to include jetty-xbean-6.x.x.jar (x.x denotes a Jetty version) in your application’s classpath. You can find this JAR in the lib/xbean folder of the Jetty 6 distribution.\nThis XBean configuration is much more easier to write and maintain (and will certainly make your configuration files smaller). It’s good to see that development team puts a great effort in making Jetty play well with other Java technologies. Jetty 6 brings much more features then this simplified configuration. Some of these are NIO connectors and Servlet 2.5 specification, but they deserve a post of their own.\n","date":"October 12, 2006","externalUrl":null,"permalink":"/posts/2006-10-12-jetty-6-and-xbean/","section":"Posts","summary":"As you probably know, Jetty is a web server (and servlet container) written purely in Java. Because it is small, fast and has a well designed configuration API it is often used as a embedded server in various Java applications (Continuum, FishEye, …).\nOf course, when you use Jetty in a Spring-based application, you will want to configure it as you configure the rest of your application (as a Spring bean). Since it has a well defined configuration API, this is not a problem to achieve.\n","title":"Jetty 6 and XBean","type":"posts"},{"content":"Some time ago I needed a unique identifier generator that will look up a value in a simple name-value kind of database table. Project’s database layer was based on Hibernate2 and since I couldn’t find such a solution I have implemented a MultiTableGenerator which I have blogged about here.\nThe project was finished and I moved on. Since then, many people reported that my solution was not compatible with Hibernate3 but unfortunately I never found time to fix it. Luckily, I was recently reported that Hibernate team introduced this functionality in Hibernate3. The class is called org.hibernate.id.MultipleHiLoPerTableGenerator. As I can see, it is not documented in the latest version of the reference documentation yet, but you can find a description in a JavaDoc documentation.\nThe configuration syntax of these two solutions looks similar (parameter names have been changed), which makes it even easier to port functionality if you are migrating to Hibernate3. It is good to see useful stuff becoming a standard part of the library.\n","date":"September 26, 2006","externalUrl":null,"permalink":"/posts/2006-09-26-multiple-table-generator-in-hibernate3/","section":"Posts","summary":"Some time ago I needed a unique identifier generator that will look up a value in a simple name-value kind of database table. Project’s database layer was based on Hibernate2 and since I couldn’t find such a solution I have implemented a MultiTableGenerator which I have blogged about here.\nThe project was finished and I moved on. Since then, many people reported that my solution was not compatible with Hibernate3 but unfortunately I never found time to fix it. Luckily, I was recently reported that Hibernate team introduced this functionality in Hibernate3. The class is called org.hibernate.id.MultipleHiLoPerTableGenerator. As I can see, it is not documented in the latest version of the reference documentation yet, but you can find a description in a JavaDoc documentation.\n","title":"Multiple table generator in Hibernate3","type":"posts"},{"content":"As I said in the previous post, one of my main intentions is to use Stomp to send map messages from PHP to Java. So in this iteration, I have added support for JSON encoding/decoding of message content.\nBefore I dig deeper into new functionalities and changes, let me explain which JSON libraries (PHP and Java) I have used and why.\nDependencies # Even though since version 5.2.0, PHP has native support for JSON, I have used pure PHP implementation from Michal Migurski. I did this for only one reason: There is no any restriction to use it in PHP4.\nFor those interested in using PHP native JSON support in PHP5 or native C implementation by Omar Kilani, it should be easy to modify this work, since all JSON related code is encapsulated in one class (more about this later).\nFor current Java example, I have used JSON.simple toolkit. The only reason for this is that JSONObject inherits java.util.HashMap so it is much easier to process it in the client.\nAfter this brief discussion, it\u0026rsquo;s time to focus on changes made to the original version of the library.\nChanges # New classes # I\u0026rsquo;ve created three new classes:\nStompMessage BytesMessage MapMessage All this classes are inherited from basic StompFrame class and are used to encapsulate type-specific behavior.\nStompMessage is representation of JMS TextMessage. The example of its usage could be:\n$c-\u0026gt;send(\u0026#34;/queue/test\u0026#34;, new StompMessage(\u0026#34;test\u0026#34;)); Note that this is equivalent to the older syntax:\n$c-\u0026gt;send(\u0026#34;/queue/test\u0026#34;, \u0026#34;test\u0026#34;) So the usage of this class is not mandatory and it is here just for the library completeness.\nBytesMessage is not tested in more details. The only difference between this class and StompMessage is that it sets content-length header. It should be tested more.\nMapMessage is what this update is all about. Now you can easily create a MapMessage in the following manner:\n$msg = new MapMessage(array(\u0026#34;key1\u0026#34;=\u0026gt;\u0026#34;value1\u0026#34;, \u0026#34;key2\u0026#34;=\u0026gt;\u0026#34;value2\u0026#34;)); $c-\u0026gt;send(\u0026#34;/queue/test\u0026#34;, $msg); It will be encoded in JSON format and sent as JMS TextMessage to the broker. As I saw on some mailing list discussion, it is advised to mark this kind of special encodings with amq-msg-type header so that it complies with future pluggable Stomp message handlers in ActiveMQ. So this class also set MapMessage value for this header.\nAlso, when you consume messages with this library, if amq-msg-type is found and has MapMessage value, message content will be decoded and MapMessage will be returned to the client.\nHere\u0026rsquo;s an example:\n$message = $c-\u0026gt;readFrame(); if (is_a($message, \u0026#39;MapMessage\u0026#39;)) { foreach($message-\u0026gt;map as $key=\u0026gt;$value) { echo \u0026#34;$key =\u0026gt; $value\u0026#34;; } } else { print_r($message); } Examples of working with map messages could be found in the producer_map.php and consumer_map.php.\nJava client # I\u0026rsquo;ve created an example of Java message listener that consumes both JMS MapMessages and Stomp JSON messages.\nHere\u0026rsquo;s a snippet of code that shows how handling could be done:\nMap data = new HashMap(); if (message instanceof TextMessage) { String type = message.getStringProperty(\u0026#34;amq-msg-type\u0026#34;); if (type != null \u0026amp;\u0026amp; type.equals(\u0026#34;MapMessage\u0026#34;)) { data = (JSONObject)JSONValue.parse(((TextMessage)message).getText()); } else { throw new Exception(\u0026#34;Not valid JSON message\u0026#34;); } } else if (message instanceof MapMessage) { data = ((ActiveMQMapMessage)message).getContentMap(); } else { throw new Exception(message.getClass() + \u0026#34; is not valid type for this que\u0026#34;); } The whole example could be found in the ClientReceiver.java file. Of course, the next step would be to put this on the broker side, so that client gets an ordinary MapMessage. That\u0026rsquo;s something I\u0026rsquo;ll try to do next.\nMessage acknowledgment # While I was playing with message consumption I noticed that acknowledgment is a bit impractical to write:\n$id = $message-\u0026gt;headers[\u0026#39;message-id\u0026#39;]; $c-\u0026gt;ack($id); so I have enabled an easier syntax:\n$c-\u0026gt;ack($message); Of course, the old style is still valid.\nTo do \u0026hellip; # Testing and finishing ByteMessages Work on ActiveMQ pluggable handlers of Stomp messages ","date":"September 18, 2006","externalUrl":null,"permalink":"/posts/2006-09-18-stomp-and-json/","section":"Posts","summary":"As I said in the previous post, one of my main intentions is to use Stomp to send map messages from PHP to Java. So in this iteration, I have added support for JSON encoding/decoding of message content.\nBefore I dig deeper into new functionalities and changes, let me explain which JSON libraries (PHP and Java) I have used and why.\nDependencies # Even though since version 5.2.0, PHP has native support for JSON, I have used pure PHP implementation from Michal Migurski. I did this for only one reason: There is no any restriction to use it in PHP4.\n","title":"Stomp and JSON","type":"posts"},{"content":" Download # This work is based on Hiram Chirino\u0026rsquo;s excellent library. It would be great if this \u0026ldquo;extended\u0026rdquo; version become part of that project too, but for now you can grab it from here.\nWhile the original library is well written, there were few things that prevented me to use it in my project. I started by fixing those things, but then gone too far and now it is quite different from the original, so I\u0026rsquo;m putting it here.\nChanges # Here is the list of the things that I have changed:\nFixed some minor bugs - such as sending ABORT message instead of ACK)\nAdded failover transfer protocol support - This was my original motivation as I want to send messages from PHP to Java application that will use ActiveMQ high availability options (such as Master/Slave architecture of brokers). The suggested solution is to run a local broker that will server as a proxy to the HA cluster. I wanted to avoid this \u0026ldquo;middle man\u0026rdquo; approach and send messages directly to the appropriate broker. So I changed the connection routine and now instead of creating the connection with\n$c = new StompConnection(\u0026#39;s1.example.com\u0026#39;, 61613); you can use this construct:\n$c = new StompConnection (\u0026#39;failover://(tcp://s1.example.com:61613,tcp://s2.example.com:61613) ?randomize=false\u0026#39;); See producer.php and consumer.php examples for more details.\nAlso, once connected if library detects connection break (while writing or reading) it will try to reconnect to another broker and proceed with its operation.\nPlease note, that not all functionality of the failover transport protocol is currently implemented. See \u0026ldquo;To do \u0026hellip;\u0026rdquo; section for more details.\nRemoved Socket functions usage - There is nothing wrong with these functions, but for them to be used PHP must be compiled with --with-socket switch which often is not the case. Also, there is no much real benefits over using fsockopen(), fwrite() and fread() so I think this will make this library usable in a broader range of environments.\ntrigger_error() (instead of die()) - I have user trigger_error PHP function instead of die to log messages and report errors. In this way library will play much nicer with PHP applications.\nProblems encountered # As I said, my primary usage of this library will currently be to reliably send messages from PHP to Java. There was one interesting problem that I have encountered that I will document here.\nIn case that master broker dies, socket on the server goes into FIN_WAIT_2. That is OK, but it leaves socket on the client (PHP) side in CLOSE_WAIT state for a while. This means that next message sent from the same PHP script will be send as if nothing had happened and only while sending the following message PHP will trigger an error. Of course, this leads to message loss which is not acceptable. This is why I send an empty (^@) message before any real message is sent. I know that it is not a clean solution but it works. Any advice on this topic is more than welcome.\nKnown issues # As I modified this library for my own purposes I didn\u0026rsquo;t polished its details for things that I won\u0026rsquo;t be using at this moment:\nAs I don\u0026rsquo;t attend to read messages from PHP, I haven\u0026rsquo;t put much effort in this part of the library. It generally works (as in original but with reconnect functionality) but I noticed some strange things from time to time, so be sure to test it thoroughly before you use it in production. I\u0026rsquo;ll also try to find some time in the future to work on this To do \u0026hellip; # Some things that will be subject to more work in the future:\nParse all failover transport URL parameters - Currently, there is only the difference whether you are using randomize parameter. The number of reconnection attempts is hardcoded to 10. I would like to support all parameters available. Test it more Test and work on message consumption - see \u0026ldquo;Known issues\u0026rdquo; JSON and MapMessges - I plan also to send a kind of maps from my PHP application. I think that the best way would be to use JSON format for coding and encoding. I\u0026rsquo;ll try to experiment with this in the coming days and let know the results. For starters, I\u0026rsquo;ll decode messages in my message listener, but maybe it would be a good idea to support this in the ActiveMQ Stomp implementation (message would be marked with special header). I think that JSON is the best solution, because it is simple and the there is a library available for almost any scripting language, so it can be quickly implemented in existing Stomp clients. Conclusion # While this is not finished work, I hope that I have made this library more usable than it was. Any feedback is more than welcome.\n","date":"September 14, 2006","externalUrl":null,"permalink":"/posts/2006-09-14-php-stomp-client/","section":"Posts","summary":"Download # This work is based on Hiram Chirino’s excellent library. It would be great if this “extended” version become part of that project too, but for now you can grab it from here.\nWhile the original library is well written, there were few things that prevented me to use it in my project. I started by fixing those things, but then gone too far and now it is quite different from the original, so I’m putting it here.\n","title":"PHP Stomp client","type":"posts"},{"content":"First of all, I never use Jakarta Commons Logging (JCL) directly in my applications (Log4J is my tool of choice for logging tasks), but as you probably know many frameworks and libraries do all of their logging through JCL. In most cases you will want to catch some of these log messages, so that you can better monitor your application. For example, you will probably want to log all SQL queries that Hibernate issues, at least in the early development phase, so that you can have a better perspective of what is going on.\nI usually don\u0026rsquo;t have a problem with JCL since it finds a Log4J implementation in the classpath, get my configuration and all works fine. Except when it doesn\u0026rsquo;t.\nIn this particular case, I had a Spring-Hibernate based web application that I needed to deploy on the Tomcat 5 server. After deploying an application, commons logging couldn\u0026rsquo;t find a log4j implementation and all logs were redirected to the standard Tomcat log file.\nContinue reading on onJava.com\n","date":"August 29, 2006","externalUrl":null,"permalink":"/posts/2006-08-29-tomcat-5x-commons-logging-and-log4j/","section":"Posts","summary":"First of all, I never use Jakarta Commons Logging (JCL) directly in my applications (Log4J is my tool of choice for logging tasks), but as you probably know many frameworks and libraries do all of their logging through JCL. In most cases you will want to catch some of these log messages, so that you can better monitor your application. For example, you will probably want to log all SQL queries that Hibernate issues, at least in the early development phase, so that you can have a better perspective of what is going on.\n","title":"Tomcat 5.x, Commons Logging and Log4J","type":"posts"},{"content":"It seems like growing interest in dynamic languages will finally move Java syntax toward local functions and closures. Gilad Bracha, Neal Gafter, James Gosling and Peter von der Ah\n","date":"August 21, 2006","externalUrl":null,"permalink":"/posts/2006-08-21-will-we-have-closures-in-java-17/","section":"Posts","summary":"It seems like growing interest in dynamic languages will finally move Java syntax toward local functions and closures. Gilad Bracha, Neal Gafter, James Gosling and Peter von der Ah\n","title":"Will we have closures in Java 1.7?","type":"posts"},{"content":"It\u0026rsquo;s finally here. According to news and blogs, Sun announced that it will open source Java ME platform and some components of the SE platform by the end of the year. Sun plans to open source javac compiler and HotSpot virtual machine, two crucial components of the Java SE platform, by the end of the year. The rest of the SE platform should be open sourced during the next year.\nThey will use some of the proven OSI licenses, but the particular license and governance model is yet to be settled. You can visit the official site for this project and make your contribution to these discussions in the forum.\nFinally, here are some thoughts on open source Java from Geir Magnusson Jr. one of the founders of the Apache Harmony project.\n","date":"August 15, 2006","externalUrl":null,"permalink":"/posts/2006-08-15-java-open-source-roadmap/","section":"Posts","summary":"It’s finally here. According to news and blogs, Sun announced that it will open source Java ME platform and some components of the SE platform by the end of the year. Sun plans to open source javac compiler and HotSpot virtual machine, two crucial components of the Java SE platform, by the end of the year. The rest of the SE platform should be open sourced during the next year.\nThey will use some of the proven OSI licenses, but the particular license and governance model is yet to be settled. You can visit the official site for this project and make your contribution to these discussions in the forum.\n","title":"Java open-source roadmap","type":"posts"},{"content":"First of all, SOAP is not my web service protocol of choice since I think it is overkill for the most of applications. I prefer the simplest possible solution for the problem, but when the service that you need is only available through SOAP, you don\n","date":"August 14, 2006","externalUrl":null,"permalink":"/posts/2006-08-14-handling-adonet-datasets-with-axis/","section":"Posts","summary":"First of all, SOAP is not my web service protocol of choice since I think it is overkill for the most of applications. I prefer the simplest possible solution for the problem, but when the service that you need is only available through SOAP, you don\n","title":"Handling ADO.NET DataSets with Axis","type":"posts"},{"content":"There were a lot of discussions lately about inclusion of Derby (aka JavaDB) in the Sun JDK. First of all, I personally think that it will not really change anything.\nI\n","date":"July 27, 2006","externalUrl":null,"permalink":"/posts/2006-07-27-on-derby/","section":"Posts","summary":"There were a lot of discussions lately about inclusion of Derby (aka JavaDB) in the Sun JDK. First of all, I personally think that it will not really change anything.\nI\n","title":"On Derby\u0026#8230;","type":"posts"},{"content":"If you ever needed to parse form-based multipart data, you are probably aware of the Jakarta Commons FileUpload library. But while this library is primarily intended to parse data directly from HttpRequest objects and thus handle uploading of files in your web application, it could be used to parse an arbitrary InputStream and extract multiparts from it too.\nAs you can probably guess, the part of the library that is related to handling file uploads is well documented, but for the low-level API you can only find the broken example in the JavaDocs. I know that this funcionality is rarely needed, but still it deserves a working example, so here it is.\nContinue reading on onJava\n","date":"June 28, 2006","externalUrl":null,"permalink":"/posts/2006-06-28-parsing-form-data-multiparts-2/","section":"Posts","summary":"If you ever needed to parse form-based multipart data, you are probably aware of the Jakarta Commons FileUpload library. But while this library is primarily intended to parse data directly from HttpRequest objects and thus handle uploading of files in your web application, it could be used to parse an arbitrary InputStream and extract multiparts from it too.\nAs you can probably guess, the part of the library that is related to handling file uploads is well documented, but for the low-level API you can only find the broken example in the JavaDocs. I know that this funcionality is rarely needed, but still it deserves a working example, so here it is.\n","title":"Parsing form-data multiparts","type":"posts"},{"content":"It is common to use final static fields to define constants in your Java applications. For example, you will often find the code similar to this in various Java APIs\npublic class Example { public static int one = 1; } which is used in the following manner\nSystem.out.println(Example.one); Of course, Java supports more complex initialization of static properties through static initializer blocks. One of the most common usages for these blocks is initialization of static collections with known values.\nTake a look at the following code for example:\npublic class Example { public final static HashMap constants = new HashMap(); static { constants.put(\u0026#34;1\u0026#34;, \u0026#34;First\u0026#34;); constants.put(\u0026#34;2\u0026#34;, \u0026#34;Second\u0026#34;); constants.put(\u0026#34;3\u0026#34;, \u0026#34;Third\u0026#34;); } } and the usage of such static collection:\nSystem.out.println(Example.constants.get(\u0026#34;1\u0026#34;)); Wouldn\u0026rsquo;t you prefer to have more \u0026ldquo;native\u0026rdquo; support in Java for dealing with collections? For example, with the syntax that is found in most \u0026ldquo;dynamic\u0026rdquo; languages today, the previous example could be replaced with something like this:\npublic final static HashMap constants = new HashMap() { \u0026#34;1\u0026#34; : \u0026#34;First\u0026#34;, \u0026#34;2\u0026#34; : \u0026#34;Second\u0026#34;, \u0026#34;3\u0026#34; : \u0026#34;Third\u0026#34; } Collections are one of the crucial aspects of programming languages and would it be normal to see them embedded in the language syntax? Would this \u0026ldquo;dynamic\u0026rdquo; syntax, used in Ruby, Groovy and other dynamic languages, make Java applications easier to write (and read)?\nDo you have other syntax enchacements that you would like to see in the following editions of Java?\n","date":"June 5, 2006","externalUrl":null,"permalink":"/posts/2006-06-05-syntax-support-for-collections/","section":"Posts","summary":"It is common to use final static fields to define constants in your Java applications. For example, you will often find the code similar to this in various Java APIs\npublic class Example { public static int one = 1; } which is used in the following manner\nSystem.out.println(Example.one); Of course, Java supports more complex initialization of static properties through static initializer blocks. One of the most common usages for these blocks is initialization of static collections with known values.\n","title":"Syntax support for collections?","type":"posts"},{"content":"There is an interesting Ajax-related proposal in Apache incubator, named XAP (eXtensible Ajax Platform). It is a project donated by Nexaweb Technologies Inc and represents XML-based declarative framework for building rich internet applications based on Ajax. You can find more information about this project on Nexaweb site\nIn the proposal there is the following paragraph:\nAlthough these toolkits ease development of Ajax-powered web applications, there are still significant development and maintenance challenges, mainly associated with writing, debugging and maintaining JavaScript code. In particular, some developers would prefer not to use JavaScript.\nI’m not sure whether XML is easier to debug and maintain than JavaScript and also whether any XML-declarative framework can have the same flexibility for writing GUIs as scripting language? Also, why we need another XML dialect when there is XUL which is mature and proven in practice. Do you think that JavaScript is the weak point of Ajax and how would you overcome it?\n","date":"May 26, 2006","externalUrl":null,"permalink":"/posts/2006-05-26-xap-proposal-in-apache-incubator/","section":"Posts","summary":"There is an interesting Ajax-related proposal in Apache incubator, named XAP (eXtensible Ajax Platform). It is a project donated by Nexaweb Technologies Inc and represents XML-based declarative framework for building rich internet applications based on Ajax. You can find more information about this project on Nexaweb site\nIn the proposal there is the following paragraph:\nAlthough these toolkits ease development of Ajax-powered web applications, there are still significant development and maintenance challenges, mainly associated with writing, debugging and maintaining JavaScript code. In particular, some developers would prefer not to use JavaScript.\n","title":"XAP proposal in Apache incubator","type":"posts"},{"content":"Recently I needed to display some information on the web page according to the value of a cookie. I think that this is one of the common web application functionalities that have been around for a decade. If you have ever used Spring MVC you know that view resolvers could be instructed to expose request and session attributes as view variables. It is done through the\n\u0026lt;property name=\u0026#34;exposeSessionAttributes\u0026#34;\u0026gt;\u0026lt;value\u0026gt;true\u0026lt;/value\u0026gt;\u0026lt;/property\u0026gt; \u0026lt;property name=\u0026#34;exposeRequestAttributes\u0026#34;\u0026gt;\u0026lt;value\u0026gt;true\u0026lt;/value\u0026gt;\u0026lt;/property\u0026gt; properties in the appropriate view resolver configuration. I wonder why there is no similar functionality for cookies, such as:\n\u0026lt;property name=\u0026#34;exposeCookies\u0026#34;\u0026gt;\u0026lt;value\u0026gt;true\u0026lt;/value\u0026gt;\u0026lt;/property\u0026gt; or something similar.\nCurrently you have two options to deal with this issue:\nFind cookies of interest in the controller and add it to the model manually. Deal with the cookies in the view by using JavaScript. I know that both of these ways are perfectly valid and will do the trick for you, but this is one of the fundamental web features (and so easy to implement) that I wonder how no one asked for it before. I googled for it and found nothing. Or am I just missing something?\n","date":"May 1, 2006","externalUrl":null,"permalink":"/posts/2006-05-01-spring-mvc-exposing-cookies-to-the-view/","section":"Posts","summary":"Recently I needed to display some information on the web page according to the value of a cookie. I think that this is one of the common web application functionalities that have been around for a decade. If you have ever used Spring MVC you know that view resolvers could be instructed to expose request and session attributes as view variables. It is done through the\n\u003cproperty name=\"exposeSessionAttributes\"\u003e\u003cvalue\u003etrue\u003c/value\u003e\u003c/property\u003e \u003cproperty name=\"exposeRequestAttributes\"\u003e\u003cvalue\u003etrue\u003c/value\u003e\u003c/property\u003e properties in the appropriate view resolver configuration. I wonder why there is no similar functionality for cookies, such as:\n","title":"Spring MVC: Exposing cookies to the view","type":"posts"},{"content":"I just saw the release note for DWR 2.0 milestone 1. It introduces many new features, but the most interesting is certainly \u0026ldquo;Reverse Ajax\u0026rdquo;, which allows Java code to asynchronously call JavaScript code in the browser.\nI\u0026rsquo;ve used DWR on few projects in the past and I find it to be a very good AJAX implementation for Java. Also, I can think of some very good use-cases for these new features, so I will certainly put my hands on this new release soon. How about you? What is your experience with DWR and what do you think of these new capabilities?\n","date":"April 12, 2006","externalUrl":null,"permalink":"/posts/2006-04-12-dwr-20/","section":"Posts","summary":"I just saw the release note for DWR 2.0 milestone 1. It introduces many new features, but the most interesting is certainly “Reverse Ajax”, which allows Java code to asynchronously call JavaScript code in the browser.\nI’ve used DWR on few projects in the past and I find it to be a very good AJAX implementation for Java. Also, I can think of some very good use-cases for these new features, so I will certainly put my hands on this new release soon. How about you? What is your experience with DWR and what do you think of these new capabilities?\n","title":"DWR 2.0","type":"posts"},{"content":"I will be speaking on Quartz scheduler in Novi Sad on April 19th, 2006. The full announcement can be found here (in Sebian).\n","date":"April 11, 2006","externalUrl":null,"permalink":"/posts/2006-04-11-jug-ns-session/","section":"Posts","summary":"I will be speaking on Quartz scheduler in Novi Sad on April 19th, 2006. The full announcement can be found here (in Sebian).\n","title":"JUG-NS session","type":"posts"},{"content":"In the previous post I showed how you can make a Spring wrapper around the WebServer object and thus configure it easily in Spring-based applications. This solution is good for standalone applications that use Spring as a configuration mechanism. But if you are using Spring MVC to develop web applications you probably don\u0026rsquo;t want to start another web server to handle XML-RPC calls. Instead, we have to find a way to configure XML-RPC to work with the web server that hosts our application and again to use our beans as XML-RPC handlers.\nOn the first look I thought that the easiest way to achieve this is to wrap the XmlRpcServlet (available from version 3.0 on) in the ServletWrappingController. But when I started looking at the code I found a solution that is much more simple and elegant.\nContinue reading on onJava\n","date":"April 7, 2006","externalUrl":null,"permalink":"/posts/2006-04-07-apache-xml-rpc-adapter-continued/","section":"Posts","summary":"In the previous post I showed how you can make a Spring wrapper around the WebServer object and thus configure it easily in Spring-based applications. This solution is good for standalone applications that use Spring as a configuration mechanism. But if you are using Spring MVC to develop web applications you probably don’t want to start another web server to handle XML-RPC calls. Instead, we have to find a way to configure XML-RPC to work with the web server that hosts our application and again to use our beans as XML-RPC handlers.\n","title":"Apache XML-RPC adapter continued","type":"posts"},{"content":"OnJava published an article titled Advanced Configuration of the Spring MVC Framework\n","date":"March 24, 2006","externalUrl":null,"permalink":"/posts/2006-03-24-advanced-configuration-of-the-spring-mvc-framework/","section":"Posts","summary":"OnJava published an article titled Advanced Configuration of the Spring MVC Framework\n","title":"Advanced Configuration of the Spring MVC Framework","type":"posts"},{"content":"I tend to use XML-RPC to implement simple requirements for connecting applications. The reason is that it is a simple, straighforward remote-procedure protocol that has good-enough performance for most of such applications. Also, it is very wide-spread so you can find a stable implementation for whatever platform you need it (for example you can use it to connect Java and PHP applications).\nWhen it comes to Java, I use the Apache XML-RPC library (http://ws.apache.org/xmlrpc/). Reasons: it\u0026rsquo;s been long time in development, it\u0026rsquo;s stable and I never had any problems with it.\nNow, most of the applications that I write lately are based on the Spring framework, so obviously I needed an adapter (bean factory) for the Apache XML-RPC server. Since I haven\u0026rsquo;t found one, I had to write it by myself.\nread more on onJava\n","date":"March 20, 2006","externalUrl":null,"permalink":"/posts/2006-03-20-apache-xml-rpc-adapter-for-spring/","section":"Posts","summary":"I tend to use XML-RPC to implement simple requirements for connecting applications. The reason is that it is a simple, straighforward remote-procedure protocol that has good-enough performance for most of such applications. Also, it is very wide-spread so you can find a stable implementation for whatever platform you need it (for example you can use it to connect Java and PHP applications).\nWhen it comes to Java, I use the Apache XML-RPC library (http://ws.apache.org/xmlrpc/). Reasons: it’s been long time in development, it’s stable and I never had any problems with it.\n","title":"Apache XML-RPC Adapter for Spring","type":"posts"},{"content":"This is the issue that I keep running into on various projects, so even if it seems obvious I think it is worth spending a post on it.\nSome OR mapping frameworks tend to use batch update operations when dealing with the database. The \u0026ldquo;problem\u0026rdquo; that this approach introduces is that if any problem occurs during the update, a java.sql.BatchUpdateException exception will be thrown instead of the regular java.sql.SQLException. If we don\u0026rsquo;t handle BatchUpdateException properly the message it will give us will not be very useful.\ncontinue reading on onJava\n","date":"March 10, 2006","externalUrl":null,"permalink":"/posts/2006-03-10-proper-handling-of-database-related-exceptions/","section":"Posts","summary":"This is the issue that I keep running into on various projects, so even if it seems obvious I think it is worth spending a post on it.\nSome OR mapping frameworks tend to use batch update operations when dealing with the database. The “problem” that this approach introduces is that if any problem occurs during the update, a java.sql.BatchUpdateException exception will be thrown instead of the regular java.sql.SQLException. If we don’t handle BatchUpdateException properly the message it will give us will not be very useful.\n","title":"Proper handling of database-related exceptions","type":"posts"},{"content":"onJava.com published an article on texting with Java\n","date":"June 9, 2004","externalUrl":null,"permalink":"/posts/2004-06-09-sms-powered-applications/","section":"Posts","summary":"onJava.com published an article on texting with Java\n","title":"SMS-Powered applications","type":"posts"},{"content":"This key generator is designed to enable Hibernate to generate unique keys using the table structure like this one\nThe keys that you get from database can be used directly or with HiLo algorithm (use MultipleTableHiLoGenerator class in that case).\nUsage # If you want to generate keys for your objects with this generator, just change \u0026lt;id\u0026gt; section in appropriate hbm.xml file to something like this.\n\u0026lt;id name=\u0026#34;id\u0026#34; type=\u0026#34;long\u0026#34; column=\u0026#34;cat_id\u0026#34;\u0026gt; \u0026lt;generator class=\u0026#34;net.nighttale.hibernate.MultipleTableGenerator\u0026#34;\u0026gt; \u0026lt;param name=\u0026#34;table\u0026#34;\u0026gt;keys\u0026lt;/param\u0026gt; \u0026lt;param name=\u0026#34;column_name\u0026#34;\u0026gt;key\u0026lt;/param\u0026gt; \u0026lt;param name=\u0026#34;column_value\u0026#34;\u0026gt;next_value\u0026lt;/param\u0026gt; \u0026lt;param name=\u0026#34;counter_name\u0026#34;\u0026gt;ids\u0026lt;/param\u0026gt; \u0026lt;/generator\u0026gt; \u0026lt;/id\u0026gt; Default parameter values are\ntable=hibernate_unique_keys column_name=name column_value=value counter_name=default and if you want to use some of them, you can left that tag out of the configuration.\nIn order to use this key generator, you\u0026rsquo;ll have to generate appropriate table with following DDL\nCREATE TABLE hibernate_unique_keys ( name VARCHAR(255) NOT NULL, value INTEGER, PRIMARY KEY(name) ) or let the Hibernate do it by setting Environment.HBM2DDL_AUTO property to create value.\nInstallation # Installation is easy, just download the source code from here, unzip it and put it somewhere in your classpath.\n","date":"June 6, 2004","externalUrl":null,"permalink":"/posts/2004-06-06-hibernate-mulitpletablegenerator/","section":"Posts","summary":"This key generator is designed to enable Hibernate to generate unique keys using the table structure like this one\nThe keys that you get from database can be used directly or with HiLo algorithm (use MultipleTableHiLoGenerator class in that case).\n","title":"Hibernate MulitpleTableGenerator","type":"posts"},{"content":"onJava.com published article on job scheduling with Java and Quartz\n","date":"March 10, 2004","externalUrl":null,"permalink":"/posts/2004-03-10-job-scheduling-in-java/","section":"Posts","summary":"onJava.com published article on job scheduling with Java and Quartz\n","title":"Job Scheduling in Java","type":"posts"},{"content":"Introduction # This patch is made for Quartz 1.2.3\nJava job scheduler and it extends original Scheduler interface with getExecutedJobs() method that returns list of recently executed jobs. Size of the list is configurabile with org.quartz.scheduler.executedJobsListSize parameter in property file (quartz.properties). It could be also turned off by specifying value 0 or by deleteing this entry from the property file. This patch works even for volatile Jobs and Triggers and doesn\u0026rsquo;t use database.\nInstallation # First you will need the source of Quartz 1.2.3 library. You can download this library from the Sourceforge download page for this release. Then you should download patch from here\nExtract library and copy the patch in the root directory of the extracted archive. Next you should apply the patch with the following line.\n$ patch -u -p 1 -i quartz_recentjobs.patch After these steps, build the Quartz by typing\n$ ant Compiled library is located at\nlib/quartz.jar library is extended with one more method in the interface.\n","date":"December 1, 2003","externalUrl":null,"permalink":"/posts/2003-12-01-quartz-recent-jobs-patch-2/","section":"Posts","summary":"Introduction # This patch is made for Quartz 1.2.3\nJava job scheduler and it extends original Scheduler interface with getExecutedJobs() method that returns list of recently executed jobs. Size of the list is configurabile with org.quartz.scheduler.executedJobsListSize parameter in property file (quartz.properties). It could be also turned off by specifying value 0 or by deleteing this entry from the property file. This patch works even for volatile Jobs and Triggers and doesn’t use database.\n","title":"Quartz recent jobs patch","type":"posts"},{"content":"This patch is made for Quartz 1.2.3\nJava job scheduler and it extends original Scheduler interface with getExecutedJobs() method that returns list of recently executed jobs. Size of the list is configurabile with org.quartz.scheduler.executedJobsListSize parameter in property file (quartz.properties). It could be also turned off by specifying value 0 or by deleteing this entry from the property file. This patch works even for volatile Jobs and Triggers and doesn\u0026rsquo;t use database.\nInstallation # First you will need the source of Quartz 1.2.3 library. You can download this library from the Sourceforge download page for this release. Then you should download patch from here\nExtract library and copy the patch in the root directory of the extracted archive. Next you should apply the patch with the following line.\n$ patch -u -p 1 -i quartz_recentjobs.patch After these steps, build the Quartz by typing\n$ ant Compiled library is located at\nlib/quartz.jar library is extended with one more method in the interface.\n","date":"December 1, 2003","externalUrl":null,"permalink":"/posts/2003-12-01-quartz-recent-jobs-patch/","section":"Posts","summary":"This patch is made for Quartz 1.2.3\nJava job scheduler and it extends original Scheduler interface with getExecutedJobs() method that returns list of recently executed jobs. Size of the list is configurabile with org.quartz.scheduler.executedJobsListSize parameter in property file (quartz.properties). It could be also turned off by specifying value 0 or by deleteing this entry from the property file. This patch works even for volatile Jobs and Triggers and doesn’t use database.\n","title":"Quartz recent jobs patch","type":"posts"},{"content":"php|architect published introductory article on version control with CVS\n","date":"November 12, 2003","externalUrl":null,"permalink":"/posts/2003-11-12-introduction-to-version-control-with-cvs/","section":"Posts","summary":"php|architect published introductory article on version control with CVS\n","title":"Introduction to Version Control with CVS","type":"posts"},{"content":"Quartz is a powerful job scheduling system for Java. Here you can find a XML-RPC plugin that can enable you to use the Quartz as a web service using XML-RPC protocol. You can use this plugin for accessing Quartz API from other languages than Java, such as PHP for example. Also, you can use it from your distributed Java application if you find this way more appropriate than RMI.\nPrerequisites # This is plugin for Quartz, java job scheduling system\nIt relays on Apache XML-RPC library.\nIn order to easily build quartz with this plugin according to the \u0026lsquo;Installation\u0026rsquo; procedure, you would also need to have Ant installed.\nInstallation # Download the source code of the Quartz and extract to the desired location\nDownload the plugin archieve from here and extract to in the same folder as Quartz\nMake sure that Apache XMLRPC library is in the classpath. The best approach is too copy jar file in the $QUARTZ_HOME/lib directory (needed for running the examples) and type something like this (just an example)\nexport CLASSPATH=$CLASSPATH:$QUARTZ_HOME/lib/xmlrpc-1.1.jar Run ant\n$ ant Quartz library ready for use will be at the $QUARTZ_HOME/lib/quartz.jar\nUsage # There are fully functional example that shows how to use this plugin:\norg.quartz.examples.XmlRpcServerTest - class that shows how to initialize server side of the plugin\norg.quartz.examples.XmlRpcClientTest - class that shows how use plugin on the client side\nexamples/xmlrpc.properties - configuration file for this example\nexamples/xmlRpcServerExample.sh - shell script for running the server example\nexamples/xmlRpcClientExample.sh - shell script for running the client example\nTo run this example, you should:\nBuild example jar by running\n$ ant jar-ex Edit .sh files and set\nQRTZ = ... variable to point to your quartz home\nIf you didn\u0026rsquo;t copy XML-RPC jar in the lib/ directory, do it now\nRun xmlRpcServerExample.sh\nRun xmlRpcClientExample.sh in another terminal window\nAfter this, in the server (first) terminal you should see something like the following:\n---dumb.dumb executing.[Mon Nov 03 22:01:18 CET 2003] ---dumb.dumb executing.[Mon Nov 03 22:01:28 CET 2003] ---dumb.dumb executing.[Mon Nov 03 22:01:38 CET 2003] ---dumb.dumb executing.[Mon Nov 03 22:01:48 CET 2003] ---dumb.dumb executing.[Mon Nov 03 22:01:58 CET 2003] ---dumb.dumb executing.[Mon Nov 03 22:02:08 CET 2003] ---dumb.dumb executing.[Mon Nov 03 22:02:18 CET 2003]","date":"November 1, 2003","externalUrl":null,"permalink":"/posts/2003-11-01-quartz-xml-rpc-plugin/","section":"Posts","summary":"Quartz is a powerful job scheduling system for Java. Here you can find a XML-RPC plugin that can enable you to use the Quartz as a web service using XML-RPC protocol. You can use this plugin for accessing Quartz API from other languages than Java, such as PHP for example. Also, you can use it from your distributed Java application if you find this way more appropriate than RMI.\n","title":"Quartz XML-RPC plugin","type":"posts"},{"content":"php|architect published introductory article on Bug management\n","date":"September 8, 2003","externalUrl":null,"permalink":"/posts/2003-09-08-introduction-to-bug-management/","section":"Posts","summary":"php|architect published introductory article on Bug management\n","title":"Introduction to Bug Management","type":"posts"},{"content":"In the beginning \u0026hellip; # PHP was designed as scripting language used to develop Web based applications. Because of its flexibility, extensibility and ease of use it became widely popular among developers, and pretty fast the large community was created. As time was passing, people wanted to develop more complex applications with it, but PHP was designed for page centric architecture with very limited support for object-oriented programming. Also, there was no system support for transactions, caching, software components and all the other things that developers of the enterprise applications have used to have. There was no application container that would take care of all the system staff that we need in our applications, so that we can focus on business requirements. As applications are getting larger and more complex scalability becomes a new issue. PHP does not scale well and there is no easy and standard way to make a cluster to achieve better scalability. So, PHP applications (with respectable exceptions) were left in the area of small and middle complex web applications.\nMeanwhile \u0026hellip; # Sun\n","date":"July 8, 2003","externalUrl":null,"permalink":"/posts/2003-07-08-scripting-the-enterprise/","section":"Posts","summary":"In the beginning … # PHP was designed as scripting language used to develop Web based applications. Because of its flexibility, extensibility and ease of use it became widely popular among developers, and pretty fast the large community was created. As time was passing, people wanted to develop more complex applications with it, but PHP was designed for page centric architecture with very limited support for object-oriented programming. Also, there was no system support for transactions, caching, software components and all the other things that developers of the enterprise applications have used to have. There was no application container that would take care of all the system staff that we need in our applications, so that we can focus on business requirements. As applications are getting larger and more complex scalability becomes a new issue. PHP does not scale well and there is no easy and standard way to make a cluster to achieve better scalability. So, PHP applications (with respectable exceptions) were left in the area of small and middle complex web applications.\n","title":"Scripting the enterprise","type":"posts"},{"content":"Introduction # This is version 0.1 of small application that demonstrates how to use EJB technology and Struts web development framework together. It is a personal organizer that let\u0026rsquo;s its users to manage their tasks and events. Don\u0026rsquo;t expect high usability of this software (in some future versions it will be considered) because it is only ment to be a demo.\nDemonstrating # In this version software demonstrates:\nHow to write and configure Enterprise Java Beans (with bean managed persistance)\nHow to write and configure basic Struts classes and files\nHow to use EJBs in Struts framework\nHow to use some other web technologies (e.g. CSS,\u0026hellip;) in your projects\nHow to use Ant in J2EE development\nHow to configure and deploy this application on JBoss application server\nPrerequisites # In order to run this demo you need to aquire and install few other software packages:\nApplication server - You must install J2EE apllication server. This demo is developed for JBoss applications server, but you can use any other server you want.\nDatabase server - You must install database server. This demo is developed for Postgres database server, but you can use any server of your choice as long it has JDBC driver.\nStruts framework - You must install Struts framework. Visit Struts official site at http://jakarta.apache.org/struts/\nAnt build system - You must install Ant build system. Visit Ant official site at http://jakarta.apache.org/ant/\nInstallation # This are steps neccessary for deployment of \u0026ldquo;arno\u0026rdquo; on JBoss 3 application server using Postgres 7 database server on Linux. For any other enviroment you should consult appropriate documentation. Some steps are common to all enviroments.\nDownload source code archive of arno from here\nExtract archive - If you are using Linux, type\ntar zxvf arno-0.1.tar.gz Create database named arno - If you are using Postgres on Linux, type something like\ncreatedb -Upostgres arno This step is enviroment dependent, please contact your database documentation for any specific information on this topic\nInitialize database with conf/arno.sql file - If you are using Postgres on Linux, type something like\npsql -Upostgres -f conf/arno.sql arno Configure application server enviroment - You should make database server accessible to the application server. This usually means that you must put JDBC driver of your database server in application server classpath and register connections to the apllication server. This step is enviroment dependent and here you can find insturctions for JBoss - Postgres enviroment.\n- Copy Postgres JDBC driver into JBoss library folder (e.g. /opt/jboss/server/default/lib/). If you have any questions regarding Postgres JBDC driver, please visit http://jdbc.postgresql.org/\n- Copy conf/postgres-service.xml file in JBoss deployment folder. This file is a connection manager file for JBoss server\nDeploy the applicaton - Edit build.xml file in project root folder. Set values for variables:\n- servlet.jar - path to the java servlet engine. You can usually locate this file in application server library folder\n- struts.libs - path to the Struts library\n- compile.classpath - path to the J2EE API engine. You can usually locate this file in application server library folder\n- deploy.home - deploy folder of the application server\nRun ant with deploy action\nant deploy Run the application - Start application server and access application (e.g. http://localhost:8080/arno/). You can log on with default account (user/pass: admin/admin) and start adding another users to the application. There is two kinds of users: Administrators (manage users) and regular users (manage tasks, events and folders).\nTodo # In future releases of Arno, you can expect:\nContainer managed beans examples More documentation that explains development process Advanced Struts options and tag examples Custom tag examples \u0026hellip; much, much more For any questions regarding this demo, please don\u0026rsquo;t hesitate to contact me\n","date":"June 5, 2003","externalUrl":null,"permalink":"/posts/2003-06-05-arno/","section":"Posts","summary":"Introduction # This is version 0.1 of small application that demonstrates how to use EJB technology and Struts web development framework together. It is a personal organizer that let’s its users to manage their tasks and events. Don’t expect high usability of this software (in some future versions it will be considered) because it is only ment to be a demo.\n","title":"Arno","type":"posts"},{"content":"When you are using XML RPC, you often want to have some security mechanism that will protect your system from malicious users.\nOne mechanism that could be used is basic HTTP authorization. When this approach is used username and password from the client are sent as a plain text in the HTTP header of the request. If authorization is valid, server will process the request or send response with status code 401 which means that client has not been successfully authorized. You may argue that plain text as a transport is not secure enough, but you can always use this mechanism with SSL what will give you more secure system.\nWe will focus now on the Apache XML RPC library. You can achieve this basic authorization by using AuthenticatedXmlRpcHandler interface. All you have to do is to implement handler and write execute method.\npublic Object execute(String method, Vector params, String user, String password) throws Exception; This method has to authenticate user according to the username and password provided, and do the action specified by the method and params. You have very nice demo in AuthDemo.java file in the library.\nAll you have to do next is to make client object, send authorization data and call execute method of the handler. For the demo handler that would be something like this:\nXmlRpcClient client = new XmlRpcClient(url); try { client.setBasicAuthentication(username, password); client.execute(\u0026#34;auth.action\u0026#34;, params); } catch(Exception ex) { System.err.println(\u0026#34;Error: \u0026#34; + ex.getMessage()); } This code snippet above would result in call like this: execute(action, params, username, password) of our handler.\nThe problem with this approach is that we are responsible for determining what action should be used which could be a big task in a complex handler. Idea of this patch is to allow you to expose any of your objects as a handler with basic authorization.\nAll you have to do is to make your object implement AuthenticatedHandler interface and write authorize method:\npublic boolean authenticate(String username, String password); Method should do whatever it takes to check if a username and password belongs to a valid user. It could connect to a relational database, LDAP or any other user storage and return true if user is permitted for a call or false otherwise. Client can make a call to any public method in your handler.\nXmlRpcClient client = new XmlRpcClient(url); try { client.setBasicAuthentication(username, password); client.execute(\u0026#34;authenticated.test\u0026#34;, params); } catch(Exception ex) { System.err.println(\u0026#34;Error: \u0026#34; + ex.getMessage()); } The code snippet will call authenticate method of the handler ant then call test method with a given params.\nInstallation # First you will need the source of Apache XMLRPC 1.1 library. You can download this library from the Apache web site. Then you should download patch from here\nExtract library source and copy the patch in the source directory. Next you should apply the patch with the following line.\npatch -u -p 1 -i xmlrpc-authenticated.patch You should see something like:\npatching file src/java/org/apache/xmlrpc/AuthenticatedDemo.java patching file src/java/org/apache/xmlrpc/AuthenticatedHandler.java patching file src/java/org/apache/xmlrpc/WebServer.java patching file src/java/org/apache/xmlrpc/XmlRpcServer.java After patching, you should be able to build your new library with Ant\nTesting # AuthenticatedDemo.java is provided for testing and demo purposes. In order to run demo, you should first include library in your class path. Suppose RPC_PATH is a path to the library. Do the following:\nexport CLASSPATH=.:XMLRPC_PATH/bin/xmlrpc-1.1.jar Now, start XMLRPC server:\njava org.apache.xmlrpc.WebServer 8080 And finally you can make a call to our handler:\njava org.apache.xmlrpc.AuthenticatedDemo http://localhost:8080 authenticated.test test test If everything is OK, you should get a result like\nTesting Now we can try bad authentication case with a following line\njava org.apache.xmlrpc.AuthenticatedDemo http://localhost:8080 authenticated.test testing testing And we will get\nError: org.apache.xmlrpc.XmlRpcException: Username or password does not match Closing word # We managed to expose our objects to the RPC server with basic authorization feature without disturbing existing library features. This way library could be used in some cases where complicated handlers are needed and still one can use standard authenticated handlers where it is appropriate.\n","date":"December 31, 2002","externalUrl":null,"permalink":"/posts/2002-12-31-apache-xmlrpc-11-authentication-patch/","section":"Posts","summary":"When you are using XML RPC, you often want to have some security mechanism that will protect your system from malicious users.\nOne mechanism that could be used is basic HTTP authorization. When this approach is used username and password from the client are sent as a plain text in the HTTP header of the request. If authorization is valid, server will process the request or send response with status code 401 which means that client has not been successfully authorized. You may argue that plain text as a transport is not secure enough, but you can always use this mechanism with SSL what will give you more secure system.\n","title":"Apache XMLRPC 1.1 authentication patch","type":"posts"},{"content":"PHP arrays are generally very powerful object container. But still, we can easily add a little more fuel to them. Imagine Iterator object that is a kind of wrapper around our arrays. What we will try to accomplish here is to create unique interface for traversing arrays and to add a little more control over how our objects are created and finally, to support lazy loading.\nInterface # Iterator has a very simple and many times seen interface.\nfunction Iterator($array) - Constructor. Takes array to be traversed as a parameter. function reset() - Sets internal pointer to the first element function end() - sets internal pointer to the last element function seek($position) - Sets internal pointer to desired position function next() - Returns next element in the iteration function previous() - Returns previous element in the iteration With the interface like this you can easily finish all your daily tasks (such as traversing arrays in any way you want and from any position you want). One advantage of using this approach against native PHP array functions is that you have one interface for all of your array tasks. You will not use foreach() construct in one case, list-each combination in other and yet next() and prev() functions in third any more. One more advantage is that now you can easily position on any particular element and start traversing from there (in any way you want). Here are few code examples:\n// $array = ?. // initialize the array $iterator = new Iterator($array); // traverse the array while ($elem = $iterator-\u0026gt;next()) { echo $elem; } // traverse array in reverse order $iterator-\u0026gt;end(); while ($elem = $iterator-\u0026gt;previous()) { echo $elem; } // traverse array from fifth element on $iterator-\u0026gt;seek(5); while ($elem = $iterator-\u0026gt;next()) { echo $elem; } OK, you say, this is all nice but there is nothing I can\u0026rsquo;t do with combination of native PHP functions. Beside that you are accessing all your arrays through unique interface, another (and most important) advantage is that Iterator\u0026rsquo;s object structure allows you to easily expand its functionality.\nObjectIterator interface # Often I ended up with situations where my object methods had to return array of some other object as a result. Usually that object are loaded from the database, but some other situation are possible such as obtaining objects through some RPC protocol (XML-RPC, SOAP, \u0026hellip;) or endless other situation combinations that you experience every day. In this article we will focus on the first problem and briefly explain how to empower Iterator for the any purpose you\u0026rsquo;d need.\nSuppose that you are developing address-book part of some large web application. Your address-book will work with companies and persons. In addition, companies could have endless number of employees (that are also kind of persons). So far we have recognized two objects in our application: Company and Person. Also, it is clear that the company will have method getEmployees() that returns array of Person objects. There are number of possible implementation of this method. Here are some usual implementations.\nFirst, you could write a query to collect all ids of the company employees. Then you could make array that contains all this objects and return this array. This would look something like this (supposing you have a database wrapper):\nfunction getEmployees() { $query = \u0026#34;SELECT id FROM persons WHERE companyid = $this-\u0026gt;companyid\u0026#34;; $stmt = execute_query($query); // creates statement object $this-\u0026gt;employees = array(); while ($row = fetch_object($stmt) { $this-\u0026gt;employess[$row-\u0026gt;id] = new Person($row-\u0026gt;id); // object creation } return $this-\u0026gt;employees; } and the usage would be:\n$company = new Company(\u0026#34;Datagate\u0026#34;); $employees = $company-\u0026gt;getEmployees(); foreach ($employees as $id =\u0026gt;$employee) $employee-\u0026gt;addVacationDays(3); // object usage OK, this looks like obvious solutions. But, it has few big flaws. All objects are created but we don\u0026rsquo;t know if we\u0026rsquo;ll going to use them all. There are two performance problems here. First accessing relational database (for creating these objects) are very time expensive. And if company have 500 employees and you need to access data of only 50, that is lot of time wasted. Imagine now, that we are loading this objects through RPC that is even slower. This could seriously affect application performance. Now, even if all objects are needed we don\u0026rsquo;t need them at the same time, we need objects one by one as we are traversing the array. The solution above is a huge waste of resources (memory and time).\nSolution to these performance problems looks so obvious. Let\u0026rsquo;s return just array of employee ids. Code would look something like this:\nfunction getEmployees() { $query = \u0026#34;SELECT id FROM persons WHERE companyid = $this-\u0026gt;companyid\u0026#34;; $stmt = execute_query($query); // creates statement object $this-\u0026gt;employees = array(); while ($row = fetch_object($stmt) { $this-\u0026gt;employess[$row-\u0026gt;id] = $row-\u0026gt;id; } return $this-\u0026gt;employees; } and the usage would be:\n$company = new Company(\u0026#34;Datagate\u0026#34;); $employees = $company-\u0026gt;getEmployees(); foreach ($employees as $id) { $employee = new Employee($id); // object creation $employee-\u0026gt;addVacationDays(3); // object usage } This looks fine at the first sight. We have saved time and memory space, but another problem arised. Suppose that the code for creating Employee object changes, for example you need to add extra argument to the constructor or some extra initialization (these are things that are happening on real projects). In that case you\u0026rsquo;ll need to modify your code on many places (wherever you have used getEmployees() method), And that is a problem.\nThe third solution is to use ObjectIterator class that is extended from Iterator. On this example we will see how easy it is to extend Iterator class to serve your purposes. When you are using ObjectIterator your getEmployee() function will stay the same as in second solution. So, we have saved our resources. No unnecessary objects are created and everything looks just fine. Now let\u0026rsquo;s look at the usage code:\n$company = new Company(\u0026#34;Datagate\u0026#34;); $iterator = new Iterator($company-\u0026gt;getEmployees(), \u0026#34;Employee\u0026#34;); while ($employee = $iterator-\u0026gt;next()) { $employee-\u0026gt;addVacationDays(3); } We see now that the object creation code is hidden in ObjectIterator class so it is now easy to support changes.\nObjectIterator implementation # The code for ObjectIterator is quite simple.\n/** * Implements iterator for traversing collection of objects * for the given array od object identifiers * * @version 1.0 * @author Dejan Bosanac */ class ObjectIterator extends Iterator { var $_objectName; /** * Constructor * Calls initialization method (@see Iterator::_initialize()) * and do some specific configuration * @param array $array array of object ids to be traversed * @param string $objectName class of objects to be created * @access public */ function ObjectIterator($array, $objectName) { $this-\u0026gt;_initialize($array); $this-\u0026gt;_objectName = $objectName; } /** * Returns object with given id * @param Object $id identifier of the object * @return Object next object in the collection * @access private */ function _fetchObject($id) { return new $this-\u0026gt;_objectName($id); } } It has $_objectName class member that represent class of the object that have to be returned by next() and previous() methods. Constructor sets this internal variable and calls initialization function (defined in Iterator class). The most important thing is _fetchObject() function. It encapsulates code for object creation. It is called from next() and previous() methods and takes object id as a parameter. So all yours object creation code is localized here, thus makes it easy to change and expand.\nSo, here are instructions for creating new type of iterators. First, make your constructor (which has to have array for parameter) calls _initialize() function from Iterator class. Second, override _fetchObject method to do whatever you have to do to make your objects. And, that would be all.\nIn conclusion # Iterator will not slow down your application in that way that it will need new hardware to run it. It has some overhead, but for that price you get clean and easy readable code that is flexible enough for future software enhancements.\nYou can download PHP Iterator from here\n","date":"November 11, 2002","externalUrl":null,"permalink":"/posts/2002-11-11-php-iterator/","section":"Posts","summary":"PHP arrays are generally very powerful object container. But still, we can easily add a little more fuel to them. Imagine Iterator object that is a kind of wrapper around our arrays. What we will try to accomplish here is to create unique interface for traversing arrays and to add a little more control over how our objects are created and finally, to support lazy loading.\n","title":"PHP Iterator","type":"posts"},{"content":" Experienced engineer working at Red Hat, with a long-standing passion for open source, system integration, and building trustworthy software ecosystems.\nMy current interests center on the intersection of AI and security, alongside software supply chain integrity — areas where open collaboration is essential to tackle emerging challenges at scale.\nOver the years, I\u0026rsquo;ve been deeply involved in influential open source communities:\nOpenSSF — Contributing to supply chain security initiatives, including work on GUAC (supply chain knowledge graphs) and the integration of Trustify to enable interoperable metadata ingestion, processing, and visibility. Kubernetes / CNCF — Former lead of the IoT Edge working group and active contributor to broader ecosystem efforts around edge computing and cloud-native connectivity. Eclipse Foundation — Former Project Lead for Eclipse Hono, advancing scalable IoT and edge connectivity platforms. Apache — Early committer and PMC member on Apache ActiveMQ, shaping enterprise messaging and integration solutions used worldwide. I thrive on bridging technical depth with real-world impact: regularly engaging with customers and partners to understand their needs, translate complex challenges into actionable solutions, and help shape project and product roadmaps. Whether through direct collaboration, conference talks, or working groups, I enjoy driving products and practices that solve practical problems for organizations adopting open source at scale.\nI\u0026rsquo;m the author of ActiveMQ in Action (2011) and Scripting in Java (2007), and a frequent speaker on topics like vulnerability management, supply chain metadata, and open collaboration.\n","externalUrl":null,"permalink":"/about/","section":"Dejan Bosanac","summary":" Experienced engineer working at Red Hat, with a long-standing passion for open source, system integration, and building trustworthy software ecosystems.\nMy current interests center on the intersection of AI and security, alongside software supply chain integrity — areas where open collaboration is essential to tackle emerging challenges at scale.\nOver the years, I’ve been deeply involved in influential open source communities:\n","title":"About","type":"page"},{"content":"","externalUrl":null,"permalink":"/search/","section":"Dejan Bosanac","summary":"","title":"Search","type":"page"},{"content":"","externalUrl":null,"permalink":"/tags/","section":"Tags","summary":"","title":"Tags","type":"tags"}]