-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any repo for annotation based samples ? #151
Comments
Hi @radiumx3 ! Not sure what is your question, but this one can cover any samples related to the Spring Integration. Cheers, P.S. Leaving open until your clarification. |
We were looking for fully java based sample (no xml, just annotations) (File move, file copy workflow), we didn't manage to find the java equivalent for outbound-adapter xml tag in the beggining, we found out how to do it though. If anyway there is some pure java <-> xml cheatsheet I would be glad to study it :) Thanks anyway |
See here: http://docs.spring.io/spring-integration/docs/latest-ga/reference/html/files.html#_configuring_with_java_configuration_7 The main concept of Java config is described here: http://docs.spring.io/spring-integration/docs/latest-ga/reference/html/configuration.html#annotations. Everything else are just Java classes which should be configured as |
As far as I understood, Java DSL make extensive use of Java Lambda (Java8) but we have to stick with java7 (internal constraint) |
The DSL is "better" (less verbose) when using lambdas, but they are no means required; it fully supports Java 7. As Artem said, we are adding annotation-based configuration to the reference manual as time permits, we have done a few recently, but generally it's driven by specific user requests. Same thing with the samples; we just don't have the resources to provide annotation-based versions for them all in one go. If there is something specific you need help with we can try to accommodate. Contributions are welcome too. |
Hi Artem/Gary, below is my Code for Spring Integration , I am trying to poll a folder and I have configured it properly. @InboundChannelAdapter(value = "inboundchannel", poller = @Poller(fixedDelay = "50000", maxMessagesPerPoll = "1"))
public Message<File> processFiles() {
fileReadingMessageSource = getFileReadingMessageSource();
return fileReadingMessageSource.receive();
}
@ServiceActivator(inputChannel = "inboundchannel")
public void process(Message<File> payload) {
processFile(payload);
} but once the program initializes..I am getting an Exception as below, Exception :
will you please help me with this Issue ? |
You have to declare From other side it isn't clear to me why you don't use
|
Hi Artem, thanks a lot for your quick reply. I will try by keeping to answer your second question , I want to have a single instance of |
Hi Artem, I am giving you the entire Annotations I have used at class level to make the Issue clear. @Component("cSVFileProcessor")
@Configuration
@IntegrationComponentScan
@EnableIntegration
@MessageEndpoint
public class CSVFileProcessor {
public static FileReadingMessageSource getFileReadingMessageSource() {
try {
if (fileReadingMessageSource == null) {
fileReadingMessageSource = new FileReadingMessageSource();
fileReadingMessageSource.setDirectory(new File(folderPath));
SimplePatternFileListFilter simplePatternFileListFilter = new SimplePatternFileListFilter(
filePattern);
IgnoreHiddenFileListFilter ignoreHiddenFileListFilter = new IgnoreHiddenFileListFilter();
List<FileListFilter<File>> fileListFilter = new ArrayList<FileListFilter<File>>();
fileListFilter.add(simplePatternFileListFilter);
fileListFilter.add(ignoreHiddenFileListFilter);
compositeFileListFilter = new CompositeFileListFilter<File>(
fileListFilter);
CustomScanner cs = new CustomScanner();
cs.setFilter(compositeFileListFilter);
fileReadingMessageSource.setScanner(cs);
logger.info("In static method after Initializing frms "
+ fileReadingMessageSource);
}
} catch (Exception e) {
logger.debug("Exception while creating FileReadingMessageSource");
logger.debug("Exception while creating FileReadingMessageSource", e);
return null;
}
return fileReadingMessageSource;
}
@InboundChannelAdapter(value = "inboundchannel", poller = @Poller(fixedDelay = "5000", maxMessagesPerPoll = "1"))
public Message<File> processFiles() {
fileReadingMessageSource = getFileReadingMessageSource();
return fileReadingMessageSource.receive();
}
@ServiceActivator(inputChannel = "inboundchannel")
public void process(Message<File> payload) {
logger.info("In process() ... payload is" + payload.getClass());
processFile(payload);
}
} The above configuration has worked on my local setup perfectly fine . but the same code when I moved to Dev machine , we are getting the Exception which I have mentioned above. will you please provide your comments ? do you still want me to add thanks In Advance. |
There might be some delay and unexpected order for the bean population to the application context which depends of the platform and the count of CPU, or even Java version. So, or you follow with our recommendation and create the |
have same question as radiumx3. to artembilan, just my experience, I've create backend and rest service with spring mvc using java config. but I am still having a hard time to use spring integration, there are people find it difficult with the current version of documentation. |
@maxiwu Well same here, we're working with Spring framework on a daily basis but Spring integration still remain the worst part of it due to a lack of documentation on the Java configuration part (yes we're not into xml configuration at all) 👎 |
We are adding I added a PR for an MQTT sample yesterday. It would be nice if we received more community submissions for this important task. Everything generally fits the same pattern - It's generally pretty easy to use the existing docs (that have new java/dsl config) and samples and to look at the XML parsers to see exactly which beans are needed when using |
It is not at all reasonable (or practical) to ask us to rewrite the entire reference manual, or recreate every sample immediately. But, generally, we try to respond to specific questions such as "how do I configure an 'x' adapter in java", either here or in StackOverflow in a timely manner. We use such questions to drive updates to the reference manual and samples. So, if you have something specific you need, open a new issue here or ask it on Stack Overflow.
The "cheat sheet" is the XML parser source code 😄 which shows every bean that is created when parsing some xml. Each module has a bunch of parsers in the |
"It is not at all reasonable (or practical) to ask us to rewrite the entire reference manual" Well I admit it is some massive work, but for most of us if we can't find it by RTFM, we try to find workaround here and there and almost always end up using xml (because we cannot post on forums / StackOverflow, at work mainly due to data leakage policies) that's why we're pushing for it. |
Guys, please, find the JIRA for documentation improvement https://jira.spring.io/browse/INT-3964. Feel free to comment there your thoughts and ideas! Closing this one since we aren't going to introduce a new repo and we really and new samples here based on the Annotations and DSL foundations. |
The reference JIRA (https://jira.spring.io/browse/INT-3964) has been fixed and you can find a new paragraph in the documentation in the latest SNAPSHOT: http://docs.spring.io/spring-integration/docs/4.3.0.BUILD-SNAPSHOT/reference/html/overview.html#programming-tips |
Any repo for annotation based samples ?
The text was updated successfully, but these errors were encountered: