Comments (17)
Hi @radiumx3 !
Not sure what is your question, but this one can cover any samples related to the Spring Integration.
If you wonder to find some specific sample which reflect some particular use-case just with annotations, you should just ask here and we may consider that as contribution to this repo.
Cheers,
Artem
P.S. Leaving open until your clarification.
from spring-integration-samples.
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
from spring-integration-samples.
See here: http://docs.spring.io/spring-integration/docs/latest-ga/reference/html/files.html#_configuring_with_java_configuration_7
You can find something similar throughout the manual. Not everywhere, of course, but we try to do our best on demand 😄 .
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 @Bean
s with particular Messaging Annotation.
We just didn't think that it is so difficult to get the concrete class from the Framework and follow with the classical Spring Java Config.
In addition consider to study: https://github.com/spring-projects/spring-integration-java-dsl.
from spring-integration-samples.
As far as I understood, Java DSL make extensive use of Java Lambda (Java8) but we have to stick with java7 (internal constraint)
from spring-integration-samples.
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.
from spring-integration-samples.
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 :
Dec 21, 2015 3:22:11 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class com.activiti.servlet.WebConfigurer
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cSVFileProcessor' defined in URL [jar:file:/xjp/appserver_1/tomcat/apache-tomcat-7.0.42/webapps/activiti-app/WEB-INF/lib/nexen-workflow-ext-0.0.3.jar!/com/activiti/extension/bean/CSVFileProcessor.class]: Initialization of bean failed; nested exception is org.springframework.messaging.core.DestinationResolutionException: failed to look up MessageChannel with name 'inboundchannel' in the BeanFactory.; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'inboundchannel' is defined
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at com.activiti.servlet.WebConfigurer.contextInitialized(WebConfigurer.java:67)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at com.activiti.servlet.WebConfigurer.contextInitialized(WebConfigurer.java:67)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:656)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1635)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.springframework.messaging.core.DestinationResolutionException: failed to look up MessageChannel with name 'inboundchannel' in the BeanFactory.; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'inboundchannel' is defined
at org.springframework.integration.support.channel.BeanFactoryChannelResolver.resolveDestination(BeanFactoryChannelResolver.java:112)
at org.springframework.integration.support.channel.BeanFactoryChannelResolver.resolveDestination(BeanFactoryChannelResolver.java:45)
at org.springframework.integration.config.annotation.InboundChannelAdapterAnnotationPostProcessor.postProcess(InboundChannelAdapterAnnotationPostProcessor.java:64)
at org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor$1.doWith(MessagingAnnotationPostProcessor.java:177)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:494)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:501)
at org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor.postProcessAfterInitialization(MessagingAnnotationPostProcessor.java:145)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:422)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1579)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
... 23 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'inboundchannel' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:687)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1168)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:281)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.integration.support.channel.BeanFactoryChannelResolver.resolveDestination(BeanFactoryChannelResolver.java:88)
... 32 more
will you please help me with this Issue ?
from spring-integration-samples.
No bean named 'inboundchannel' is defined
You have to declare @Bean
as a MessageChannel
for that name. Otherwise it doesn't work as you see.
From other side it isn't clear to me why you don't use FileReadingMessageSource
directly as a:
@Bean
@InboundChannelAdapter(value = "inboundchannel", poller = @Poller(fixedDelay = "50000", maxMessagesPerPoll = "1"))
public MessageSource<File> fileMessageSource() {
new FileReadingMessageSource();
.........
}
from spring-integration-samples.
Hi Artem,
thanks a lot for your quick reply.
I will try by keeping @Bean
Annotation and let you know.
to answer your second question , I want to have a single instance of FileReadingMessageSource
through out my Application , that's the reason why I am getting it from a method where I created a single Instance for it.
from spring-integration-samples.
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 @Bean
Annotation.
thanks In Advance.
from spring-integration-samples.
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.
Having that we don't recommend to use auto channel creating
for such kind of configuration from the inbound-channel
to the service-activator
.
So, or you follow with our recommendation and create the @Bean
for the inboundchannel
or you continue live with the issue.
But what is the reason to disturb us than ? 😄
from spring-integration-samples.
have same question as radiumx3.
maybe there could be a document that explain how XML are convert to java config?
for example there is <int:outbound-channel-adapter /> but no annotation @OutboundChannelAdapter
If we could understand how these works, we could write java config sample ourselves.
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.
from spring-integration-samples.
@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) 👎
from spring-integration-samples.
We are adding @Configuration
and DSL samples as time permits; but most of our time is spent enhancing the framework itself.
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 - @InboundChannelAdapter
+ MessageSource
@Bean
for polled adapters, simple @Bean
for event-driven adapters and gateways, and @ServiceActivator
+ MessageHandler
for outbound endpoints.
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 @Configuration
.
from spring-integration-samples.
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.
java <-> xml cheatsheet I would be glad to study it :)
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 o.s.i.xxx.config
package.
from spring-integration-samples.
"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.
Anyway thanks for your help.
from spring-integration-samples.
Guys, please, find the JIRA for documentation improvement https://jira.spring.io/browse/INT-3964.
I don't promise to cover there all your particular cases like "move file workflow", but at least we'll share there the basic concepts how to configure Spring Integration with Java & Annotations.
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.
from spring-integration-samples.
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
from spring-integration-samples.
Related Issues (20)
- JSON or Pipe(|) based DSL for dynamic flow generation in Spring Integration HOT 1
- why @ConditionalOnBean annotation does't work well on the bean which annotated @@MessagingGateway ? HOT 1
- What is required to make DynamicTcpClientApplication also return data with the send interface? HOT 2
- Investigate Failing Test in tcp-client-server-multiplex
- SFTP delegation example HOT 8
- Only accepts one instance of multipart file not an array of multipart file HOT 7
- Add examples for using SI with Project Reactor HOT 4
- Project Structure - Reorganize in favor of JavaDSL and Reactive support HOT 12
- How to import and compile the project locally HOT 1
- Can add the sample code of mqttv5 in spring.integration.samples.basic.mqttv5? HOT 1
- How do I create multiple MQTTClients and generate messages using Spring-Integration-MQTT? HOT 1
- Why getClientInstance is used for inbound and getAsyncClientInstance is used for outbound to get synchronous and asynchronous clients. HOT 5
- Trying to find code examples on Spring Integration scatter gather HOT 3
- How to set up apply-sequence=true through xml configuration HOT 1
- Server-side logging seems to be broken HOT 2
- IMAP with OAuth 2 authentication HOT 8
- Payload Enricher with request-payload-expression="payload.username" HOT 10
- LoanBrokerSharkDetectorDemo.java:48: error: cannot find symbol HOT 1
- sftp - outbound transfer test doesn't work for embedded server HOT 6
- Sample projects to not compile with maven due to lack of <java.version/> property
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-integration-samples.