Joshua Smith

Ranch Hand
+ Follow
since Aug 22, 2005
Merit badge: grant badges
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

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?

Thanks,
Josh
13 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.

Thanks,
Joshua Smith
13 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.
http://www.ai-class.com/

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.
http://www.ml-class.com/

Thanks,
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
http://www.amazon.com/Spring-Action-Craig-Walls/dp/1935182358
http://www.manning.com/walls4/

Spring Recipes, 2nd Edition
http://www.amazon.com/Spring-Recipes-Problem-Solution-Gary-Mak/dp/1430224991
http://www.apress.com/9781430224990

Josh
13 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.
13 years ago
Extend PatternLayout and then override the getHeader() method.





Josh
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:
prospringintegration_src/monitoring/src/main/java/com/apress/prospringintegration/jmx/JmxNotificationListener.java

Then I did the following:
Added my own class (FileToRecordSplitter.java) to the same package as the JMX enabled example class (BasicMBean.java).
Added the @Component, @ManagedResource and @ManagedOperation to FileToRecordSplitter.java
Added the NotificationPublisher to FileToRecordSplitter.java
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 JmxNotifcationListener.java 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


FileToRecordSplitter.java
-------------------------
package com.apress.prospringintegration.jmx;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import javax.management.Notification;

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;

@Component
@ManagedResource
public class FileToRecordSplitter implements NotificationPublisherAware {

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

@Splitter
@ManagedOperation
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+")));
}
LOGGER.info("Split " + file.getName() + " into " + records.size() + " records.");
notificationPublisher.sendNotification(new Notification("split", this, 0));
return records;
}

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

}


notification-listener.xml
-------------------------
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jmx="http://www.springframework.org/schema/integration/jmx"
xmlns:file="http://www.springframework.org/schema/integration/file"
xmlns:stream="http://www.springframework.org/schema/integration/stream"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
http://www.springframework.org/schema/integration/jmx
http://www.springframework.org/schema/integration/jmx/spring-integration-jmx-2.0.xsd
http://www.springframework.org/schema/integration/file
http://www.springframework.org/schema/integration/file/spring-integration-file-2.0.xsd
http://www.springframework.org/schema/integration/stream
http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<context:mbean-export/>
<context:mbean-server/>

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

<int:channel id="notification"/>

<jmx:notification-listening-channel-adapter
channel="notification"
object-name="com.apress.prospringintegration.jmx:name=basicMBean,type=BasicMBean"/>

<jmx:notification-listening-channel-adapter
channel="notification"
object-name="com.apress.prospringintegration.jmx:name=fileToRecordSplitter,type=FileToRecordSplitter"/>

<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">

</file:inbound-channel-adapter>

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

</beans>


Added to pom.xml
----------------
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-file</artifactId>
</dependency>


Error Message
-------------
INFO : org.springframework.context.support.ClassPathXmlApplicationContext - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@36b8bef7: 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 : org.springframework.beans.factory.support.DefaultListableBeanFactory - 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 : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@70d05c13: 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.stream.CharacterStreamWritingMessageHandler#0,org.springframework.integration.config.ConsumerEndpointFactoryBean#0,org.springframework.scheduling.support.PeriodicTrigger#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 : org.springframework.context.support.DefaultLifecycleProcessor - 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 : org.springframework.context.support.DefaultLifecycleProcessor - Starting beans in phase 0
INFO : org.springframework.integration.jmx.NotificationListeningMessageProducer - started org.springframework.integration.jmx.NotificationListeningMessageProducer#0
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@70d05c13: 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.stream.CharacterStreamWritingMessageHandler#0,org.springframework.integration.config.ConsumerEndpointFactoryBean#0,org.springframework.scheduling.support.PeriodicTrigger#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 org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:169)
at org.springframework.context.support.DefaultLifecycleProcessor.access$1(DefaultLifecycleProcessor.java:154)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:335)
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:143)
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:108)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:908)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:428)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.apress.prospringintegration.jmx.JmxNotificationListener.main(JmxNotificationListener.java:23)
Caused by: java.lang.IllegalStateException: Failed to find MBean instance.
at org.springframework.integration.jmx.NotificationListeningMessageProducer.doStart(NotificationListeningMessageProducer.java:121)
at org.springframework.integration.endpoint.AbstractEndpoint.start(AbstractEndpoint.java:84)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:166)
... 9 more
Caused by: javax.management.InstanceNotFoundException: com.apress.prospringintegration.jmx:name=fileToRecordSplitter,type=FileToRecordSplitter
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1094)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.addNotificationListener(DefaultMBeanServerInterceptor.java:1190)
at com.sun.jmx.mbeanserver.JmxMBeanServer.addNotificationListener(JmxMBeanServer.java:799)
at org.springframework.integration.jmx.NotificationListeningMessageProducer.doStart(NotificationListeningMessageProducer.java:118)
... 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
http://static.springsource.org/spring-integration/docs/2.0.0.RELEASE/reference/htmlsingle/

Spring Integration Reference Manual - Overview of Endpoints
http://static.springsource.org/spring-integration/docs/2.0.0.RELEASE/reference/htmlsingle/#overview-endpoints

Spring Integration API
http://static.springsource.org/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 (http://www.eaipatterns.com/) 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.

Thanks,
Josh
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.

Josh
13 years ago
Mark-

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

Josh
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:
http://static.springsource.org/spring-integration/api/org/springframework/integration/annotation/Splitter.html
http://static.springsource.org/spring-integration/docs/2.0.0.RELEASE/reference/htmlsingle/#splitter

Thanks,
Josh
13 years ago