Live from TSSJS – PostgreSQL with Tom

Live blogging from TheServerSide Java Symposium with Tom Kincaid at his vendor presentation “Introduction to PostgreSQL for Development and Deployment”.  Tom spends a lot of time contrasing Postgres with MySQL, and commenting how since Oracle’s aquisition of MySQL, the licensing of MySQL is now much more restrictive. Tom says the licensing of Postgres is basically “Do what you want with the code but don’t bother us”.

1. Why has it not the most adopted open source DB?
Tom talks about some of the limitation of Postgres that prevented it from becoming one of the most adopted DBMS software including:

  • Early versions were Linux only with Windows support coming later
  • Installation was difficult
  • Default configuration was not neccessarily the best, and was designed for widest platform adoption
  • Lacked bundled distribution tools

Tom points out that originally, developers “first 20 mins” of using the product was often frustrating and would turn people off to the software.

2. Today’s Postgres
Postgres has made a number of changes in the last few years to grow Postgres has a more developer-friendly and easier-to-use product.  It also has been extended to work with all major IDEs, object-relational mapping tools such as JDBC, ODBC drivers, and stored procedures based in Java.  They have also spent time improving the GUI tools to compete with other major DBMS providers.  The GUI also shows performance tools and query plans.

Conclusion
The vendor sessions were abridged compared to the normal sessions so there was a lot Tom did not get to.  He did peak my interest in learning more about Postgres, now that it has grown to a more substational platform.  Tom’s belief is that everyone should use Postgres given its power and hands-off licensing, especially compared to the direction MySQL may be going.

Live from TSSJS – Spring Messaging with Mark

I’m live blogging from “Message Driven Architecture with Spring” by Mark Fisher at TheServerSide Java Symposium.  Mark talks about how Spring messaging involved with the idea simple POJOs, similar to JMS.  Mark’s examples involve RabbitMQ, as one of the more recent and powerful messaging providers.  Below are some notes for this talk.

1.  AMQP
Mark introduces Advanced Message Queuing Protocol, AMQP for short, protocol as an alternative to standard JMS messaging but with a richer feature set including an advancing system of binding for filtering/routing of messages.  Also, AMQP templates are very similar to JMS templates.  Mark presented a number of slides with code examples of AMQP using the templates.

2.  MailSender
Mark presents MailSender, which can be used to send simple mail massages. 

3.  Lifecycle Management
The Spring SmartLifeCycle has been created in Spring 3.0 to help facilitate auto-start and graceful shutdown of listeners with the rest of the application.  This feature includes an optionaly isAutoStartup() attribute which can be used, for backwards compatibility and maintenance, to disable this feature.  By graceful shutdown, the components are stopped in the reverse order of startup, as needed.

4.  Task Execution
Create managed and pooled tasks that don’t need to be started manually (a big no-no)

5.  @Async
Async was added in Spring 3.0 that uses the @Async annotation for executor framework.

6.  Task Schedule
Built-in framework in Spring 3.0, no longer requires Quartz scheduling plugins and similar structures.  Supports recurring and cancelable tasks.  The @Scheduled(“*/5 * 9-17 * * ?”) annotation allows developers to build cron-like schedule tasks.  There is also an alternative solution to externalize the schedule information in XML so it’s tied to the code and the code does not require import statements for the annotations.  Finally, it supports meta-annotations that uses the @Scheduled annotation but points to XML reference in another location.

7.  Message Publishing Interceptor
Send message a by-product of another event.

Conclusion
Mark covered a large variety of material in a very short time, so I wasn’t able to write all the important points from his slides.  He did demonstrate a number of really useful features available in Spring 3.0 and showed how messaging in Spring has really grown to a more mature development platform.  He presentation was especially good because he managed to include demonstrations of the code alongside the spec information.

Message driven architecture with spring – the server side java symposium

Mark Fisher has a cool twitter handle @m_f_
Pardon the lack of formatting, there was just too much information to learn plus watch live demos and type lists on an ipad. I will clean it up over the weekend. [cleaned up] Too much content is a good “problem” for a presentation to have.

libraries:

  1. Spring Integration
  2. Spring AMQP in release candidate mode.  Similar to Spring JMS but doesn’t hide it behind JMS. AMQP is an open wireless protocol.  Also use you set up a routing exchange and set up a routing key for clients to bind to.  For example news.star.us so can subscribe to different levels on broker. works with non Java clients

Events

  • Has been in Spring since the very beginning
  • interface ApplicationEventPublisherAware allows you to make a callback
  • Interface ApplicationListener is called when event occurs, can use generics to say what type of events you care about
  • Can do without forcing to extend spring interface as well

Messaging

  • JmsTemplate – prefer CachingConnectionFactory to ensure sessions are reused
  • Jms:listener-container defined in xml on a pojo
  • Or use AmqpTemplate instead of JmsTemplate to use amqp, works the same as jmstemplate, for example you can call receive/send methods
  • Amqp namespace released this week to support listeners
  • Showed demo with rabbitmq including using web ui to see how many messages on queue
  • RestTemplate for http messaging, can use HttpMessageConverters if need to be more specific

Mail

  • SimpleMailMessage to create a message and inject MailSender to send it, good for simple messages, there is a mime one for more complex messsages
  • Core Spring cannot receive e-mail. Spring Integration can

Polling

  • Better to use events/messaging and only poll when you have to
  • Lifecycle interface – start(), stop() and isRunning()
  • SmartLifecycle does those three plus autostartup, phases and adds a callback on stop

Scheduling

  • taskScheduler interface lets you schedule one time tasks, tasks at a fixed rate and tasks at a fixed delay
  • Trigger interface lets you control the next execution time along with the Trigger Context that gives information about the last scheduled/actual time
  • This means you don’t need quartz for simple operations
  • The @Scheduled annotation lets you specify cron or fixed time/delay expressions instead of interfaces
  • Can also create your own annotations to externalize the cron expression so using your custom annotation without duplicating the configuration of the cron expression

Pipes and filters

  • Message can be any object as the payload with headers in a map, the message is immutable unless your payload itself is mutable
  • MessageChannel can do point to point or publish subscribe, set channel, types in xml using  and can also set whether async
  • A gateway can be one way or bidirectional
  • Can use @publisher to put the result of a method or argument to go on a channel as a side effect of calling the method
  • Filters return booleans
  • Router directs to proper channel name
  • Can route on payload type, header type etc
  • Can split/aggregate channels
  • Spring Integration 2.0 lets you use el to specify bindings, etc
  • Can chain when don’t need explicit channel names