Joshua Smith

Ranch Hand
+ Follow
since Aug 22, 2005
Merit badge: grant badges
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Joshua Smith

S G Ganesh & Tushar Sharma-

I have the SCJP for Java 1.5 certification. Which section of the exam do you think requires the most amount of study for those that already hold the SJCP certification?

Thank you,
Joshua Smith
Thank you Ashish.

If I move that code into the .java file, does that mean that I can delete the .aj file and not use it any longer?

Why does Roo generate the code in a .aj file instead of generating .java files or modifying existing Java files?

12 years ago
One of the reasons that I am a bit reluctant to use Spring Roo is the fact that it depends on code generation, non-Java code generation at that. Do you address this in your book? What can you tell me to assure me that this is not a liability in adopting Spring Roo.

Joshua Smith
12 years ago
Sean Owen, Robin Anil, Ted Dunning, and Ellen Friedman, -

There's been a lot of buzz in the last week about the free online Stanford University course on Artificial Intelligence. Currently there are more than 70,000 people signed up for it.

How relevant is their course to the things covered in your book and vice versa?

Also, there is a free course on Machine Learning. Same question there.

Joshua Smith
If you want to learn Spring 3.0, these are the only books in print that I know of. I own both of them and have found them to be very useful.

Spring in Action, Third Edition

Spring Recipes, 2nd Edition

12 years ago
Give Google+ one year and Facebook will go the way of AOL.

Google is serious about this one, they have multiple upgrades queued up, ready to go. Not only will Google have every feature that Facebook has within one year, they have the depth of content to bring maps, docs, search, blogs, Android, location and a dozen other technologies to Google+ that will bury Facebook.

What does Facebook have? Facebook. That's it. They're a one trick pony that got there first. Once Google+ is offering Facebook and then some, there will be no reason to stay on Facebook.
12 years ago
Extend PatternLayout and then override the getHeader() method.

Same results.

The reason that I wouldn't expect it to need the extra text specified in the annotation is that the class being monitored in the example doesn't have any extra text.

And from the application context:
13 years ago
Pro Spring Integration Authors-
(and/or others doing JMX with Spring Integration)

I received your book this week and it came just in time! I'm actively architecting a Spring Integration application at work and your book is filling in some of the pieces that are not covered in other reference materials. Thanks!

I started with this example:

