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

Fixing the jcp – the server side java symposium

The official title of this session is “The Java Community Process – What’s broken and how to fix it”.  The panel is James Gosling, Patrick Curran (head of the jcp) and Reza Rahman (member of jcp expert groups and author of EJB in action)

What’s wrong

  • Some inherent because so many priorities and agendas. these predated Oracle
  • Apache Harmony TCK issue (Apache Geronomo doesn’t pay for TCK because non profit open source. The problem with Harmony is that it has restrictions). Reza would like to see it free, no strings attached after the lawsuit.
  • Patrick said Oracle is more forceful than Sun in that they make a stand rather than bicker forever
  • Reza said James is too bright but not practical enough :). He views Oracle as being more practical. Reza noted leading is hard and getting people to agree is hard. He views Oracle leading as a necessity because they have the resources to be a JSR lead.   James noted being a spec lead is a full time job even if things go smoothly.
  • In 2007, Oracle tried to create an organization so sun would have less power. Now that they are in charge, they want to retain ownership. Logical position at least.
  • Process issues -greater transparency so don’t have to be a JCP member for read only view
  • Reza views a big problem as lack of individual participation in the JCP. Reas the proceedings, blog, be spec leads, etc. Democracy is participatory [yes, but this isn’t a democracy, right after i wrote this Cameron noted SpringSource and Google are leading by example. Reza said that sounds like Microsoft. and it does.  Except that Sun copied from Spring extensively. James noted that innovation in the String class would be dangerous]

What could be better

  • Reza recognized it is hard to have an independent JCP. It requires resources, a way to move forward without veto bpower, etc
  • Patrick noted that all standards groups have these political obstacles because companies or countries have different interests. The fact that they are trying to work together is a good thing.
  • Patrick noted things are better than they look. Some groups have mailing lists that be read.  Oracle is looking at making things more open and expect to mandate transparency via an open mailing list. Similarly for formally tracking comments. The executive committee has been publishing minutes for several years.
  • Patrick noted they are looking at making it easier to join. In particular, creating a simpler legal agreement for non-spec lead roles
  • Patrick pointed out standards take time. It is more important to get it right than fast. It is avoiding unnecessary waste that matters

audience questions

  • Role of spec evangelist separate from spec lead?  Reza said don’t need formal role. Independents on JCP should blog and do this
  • More people shipping products dependent on platform?  oracle working on balance. Also looking at letting java user groups join so members can contribute
  • What can someone do to help without spending a lot of time?  Follow JSR interested in. Read the spec and comment without joining group. Mny JSRS are open source comments. Reza listed following jee articles on theserverside and javalobby and leave comments for actual jcp members to read and convey. Similarly for the comment period. [this was my question, a lot of the answers sound quite time consuming to me. Reza did list a short one which I appreciate]
  • Developers wait until something is stable to try it because working our own problems. By then it is late in the game to comment. Everyone agreed the proposed final draft and reference implementation IS that

java in flux – the server side java symposium

Oh look.  The ten line Oracle disclaimer is back.  At least this talk contains some forward looking statements where it makes sense to have the disclaimer.

Communication
Oracle recognizes they have issues with communicating late/poorly.  They have a culture of saying little and sticking to it.  Whereas Sun had more dialog.  They acknowledge it; will be interesting to see what happens.

Priority

Want to keep Java vibrant to keep making money.  Said will continue move to Open JDK.  Moving JRockit features to OpenJDK.

Other topics

  • Looking at support for multiple cores at the CPU level.  Think parallel collections and lambda/closures will be good candidates for paralleilization
  • Let ideas mature in more experimental languages
  • Reiterated pledge to backward compatibility
  • Covered what’s new in Java 7 at a high level – most I had heard before – the more lightweight garbage collector was new to me
  • Java 8 – more modularization, project lambda(closures), annotations on Java types and more small language enhancements
  • Java 9 – really speculative – forces on platform independence with hardware virtualization, better interoperatibility with non Java languages, improved data integration, improved device support
  • Looking to expand Java FX [surprised]

JEE

  • Want JEE 7 done before Java 8 comes out which is end of 2012
  • Looking at what can do for modularity in JEE 7 before “real” modularity comes out in Java 8
  • Compared Java to .NET.Azure including areas like Cloud and multiple language support where Microsoft doing better
  • Covered the problems it was designed to solve and how it got so big that it isn’t simple anymore. Going back to POJOs, dependency injection. [again making it sound like this stuff just sprung up from developer complaints]
  • Showed timeline from 1998 and J2EE 1.2.
  • Recognized innovation is occurring on the outside and the platform stewards/Oracle need to reuse that to avoid becoming irrelevant
  • Customers win when there is interoperability and vendor choice
  • Companies want to build internal clouds – solutions starting to be built on Java Also noted cloud gives new JEE roles of data center and tenant roles. (in addition to things like deployer) In addition, noted the existing JEE APIs need to become tenant aware. Such as how to discriminate within a table what rows are associated with what tenant in a JPA entity. Maybe in JEE 8