我正在尝试使用带有xml的apache Camel来获取邮件。请教我如何编写xml。
※我想用xml检查新邮件。邮件新邮件到cur之后。
·XML
<?xml version="1.0" encoding="UTF-8"?>
<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route trace="true">
<to uri="pop3://ipaddress?to=user@domain&username=user@domain&password=user&unseen=true" />
</route>
</camelContext>
</blueprint>
·错误
2018-08-27 04:57:57,360 | INFO | mix-7.0.0/deploy | fileinstall | 4 - org.apache.felix.fileinstall - 3.5.6 | Installing bundle mail-blueprint / 0.1.0.SNAPSHOT
2018-08-27 04:57:57,478 | WARN | mix-7.0.0/deploy | NamespaceHandlerRegistryImpl | 28 - org.apache.aries.blueprint.core - 1.7.1 | NamespaceHandler org.apache.camel.blueprint.handler.CamelNamespaceHandler is behaving badly and should be fixed
2018-08-27 04:57:57,661 | WARN | mix-7.0.0/deploy | DefaultTypeConverter | 43 - org.apache.camel.camel-core - 2.16.4 | Overriding type converter from: StaticMethodTypeConverter: public static org.apache.activemq.command.ActiveMQDestination org.apache.activemq.camel.converter.ActiveMQConverter.toDestination(java.lang.String) to: StaticMethodTypeConverter: public static org.apache.activemq.command.ActiveMQDestination org.apache.activemq.camel.converter.ActiveMQConverter.toDestination(java.lang.String)
2018-08-27 04:57:57,661 | WARN | mix-7.0.0/deploy | DefaultTypeConverter | 43 - org.apache.camel.camel-core - 2.16.4 | Overriding type converter from: InstanceMethodTypeConverter: public org.apache.activemq.command.ActiveMQMessage org.apache.activemq.camel.converter.ActiveMQMessageConverter.toMessage(org.apache.camel.Exchange) throws javax.jms.JMSException to: InstanceMethodTypeConverter: public org.apache.activemq.command.ActiveMQMessage org.apache.activemq.camel.converter.ActiveMQMessageConverter.toMessage(org.apache.camel.Exchange) throws javax.jms.JMSException
2018-08-27 04:57:57,661 | WARN | mix-7.0.0/deploy | DefaultTypeConverter | 43 - org.apache.camel.camel-core - 2.16.4 | Overriding type converter from: InstanceMethodTypeConverter: public org.apache.camel.Processor org.apache.activemq.camel.converter.ActiveMQMessageConverter.toProcessor(javax.jms.MessageListener) to: InstanceMethodTypeConverter: public org.apache.camel.Processor org.apache.activemq.camel.converter.ActiveMQMessageConverter.toProcessor(javax.jms.MessageListener)
2018-08-27 04:57:57,667 | WARN | mix-7.0.0/deploy | BeanRecipe | 28 - org.apache.aries.blueprint.core - 1.7.1 | Object to be destroyed is not an instance of UnwrapperedBeanHolder, type: null
2018-08-27 04:57:57,667 | ERROR | mix-7.0.0/deploy | BlueprintContainerImpl | 28 - org.apache.aries.blueprint.core - 1.7.1 | Unable to start blueprint container for bundle mail-blueprint/0.1.0.SNAPSHOT
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to initialize bean .camelBlueprint.factory.camel-2
at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:738)[28:org.apache.aries.blueprint.core:1.7.1]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:848)[28:org.apache.aries.blueprint.core:1.7.1]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:811)[28:org.apache.aries.blueprint.core:1.7.1]
at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[28:org.apache.aries.blueprint.core:1.7.1]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_181]
at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[28:org.apache.aries.blueprint.core:1.7.1]
at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:255)[28:org.apache.aries.blueprint.core:1.7.1]
at org.apache.aries.blueprint.container.BlueprintRepository.createInstance(BlueprintRepository.java:233)[28:org.apache.aries.blueprint.core:1.7.1]
at org.apache.aries.blueprint.container.BlueprintRepository.create(BlueprintRepository.java:148)[28:org.apache.aries.blueprint.core:1.7.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.getComponentInstance(BlueprintContainerImpl.java:796)[28:org.apache.aries.blueprint.core:1.7.1]
at org.apache.camel.blueprint.handler.CamelNamespaceHandler$CamelDependenciesFinder.process(CamelNamespaceHandler.java:980)[40:org.apache.camel.camel-blueprint:2.16.4]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.processProcessors(BlueprintContainerImpl.java:569)[28:org.apache.aries.blueprint.core:1.7.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:395)[28:org.apache.aries.blueprint.core:1.7.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:276)[28:org.apache.aries.blueprint.core:1.7.1]
at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:300)[28:org.apache.aries.blueprint.core:1.7.1]
at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:269)[28:org.apache.aries.blueprint.core:1.7.1]
at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:265)[28:org.apache.aries.blueprint.core:1.7.1]
at org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:255)[28:org.apache.aries.blueprint.core:1.7.1]
at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)[39:org.apache.aries.util:1.1.1]
at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)[39:org.apache.aries.util:1.1.1]
at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)[39:org.apache.aries.util:1.1.1]
at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)[39:org.apache.aries.util:1.1.1]
at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)[39:org.apache.aries.util:1.1.1]
at org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1179)[org.apache.felix.framework-5.6.1.jar:]
at org.apache.felix.framework.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:730)[org.apache.felix.framework-5.6.1.jar:]
at org.apache.felix.framework.EventDispatcher.fireBundleEvent(EventDispatcher.java:485)[org.apache.felix.framework-5.6.1.jar:]
at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4541)[org.apache.felix.framework-5.6.1.jar:]
at org.apache.felix.framework.Felix.startBundle(Felix.java:2172)[org.apache.felix.framework-5.6.1.jar:]
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)[org.apache.felix.framework-5.6.1.jar:]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1253)[4:org.apache.felix.fileinstall:3.5.6]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1225)[4:org.apache.felix.fileinstall:3.5.6]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:512)[4:org.apache.felix.fileinstall:3.5.6]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:361)[4:org.apache.felix.fileinstall:3.5.6]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:312)[4:org.apache.felix.fileinstall:3.5.6]
Caused by: java.lang.IllegalArgumentException: Route has no outputs: Route[[From[pop3://ipaddress?to=user@domain&username=user@domain&password=user&unseen=true]] -> []]
at org.apache.camel.model.RouteDefinitionHelper.sanityCheckRoute(RouteDefinitionHelper.java:353)
at org.apache.camel.core.xml.AbstractCamelContextFactoryBean.prepareRoutes(AbstractCamelContextFactoryBean.java:400)
at org.apache.camel.core.xml.AbstractCamelContextFactoryBean.setupRoutes(AbstractCamelContextFactoryBean.java:377)
at org.apache.camel.blueprint.CamelContextFactoryBean.afterPropertiesSet(CamelContextFactoryBean.java:322)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.8.0_181]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[:1.8.0_181]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_181]
at java.lang.reflect.Method.invoke(Method.java:498)[:1.8.0_181]
at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:299)[28:org.apache.aries.blueprint.core:1.7.1]
at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:980)[28:org.apache.aries.blueprint.core:1.7.1]
at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:736)[28:org.apache.aries.blueprint.core:1.7.1]
... 33 more
2018-08-27 04:57:57,678 | INFO | mix-7.0.0/deploy | fileinstall | 4 - org.apache.felix.fileinstall - 3.5.6 | Started bundle: file:/opt/apache-servicemix-7.0.0/deploy/mail-blueprint-0.1.0-SNAPSHOT.jar
谢谢=============================================== -
我修好了代码。我在下面每隔1分钟收到servicemix.log。我检查邮件(新目录)移动到cur目录。但我无法在servicemix.log上查看telnet数据的内容我希望以下行为
【问题】为什么添加下面的代码时没有错误?
<log message="received the message with xml" />
·码
<?xml version="1.0" encoding="UTF-8"?>
<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route id="email-consumer-entrypoint-route" trace="true">
<from uri="pop3://ipadress?to=user@domain&username=user@domain&password=user&unseen=true&consumer.delay=60000&mapMailMessage=false&fetchSize=1" />
<log message="received the message with xml" />
</route>
</camelContext>
</blueprint>
·servicemix.log
2018-08-27 07:19:42,960 | INFO | pop3://ipaddress | email-consumer-entrypoint-route | 43 - org.apache.camel.camel-core - 2.16.4 | received the message with xml
2018-08-27 07:20:44,444 | INFO | pop3://ipaddress | email-consumer-entrypoint-route | 43 - org.apache.camel.camel-core - 2.16.4 | received the message with xml
·期待行为
谢谢
===============================================-
我修复并检查了servicemix.log上的邮件我有新问题。
【问题】·我想在代码下方使用“to”标记。但它无法读取“新目录(文件)”,无法在servicemix.log上写入日志消息。我可以将端点写入“to”标签,如下所示吗?
<route id="email-consumer-entrypoint-route" trace="true">
<from uri="direct:start" />
<log message="received the message with xml" />
<to uri="imap://ipaddress?to=user@domain&username=user@domain&password=user&unseen=true&consumer.delay=60000&mapMailMessage=false&fetchSize=1" />
</route>
·固定代码
<?xml version="1.0" encoding="UTF-8"?>
<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route id="email-consumer-entrypoint-route" trace="true">
<from uri="imap://ipaddress?to=user@domain&username=user@domain&password=user&unseen=true&consumer.delay=60000&mapMailMessage=false&fetchSize=1" />
<log message="received the message with xml" />
</route>
</camelContext>
</blueprint>
谢谢=============================================== -
非常感谢你trilok。我有新问题。
【题】
·错误
- 2.16.4 | Error occurred during starting Camel: CamelContext(camel-2) due CronExpression '0 0/5 * * * ?@domain' is invalid.
java.lang.RuntimeException: CronExpression '0 0/5 * * * ?@domain' is invalid.
谢谢
当你说'apache Camel with xml'时,我认为你的意思是说是Spring DSL。
另一件事是,要使用camel接收电子邮件,您将使用camel邮件组件。它会像接收电子邮件一样 -
<route id="email-consumer-entrypoint-route">
<from uri="imaps://[email protected]&password=p@ssword&delete=false&unseen=true&consumer.delay=60000&mapMailMessage=false&fetchSize=1" />
有关详细信息,请查看http://camel.apache.org/mail.html