Then I did the following:
Added my own class ( to the same package as the JMX enabled example class (
Added the @Component, @ManagedResource and @ManagedOperation to
Added the NotificationPublisher to
Added the jmx:notification-listening-channel-adapter and the elements necessary to support my splitter to notification-listener.xml.
Added the spring-integration-file dependency to the pom.xml

Finally, I executed and received a "Failed to find MBean instance" error message. Why am I receiving this error message?

Below is the error message and the things that I added to your example. Everything else is exactly as it came from the examples.

Thank you,
Joshua Smith
package com.apress.prospringintegration.jmx;

import java.util.ArrayList;
import java.util.List;


import org.apache.log4j.Logger;
import org.springframework.integration.annotation.Splitter;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.jmx.export.notification.NotificationPublisher;
import org.springframework.jmx.export.notification.NotificationPublisherAware;
import org.springframework.stereotype.Component;

public class FileToRecordSplitter implements NotificationPublisherAware {

private static final Logger LOGGER = Logger.getLogger(FileToRecordSplitter.class);
private NotificationPublisher notificationPublisher;

public List<Record> split(File file) throws IOException {
List<Record> records = new ArrayList<Record>();
FileInputStream fstream = new FileInputStream(file);
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
while ((strLine = br.readLine()) != null) {
records.add(new Record(file.getName(), strLine.split("\\s+")));
}"Split " + file.getName() + " into " + records.size() + " records.");
notificationPublisher.sendNotification(new Notification("split", this, 0));
return records;

public void setNotificationPublisher(NotificationPublisher notificationPublisher) {
this.notificationPublisher = notificationPublisher;


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""


<context:component-scan base-package="com.apress.prospringintegration.jmx"/>

<int:channel id="notification"/>



<stream:stdout-channel-adapter channel="notification" append-newline="true"/>

<int:poller default="true" max-messages-per-poll="10" fixed-rate="100" />
<file:inbound-channel-adapter id="fileChannel"
directory="file:/tmp/input" prevent-duplicates="true">


<int:splitter id="fileToRecordSplitter"
output-channel="nullChannel" >
<bean class="com.apress.prospringintegration.jmx.FileToRecordSplitter"/>


Added to pom.xml

Error Message
INFO : - Refreshing startup date [Sat Apr 23 12:12:47 EDT 2011]; root of context hierarchy
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [jmx/notification-listener.xml]
INFO : - Overriding bean definition for bean 'fileToRecordSplitter': replacing [Generic bean: class [com.apress.prospringintegration.jmx.FileToRecordSplitter]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [/Users/josh/Documents/ProjectsCommon/SpringIntegration/ProSpringIntegrationSourceCodeFromApress/prospringintegration_src/monitoring/target/classes/com/apress/prospringintegration/jmx/FileToRecordSplitter.class]] with [Generic bean: class [org.springframework.integration.config.ConsumerEndpointFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null]
INFO : org.springframework.integration.config.xml.DefaultConfiguringBeanFactoryPostProcessor - No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created.
INFO : org.springframework.integration.config.xml.DefaultConfiguringBeanFactoryPostProcessor - No bean named 'taskScheduler' has been explicitly defined. Therefore, a default ThreadPoolTaskScheduler will be created.
INFO : - Pre-instantiating singletons in defining beans [mbeanExporter,mbeanServer,basicMBean,fileToRecordSplitter,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.integration.internalDefaultConfiguringBeanFactoryPostProcessor,notification,org.springframework.integration.jmx.NotificationListeningMessageProducer#0,org.springframework.integration.jmx.NotificationListeningMessageProducer#1,,org.springframework.integration.config.ConsumerEndpointFactoryBean#0,,org.springframework.integration.context.defaultPollerMetadata,fileChannel,org.springframework.integration.file.config.FileListFilterFactoryBean#0,org.springframework.integration.file.config.FileReadingMessageSourceFactoryBean#0,fileChannel.adapter,org.springframework.integration.config.SplitterFactoryBean#0,nullChannel,errorChannel,_org.springframework.integration.errorLogger,taskScheduler]; root of factory hierarchy
INFO : org.springframework.jmx.export.annotation.AnnotationMBeanExporter - Registering beans for JMX exposure on startup
INFO : org.springframework.jmx.export.annotation.AnnotationMBeanExporter - Bean with name 'basicMBean' has been autodetected for JMX exposure
INFO : org.springframework.jmx.export.annotation.AnnotationMBeanExporter - Located managed bean 'basicMBean': registering with JMX server as MBean [com.apress.prospringintegration.jmx:name=basicMBean,type=BasicMBean]
INFO : org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler - Initializing ExecutorService 'taskScheduler'
INFO : - Starting beans in phase -2147483648
INFO : org.springframework.integration.endpoint.EventDrivenConsumer - started fileToRecordSplitter
INFO : org.springframework.integration.endpoint.EventDrivenConsumer - started org.springframework.integration.config.ConsumerEndpointFactoryBean#0
INFO : org.springframework.integration.endpoint.EventDrivenConsumer - started _org.springframework.integration.errorLogger
INFO : - Starting beans in phase 0
INFO : org.springframework.integration.jmx.NotificationListeningMessageProducer - started org.springframework.integration.jmx.NotificationListeningMessageProducer#0
INFO : - Destroying singletons in defining beans [mbeanExporter,mbeanServer,basicMBean,fileToRecordSplitter,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.integration.internalDefaultConfiguringBeanFactoryPostProcessor,notification,org.springframework.integration.jmx.NotificationListeningMessageProducer#0,org.springframework.integration.jmx.NotificationListeningMessageProducer#1,,org.springframework.integration.config.ConsumerEndpointFactoryBean#0,,org.springframework.integration.context.defaultPollerMetadata,fileChannel,org.springframework.integration.file.config.FileListFilterFactoryBean#0,org.springframework.integration.file.config.FileReadingMessageSourceFactoryBean#0,fileChannel.adapter,org.springframework.integration.config.SplitterFactoryBean#0,nullChannel,errorChannel,_org.springframework.integration.errorLogger,taskScheduler]; root of factory hierarchy
INFO : org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler - Shutting down ExecutorService 'taskScheduler'
INFO : org.springframework.jmx.export.annotation.AnnotationMBeanExporter - Unregistering JMX-exposed beans on shutdown
Exception in thread "main" org.springframework.context.ApplicationContextException: Failed to start bean 'org.springframework.integration.jmx.NotificationListeningMessageProducer#1'; nested exception is java.lang.IllegalStateException: Failed to find MBean instance.
at com.apress.prospringintegration.jmx.JmxNotificationListener.main(
Caused by: java.lang.IllegalStateException: Failed to find MBean instance.
at org.springframework.integration.jmx.NotificationListeningMessageProducer.doStart(
at org.springframework.integration.endpoint.AbstractEndpoint.start(
... 9 more
Caused by: com.apress.prospringintegration.jmx:name=fileToRecordSplitter,type=FileToRecordSplitter
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.addNotificationListener(
at com.sun.jmx.mbeanserver.JmxMBeanServer.addNotificationListener(
at org.springframework.integration.jmx.NotificationListeningMessageProducer.doStart(
... 11 more

13 years ago
I'm a little confused on some of the Spring Integration terminology and want to clear it up in my head before I use it as part of some software documentation. It seems there is a conflict in the way terms are used in the API versus how they are used in the reference manual.

Section 2.4 of the Spring Integration Reference Manual lists Transformer, Filter, Router, Splitter, Aggregator, Service Activator and Channel Adapter as examples of Message Endpoints. A number of the classes that correspond to these (MessageFilter, AbstractMessageRouter, AbstractMessageSplitter, AbstractAggregatingMessageGroupProcessor) do not extend AbstractEndpoint. In fact, of all of them, only the various Channel Adapters implement AbstractEndpoint. Instead, most of these classes have AbstractMessageHandler in their parent hierarchy. AbstractTransformer doesn't extend either of them and I wasn't able to find an abstract class for Service Activator.

What is the correct generic term for Transformer, Filter, Router, Splitter, Aggregator, Service Activator and Channel Adapter?
Message Endpoint? Message Handler? Service Activator? Something else?

Spring Integration Reference Manual

Spring Integration Reference Manual - Overview of Endpoints

Spring Integration API

Thank you,
Joshua Smith

13 years ago
Since there are a couple of really smart Spring Integration guys on the list right now (thanks Mark and Mark), I thought I would take advantage of that and post a few topics that I, and probably others, have questions on...

I'm about to use Spring Integration in anger on a software project at work. It's one of those projects that has existed for some time, but was written by a very smart C programmer that was fairly new to Java. The result is that it doesn't feel like Java in some places and the overall architecture is overly complicated. This makes it difficult to maintain. The great thing is that he sees this and has asked me to come in and overhaul the architecture. He wants the overhaul to fix that one project, but for it also to serve as a model for related projects. The applications are data flow type applications where they accept files and do multiple steps of processing on them and output files at the other end. So they definitely lend themselves to Spring Integration. Since this is the model for going forward on a number of other projects, there's some extra emphasis on documenting it right so that others can understand the architecture and implement it in a number of places. As a result, I have a couple of questions on documentation that maybe you can help me on.

1) I've been studying the Enterprise Integration Patterns (EIP) book by Hohpe ( and have downloaded the Visio stencils from his web site. I intend to use them in the software documentation as they seem to be a very complete and easy to understand grammar for Spring Integration (since the latter was based on the former, that makes sense). How do you see these sorts of diagrams fitting into a software documentation package? Do they replace sequence diagrams? Are there other places that the use of EIP affects the documentation?

2) Is there a Spring Integration Petstore? And if so, does it have accompanying software documentation? I'm looking for an example software documentation package that would show how documentation that is specific to Enterprise Integration Patterns (with a Spring Integration implementation) might fit into the more general documentation for an N-tiered application.

13 years ago
That sounds like a great class Mark. I recently took a Core Spring class from Learning Tree. My place of employment brought them in to teach a class. The instructor was solid as far as the content in the curriculum, but when I asked about Spring Integration he had no idea what I was talking about. Maybe he just had a narrower focus and didn't follow the other things going on in the community.

Spring Integration is amazing so far. I have used Jakarta Commons Chain in the past and while there are major differences, there are a lot of conceptual similarities as well.

13 years ago

That's exactly what I needed to know. Thank you.

13 years ago
I'm trying to make sure that I understand, and use correctly, the element of Spring Integration. In particular I have questions about splitters and the types that they should return. From reading some of the Spring Integration literature on Splitters, I first came to this conclusion...

1) A splitter is used on any case that you want to process a message and have it result in multiple messages EVEN if those messages are of multiple types (say for instance you were processing an Order and the result was Customer object and a number of OrderItem objects)

but then I read about aggregators and saw that they are often used with splitters and the kind of do the opposite of a splitter in that they store up messages and then, when they have all the pieces, they stitch them back together. So then I came to this conclusion...

2) A splitter is only used when the output is multiple messages of the same type.

After browsing the API again this morning, I'm more convinced that number 1 is correct. There doesn't seem to be a facility for producing multiple messages in a transformer, so it's got to be done in a splitter. It seems that the case where all the output is of the same type and later processed by an aggregator is a special case, but a splitter is the correct pattern for any multiple message output case.

I just wanted to get confirmation from others that have used Spring Integration that I'm using it properly. Also, the docs for splitters says that you can return a collection or an array, so I'm assuming that in a case where the messages are of multiple types, I should probably return an array of Object[] or a List<Object> and that Spring Integration will pull the individual objects out into the correct parameterized messages?

So my questions:

A) Should the output of a splitter be a number of messages of the same type or are multiple types permitted?
B) What type of collection or array should be used to hold the messages being output if they are of different types?

Related links:

13 years ago